diff options
Diffstat (limited to 'scalaplugin')
4 files changed, 22 insertions, 16 deletions
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala index 87a42d04..4ccb71cd 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala @@ -4,7 +4,7 @@ import ammonite.ops._ import mill.discover.Mirror.Segment import mill.discover.{Discovered, Mirror} import mill.eval.{Evaluator, PathRef} -import mill.util.OSet +import mill.util.{OSet, PrintLogger} object GenIdea { @@ -22,7 +22,7 @@ object GenIdea { val discovered = implicitly[Discovered[T]] val mapping = Discovered.mapping(obj)(discovered) val workspacePath = pwd / 'out - val evaluator = new Evaluator(workspacePath, mapping, _ => ()) + val evaluator = new Evaluator(workspacePath, mapping, new PrintLogger(true)) val modules = Mirror .traverse(obj, discovered.mirror){ (h, p) => diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index eb9026ba..292c41a6 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -1,7 +1,7 @@ package mill package scalaplugin -import java.io.File +import java.io.{File, PrintStream, PrintWriter, Writer} import java.net.URLClassLoader import java.util.Optional import java.util.concurrent.Callable @@ -86,7 +86,9 @@ object ScalaModule{ val logger = { - val consoleAppender = MainAppender.defaultScreen(ConsoleOut.printStreamOut(ctx.log)) + val consoleAppender = MainAppender.defaultScreen(ConsoleOut.printStreamOut( + ctx.log.outputStream + )) val l = LogExchange.logger("Hello") LogExchange.unbindLoggerAppenders("Hello") LogExchange.bindLoggerAppenders("Hello", (consoleAppender -> sbt.util.Level.Info) :: Nil) diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala b/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala index 03292b68..43e15974 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala @@ -6,6 +6,8 @@ import java.net.URLClassLoader import java.util.zip.ZipInputStream import ammonite.ops.{Path, ls, pwd} +import mill.util.Ctx.LogCtx +import mill.util.PrintLogger import sbt.testing._ import scala.collection.mutable @@ -43,14 +45,17 @@ object TestRunner { entireClasspath = args(1).split(" ").map(Path(_)), testClassfilePath = args(2).split(" ").map(Path(_)), args = args(3) match{ case "" => Nil case x => x.split(" ").toList } - ) + )(new LogCtx { + def log = new PrintLogger(true) + }) val outputPath = args(4) ammonite.ops.write(Path(outputPath), upickle.default.write(result)) } def apply(frameworkName: String, entireClasspath: Seq[Path], testClassfilePath: Seq[Path], - args: Seq[String]): Option[String] = { + args: Seq[String]) + (implicit ctx: LogCtx): Option[String] = { val outerClassLoader = getClass.getClassLoader val cl = new URLClassLoader( entireClasspath.map(_.toIO.toURI.toURL).toArray, @@ -86,17 +91,17 @@ object TestRunner { }, Array( new Logger { - def debug(msg: String) = println(msg) + def debug(msg: String) = ctx.log.info(msg) - def error(msg: String) = println(msg) + def error(msg: String) = ctx.log.error(msg) def ansiCodesSupported() = true - def warn(msg: String) = println(msg) + def warn(msg: String) = ctx.log.info(msg) - def trace(t: Throwable) = println(t) + def trace(t: Throwable) = t.printStackTrace(ctx.log.outputStream) - def info(msg: String) = println(msg) + def info(msg: String) = ctx.log.info(msg) }) ) } @@ -107,7 +112,7 @@ object TestRunner { val grouped = events.groupBy(x => x).mapValues(_.length).filter(_._2 != 0).toList.sorted grouped.map{case (k, v) => k + ": " + v}.mkString(",") } - println(msg) + ctx.log.info(msg) if (events.count(Set(Status.Error, Status.Failure)) == 0) None else Some(msg) } diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala b/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala index e54480c9..49c245e4 100644 --- a/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala +++ b/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala @@ -4,20 +4,19 @@ import ammonite.ops.Path import mill.define.{Target, Task} import mill.discover.Mirror import mill.eval.{Evaluator, Result} -import mill.util.OSet +import mill.util.{DummyLogger, OSet} object TestEvaluator { - private val noopLogger: String => Unit = _ => () def resolveDestPaths(workspacePath: Path)(t: Mirror.LabelledTarget[_]): (Path, Path) = { - new Evaluator(workspacePath, Map.empty, noopLogger).resolveDestPaths(t) + new Evaluator(workspacePath, Map.empty, DummyLogger).resolveDestPaths(t) } def eval[T]( mapping: Map[Target[_], Mirror.LabelledTarget[_]], workspacePath: Path)(t: Task[T]): Either[Result.Failing, (T, Int)] = { - val evaluator = new Evaluator(workspacePath, mapping, noopLogger) + val evaluator = new Evaluator(workspacePath, mapping, DummyLogger) val evaluated = evaluator.evaluate(OSet(t)) if (evaluated.failing.keyCount == 0) { |