diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-12-12 22:15:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 22:15:38 +0800 |
commit | ea7fceb6e56f53bde3517586dfc57e10a605a524 (patch) | |
tree | cf2e4b7a403f8bcbcf3d1c4c45a8abd315cbefe6 /main/core/src | |
parent | d0e1b572e88d311e1aee23d92e0384a81de4bcb6 (diff) | |
download | mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.tar.gz mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.tar.bz2 mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.zip |
First pass at splitting out worker-api from mill core. (#504)
This reduces the {scala,scalajs,scalanative}-worker dependency from the entirety of Mill to a much narrower `mill.api` module. This reduces the amount of classpath pollution within these workers, should mean they're much faster to download the first time, and reduces the amount of random junk they would pull in if they were to be used outside of the Mill project.
The interactions between the various *Modules and their *WorkerImpls has been narrowed down to the `*.api` modules, which only depend on other `*.api` modules.
A lot of things have been moved around; user code is unlikely to break, but it's possible some will if it references classes that have been moved around. Forwarders have been left for the few internal classes that Mill uses in it's own `build.sc`, to support bootstrapping. Third-party code which breaks should be a straightforward to fix just by updating imports
The `*.api` modules have minimal dependencies (mostly uPickle and os-lib) and minimal code. There is still a bunch of implementation code in there: some of it defining data-types that are commonly sent across the module/worker interface (`Agg`, `PathRef`, ...), and some of it just general helper functions that are needed both in modules and workers. The latter code isn't strictly API definitions, but for now is small enough it's not worth splitting into it's own module
Diffstat (limited to 'main/core/src')
-rw-r--r-- | main/core/src/mill/define/Applicative.scala | 4 | ||||
-rw-r--r-- | main/core/src/mill/define/Task.scala | 44 | ||||
-rw-r--r-- | main/core/src/mill/eval/Evaluator.scala | 2 | ||||
-rw-r--r-- | main/core/src/mill/eval/PathRef.scala | 69 | ||||
-rw-r--r-- | main/core/src/mill/eval/Result.scala | 36 | ||||
-rw-r--r-- | main/core/src/mill/eval/package.scala | 12 | ||||
-rw-r--r-- | main/core/src/mill/util/ClassLoader.scala | 62 | ||||
-rw-r--r-- | main/core/src/mill/util/Ctx.scala | 55 | ||||
-rw-r--r-- | main/core/src/mill/util/IO.scala | 32 | ||||
-rw-r--r-- | main/core/src/mill/util/JsonFormatters.scala | 43 | ||||
-rw-r--r-- | main/core/src/mill/util/Loggers.scala (renamed from main/core/src/mill/util/Logger.scala) | 43 | ||||
-rw-r--r-- | main/core/src/mill/util/Watched.scala | 2 | ||||
-rw-r--r-- | main/core/src/mill/util/package.scala | 7 |
13 files changed, 49 insertions, 362 deletions
diff --git a/main/core/src/mill/define/Applicative.scala b/main/core/src/mill/define/Applicative.scala index 69c506f7..5e63b1cc 100644 --- a/main/core/src/mill/define/Applicative.scala +++ b/main/core/src/mill/define/Applicative.scala @@ -25,7 +25,7 @@ object Applicative { def self: M[T] def apply()(implicit handler: ApplyHandler[M]): T = handler(self) } - class ImplicitStub extends StaticAnnotation + type Id[+T] = T trait Applyer[W[_], T[_], Z[_], Ctx] extends ApplyerGenerated[T, Z, Ctx] { @@ -81,7 +81,7 @@ object Applicative { tempIdent case (t, api) if t.symbol != null - && t.symbol.annotations.exists(_.tree.tpe =:= typeOf[ImplicitStub]) => + && t.symbol.annotations.exists(_.tree.tpe =:= typeOf[mill.api.Ctx.ImplicitStub]) => val tempIdent = Ident(ctxSym) c.internal.setType(tempIdent, t.tpe) diff --git a/main/core/src/mill/define/Task.scala b/main/core/src/mill/define/Task.scala index 07576724..a464bf18 100644 --- a/main/core/src/mill/define/Task.scala +++ b/main/core/src/mill/define/Task.scala @@ -27,7 +27,7 @@ abstract class Task[+T] extends Task.Ops[T] with Applyable[Task, T]{ /** * Evaluate this target */ - def evaluate(args: mill.util.Ctx): Result[T] + def evaluate(args: mill.api.Ctx): Result[T] /** * Even if this target's inputs did not change, does it need to re-evaluate @@ -53,7 +53,7 @@ trait Target[+T] extends NamedTask[T]{ def readWrite: RW[_] } -object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Result, mill.util.Ctx] { +object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Result, mill.api.Ctx] { implicit def apply[T](t: T) (implicit rw: RW[T], @@ -64,7 +64,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (rw: c.Expr[RW[T]], ctx: c.Expr[mill.define.Ctx]): c.Expr[Target[T]] = { import c.universe._ - val lhs = Applicative.impl0[Task, T, mill.util.Ctx](c)(reify(Result.Success(t.splice)).tree) + val lhs = Applicative.impl0[Task, T, mill.api.Ctx](c)(reify(Result.Success(t.splice)).tree) mill.moduledefs.Cacher.impl0[TargetImpl[T]](c)( reify( @@ -85,7 +85,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul mill.moduledefs.Cacher.impl0[Target[T]](c)( reify( new TargetImpl[T]( - Applicative.impl0[Task, T, mill.util.Ctx](c)(t.tree).splice, + Applicative.impl0[Task, T, mill.api.Ctx](c)(t.tree).splice, ctx.splice, rw.splice ) @@ -118,7 +118,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul import c.universe._ val wrapped = for (value <- values.toList) - yield Applicative.impl0[Task, PathRef, mill.util.Ctx](c)( + yield Applicative.impl0[Task, PathRef, mill.api.Ctx](c)( reify(value.splice.map(PathRef(_))).tree ).tree @@ -144,7 +144,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul mill.moduledefs.Cacher.impl0[Sources](c)( reify( new Sources( - Applicative.impl0[Task, Seq[PathRef], mill.util.Ctx](c)(values.tree).splice, + Applicative.impl0[Task, Seq[PathRef], mill.api.Ctx](c)(values.tree).splice, ctx.splice ) ) @@ -163,7 +163,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul mill.moduledefs.Cacher.impl0[Input[T]](c)( reify( new Input[T]( - Applicative.impl[Task, T, mill.util.Ctx](c)(value).splice, + Applicative.impl[Task, T, mill.api.Ctx](c)(value).splice, ctx.splice, rw.splice ) @@ -194,7 +194,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul import c.universe._ reify( new Command[T]( - Applicative.impl[Task, T, mill.util.Ctx](c)(t).splice, + Applicative.impl[Task, T, mill.api.Ctx](c)(t).splice, ctx.splice, w.splice, cls.splice.value, @@ -214,11 +214,11 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (ctx: c.Expr[mill.define.Ctx]): c.Expr[Worker[T]] = { import c.universe._ reify( - new Worker[T](Applicative.impl[Task, T, mill.util.Ctx](c)(t).splice, ctx.splice) + new Worker[T](Applicative.impl[Task, T, mill.api.Ctx](c)(t).splice, ctx.splice) ) } - def task[T](t: Result[T]): Task[T] = macro Applicative.impl[Task, T, mill.util.Ctx] + def task[T](t: Result[T]): Task[T] = macro Applicative.impl[Task, T, mill.api.Ctx] def persistent[T](t: Result[T])(implicit rw: RW[T], ctx: mill.define.Ctx): Persistent[T] = macro persistentImpl[T] @@ -233,7 +233,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul mill.moduledefs.Cacher.impl0[Persistent[T]](c)( reify( new Persistent[T]( - Applicative.impl[Task, T, mill.util.Ctx](c)(t).splice, + Applicative.impl[Task, T, mill.api.Ctx](c)(t).splice, ctx.splice, rw.splice ) @@ -242,20 +242,20 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul } type TT[+X] = Task[X] - def makeT[X](inputs0: Seq[TT[_]], evaluate0: mill.util.Ctx => Result[X]) = new Task[X] { + def makeT[X](inputs0: Seq[TT[_]], evaluate0: mill.api.Ctx => Result[X]) = new Task[X] { val inputs = inputs0 - def evaluate(x: mill.util.Ctx) = evaluate0(x) + def evaluate(x: mill.api.Ctx) = evaluate0(x) } def underlying[A](v: Task[A]) = v - def mapCtx[A, B](t: Task[A])(f: (A, mill.util.Ctx) => Result[B]) = t.mapDest(f) + def mapCtx[A, B](t: Task[A])(f: (A, mill.api.Ctx) => Result[B]) = t.mapDest(f) def zip() = new Task.Task0(()) def zip[A](a: Task[A]) = a.map(Tuple1(_)) def zip[A, B](a: Task[A], b: Task[B]) = a.zip(b) } abstract class NamedTaskImpl[+T](ctx0: mill.define.Ctx, t: Task[T]) extends NamedTask[T]{ - def evaluate(args: mill.util.Ctx) = args[T](0) + def evaluate(args: mill.api.Ctx) = args[T](0) val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) val inputs = Seq(t) } @@ -303,12 +303,12 @@ object Task { class Task0[T](t: T) extends Task[T]{ lazy val t0 = t val inputs = Nil - def evaluate(args: mill.util.Ctx) = t0 + def evaluate(args: mill.api.Ctx) = t0 } abstract class Ops[+T]{ this: Task[T] => def map[V](f: T => V) = new Task.Mapped(this, f) - def mapDest[V](f: (T, mill.util.Ctx) => Result[V]) = new Task.MappedDest(this, f) + def mapDest[V](f: (T, mill.api.Ctx) => Result[V]) = new Task.MappedDest(this, f) def filter(f: T => Boolean) = this def withFilter(f: T => Boolean) = this @@ -323,22 +323,22 @@ object Task { class Sequence[+T](inputs0: Seq[Task[T]]) extends Task[Seq[T]]{ val inputs = inputs0 - def evaluate(args: mill.util.Ctx) = { + def evaluate(args: mill.api.Ctx) = { for (i <- 0 until args.length) yield args(i).asInstanceOf[T] } } class Mapped[+T, +V](source: Task[T], f: T => V) extends Task[V]{ - def evaluate(args: mill.util.Ctx) = f(args(0)) + def evaluate(args: mill.api.Ctx) = f(args(0)) val inputs = List(source) } - class MappedDest[+T, +V](source: Task[T], f: (T, mill.util.Ctx) => Result[V]) extends Task[V]{ - def evaluate(args: mill.util.Ctx) = f(args(0), args) + class MappedDest[+T, +V](source: Task[T], f: (T, mill.api.Ctx) => Result[V]) extends Task[V]{ + def evaluate(args: mill.api.Ctx) = f(args(0), args) val inputs = List(source) } class Zipped[+T, +V](source1: Task[T], source2: Task[V]) extends Task[(T, V)]{ - def evaluate(args: mill.util.Ctx) = (args(0), args(1)) + def evaluate(args: mill.api.Ctx) = (args(0), args(1)) val inputs = List(source1, source2) } } diff --git a/main/core/src/mill/eval/Evaluator.scala b/main/core/src/mill/eval/Evaluator.scala index 2aafdb7a..8709064e 100644 --- a/main/core/src/mill/eval/Evaluator.scala +++ b/main/core/src/mill/eval/Evaluator.scala @@ -7,7 +7,7 @@ import scala.collection.JavaConverters._ import mill.util.Router.EntryPoint import ammonite.runtime.SpecialClassLoader import mill.define.{Ctx => _, _} -import mill.eval.Result.OuterStack +import mill.api.Result.OuterStack import mill.util import mill.util._ import mill.util.Strict.Agg diff --git a/main/core/src/mill/eval/PathRef.scala b/main/core/src/mill/eval/PathRef.scala deleted file mode 100644 index 92ef8d24..00000000 --- a/main/core/src/mill/eval/PathRef.scala +++ /dev/null @@ -1,69 +0,0 @@ -package mill.eval - -import java.io.IOException -import java.nio.file.attribute.BasicFileAttributes -import java.nio.file.{FileVisitResult, FileVisitor} -import java.nio.{file => jnio} -import java.security.{DigestOutputStream, MessageDigest} - -import upickle.default.{ReadWriter => RW} -import mill.util.{DummyOutputStream, IO, JsonFormatters} - - -/** - * A wrapper around `os.Path` that calculates it's hashcode based - * on the contents of the filesystem underneath it. Used to ensure filesystem - * changes can bust caches which are keyed off hashcodes. - */ -case class PathRef(path: os.Path, quick: Boolean, sig: Int){ - override def hashCode() = sig -} - -object PathRef{ - def apply(path: os.Path, quick: Boolean = false) = { - val sig = { - val digest = MessageDigest.getInstance("MD5") - val digestOut = new DigestOutputStream(DummyOutputStream, digest) - if (os.exists(path)){ - for((path, attrs) <- os.walk.attrs(path, includeTarget = true, followLinks = true)){ - digest.update(path.toString.getBytes) - if (!attrs.isDir) { - if (quick){ - val value = (attrs.mtime, attrs.size).hashCode() - digest.update((value >>> 24).toByte) - digest.update((value >>> 16).toByte) - digest.update((value >>> 8).toByte) - digest.update(value.toByte) - } else if (jnio.Files.isReadable(path.toNIO)) { - val is = os.read.inputStream(path) - IO.stream(is, digestOut) - is.close() - } - } - } - } - - java.util.Arrays.hashCode(digest.digest()) - - } - new PathRef(path, quick, sig) - } - - implicit def jsonFormatter: RW[PathRef] = upickle.default.readwriter[String].bimap[PathRef]( - p => { - (if (p.quick) "qref" else "ref") + ":" + - String.format("%08x", p.sig: Integer) + ":" + - p.path.toString() - }, - s => { - val Array(prefix, hex, path) = s.split(":", 3) - PathRef( - os.Path(path), - prefix match{ case "qref" => true case "ref" => false}, - // Parsing to a long and casting to an int is the only way to make - // round-trip handling of negative numbers work =( - java.lang.Long.parseLong(hex, 16).toInt - ) - } - ) -} diff --git a/main/core/src/mill/eval/Result.scala b/main/core/src/mill/eval/Result.scala deleted file mode 100644 index d0400599..00000000 --- a/main/core/src/mill/eval/Result.scala +++ /dev/null @@ -1,36 +0,0 @@ -package mill.eval - -sealed trait Result[+T]{ - def map[V](f: T => V): Result[V] - def asSuccess: Option[Result.Success[T]] = None -} -object Result{ - implicit def create[T](t: => T): Result[T] = { - try Success(t) - catch { case e: Throwable => Exception(e, new OuterStack(new java.lang.Exception().getStackTrace)) } - } - case class Success[+T](value: T) extends Result[T]{ - def map[V](f: T => V) = Result.Success(f(value)) - override def asSuccess = Some(this) - } - case object Skipped extends Result[Nothing]{ - def map[V](f: Nothing => V) = this - } - sealed trait Failing[+T] extends Result[T]{ - def map[V](f: T => V): Failing[V] - } - case class Failure[T](msg: String, value: Option[T] = None) extends Failing[T]{ - def map[V](f: T => V) = Result.Failure(msg, value.map(f(_))) - } - case class Exception(throwable: Throwable, outerStack: OuterStack) extends Failing[Nothing]{ - def map[V](f: Nothing => V) = this - } - class OuterStack(val value: Seq[StackTraceElement]){ - override def hashCode() = value.hashCode() - - override def equals(obj: scala.Any) = obj match{ - case o: OuterStack => value.equals(o.value) - case _ => false - } - } -}
\ No newline at end of file diff --git a/main/core/src/mill/eval/package.scala b/main/core/src/mill/eval/package.scala new file mode 100644 index 00000000..433f9074 --- /dev/null +++ b/main/core/src/mill/eval/package.scala @@ -0,0 +1,12 @@ +package mill + +package object eval { + // Backwards compatibility forwarders + val Result = mill.api.Result + type Result[+T] = mill.api.Result[T] + + val PathRef = mill.api.PathRef + type PathRef = mill.api.PathRef + + type Logger = mill.api.Logger +} diff --git a/main/core/src/mill/util/ClassLoader.scala b/main/core/src/mill/util/ClassLoader.scala deleted file mode 100644 index 07ab1ca9..00000000 --- a/main/core/src/mill/util/ClassLoader.scala +++ /dev/null @@ -1,62 +0,0 @@ -package mill.util - -import java.net.{URL, URLClassLoader} - - -import io.github.retronym.java9rtexport.Export - -import scala.util.Try - -object ClassLoader { - def create(urls: Seq[URL], - parent: java.lang.ClassLoader) - (implicit ctx: Ctx.Home): URLClassLoader = { - create(urls, parent, _ => None) - } - def create(urls: Seq[URL], - parent: java.lang.ClassLoader, - customFindClass: String => Option[Class[_]]) - (implicit ctx: Ctx.Home): URLClassLoader = { - new URLClassLoader( - makeUrls(urls).toArray, - refinePlatformParent(parent) - ) { - override def findClass(name: String): Class[_] = { - if (name.startsWith("com.sun.jna")) getClass.getClassLoader.loadClass(name) - else customFindClass(name).getOrElse(super.findClass(name)) - } - } - } - - - /** - * Return `ClassLoader.getPlatformClassLoader` for java 9 and above, if parent class loader is null, - * otherwise return same parent class loader. - * More details: https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-A868D0B9-026F-4D46-B979-901834343F9E - * - * `ClassLoader.getPlatformClassLoader` call is implemented via runtime reflection, cause otherwise - * mill could be compiled only with jdk 9 or above. We don't want to introduce this restriction now. - */ - private def refinePlatformParent(parent: java.lang.ClassLoader): ClassLoader = { - if (!ammonite.util.Util.java9OrAbove || parent != null) parent - else { - // Make sure when `parent == null`, we only delegate java.* classes - // to the parent getPlatformClassLoader. This is necessary because - // in Java 9+, somehow the getPlatformClassLoader ends up with all - // sorts of other non-java stuff on it's classpath, which is not what - // we want for an "isolated" classloader! - classOf[ClassLoader] - .getMethod("getPlatformClassLoader") - .invoke(null) - .asInstanceOf[ClassLoader] - } - } - - private def makeUrls(urls: Seq[URL])(implicit ctx: Ctx.Home): Seq[URL] = { - if (ammonite.util.Util.java9OrAbove) { - urls :+ Export.rtAt(ctx.home.toIO).toURI.toURL - } else { - urls - } - } -} diff --git a/main/core/src/mill/util/Ctx.scala b/main/core/src/mill/util/Ctx.scala deleted file mode 100644 index bbc243b7..00000000 --- a/main/core/src/mill/util/Ctx.scala +++ /dev/null @@ -1,55 +0,0 @@ -package mill.util - -import mill.define.Applicative.ImplicitStub - -import scala.annotation.compileTimeOnly -import scala.language.implicitConversions - -object Ctx{ - @compileTimeOnly("Target.ctx() can only be used with a T{...} block") - @ImplicitStub - implicit def taskCtx: Ctx = ??? - - object Dest { - implicit def pathToCtx(path: os.Path): Dest = new Dest { def dest = path } - } - trait Dest{ - def dest: os.Path - } - trait Log{ - def log: Logger - } - trait Home{ - def home: os.Path - } - trait Env{ - def env: Map[String, String] - } - object Log{ - implicit def logToCtx(l: Logger): Log = new Log { def log = l } - } - trait Args{ - def args: IndexedSeq[_] - } - - def defaultHome = ammonite.ops.home / ".mill" / "ammonite" - -} -class Ctx(val args: IndexedSeq[_], - dest0: () => os.Path, - val log: Logger, - val home: os.Path, - val env : Map[String, String]) - extends Ctx.Dest - with Ctx.Log - with Ctx.Args - with Ctx.Home - with Ctx.Env { - - def dest = dest0() - def length = args.length - def apply[T](index: Int): T = { - if (index >= 0 && index < args.length) args(index).asInstanceOf[T] - else throw new IndexOutOfBoundsException(s"Index $index outside of range 0 - ${args.length}") - } -} diff --git a/main/core/src/mill/util/IO.scala b/main/core/src/mill/util/IO.scala deleted file mode 100644 index 833e52c7..00000000 --- a/main/core/src/mill/util/IO.scala +++ /dev/null @@ -1,32 +0,0 @@ -package mill.util - -import java.io.{InputStream, OutputStream} - -import scala.tools.nsc.interpreter.OutputStream - -/** - * Misc IO utilities, eventually probably should be pushed upstream into - * ammonite-ops - */ -object IO { - def stream(src: InputStream, dest: OutputStream) = { - val buffer = new Array[Byte](4096) - while ( { - src.read(buffer) match { - case -1 => false - case n => - dest.write(buffer, 0, n) - true - } - }) () - } -} - -import java.io.{ByteArrayInputStream, OutputStream} - -object DummyInputStream extends ByteArrayInputStream(Array()) -object DummyOutputStream extends OutputStream{ - override def write(b: Int) = () - override def write(b: Array[Byte]) = () - override def write(b: Array[Byte], off: Int, len: Int) = () -} diff --git a/main/core/src/mill/util/JsonFormatters.scala b/main/core/src/mill/util/JsonFormatters.scala index dba599f7..830782c6 100644 --- a/main/core/src/mill/util/JsonFormatters.scala +++ b/main/core/src/mill/util/JsonFormatters.scala @@ -1,49 +1,10 @@ package mill.util import upickle.default.{ReadWriter => RW} -import scala.util.matching.Regex -object JsonFormatters extends JsonFormatters -trait JsonFormatters { - implicit val pathReadWrite: RW[os.Path] = upickle.default.readwriter[String] - .bimap[os.Path]( - _.toString, - os.Path(_) - ) - - implicit val regexReadWrite: RW[Regex] = upickle.default.readwriter[String] - .bimap[Regex]( - _.pattern.toString, - _.r - ) - - implicit val bytesReadWrite: RW[os.Bytes] = upickle.default.readwriter[String] - .bimap( - o => java.util.Base64.getEncoder.encodeToString(o.array), - str => new os.Bytes(java.util.Base64.getDecoder.decode(str)) - ) - - - implicit lazy val crFormat: RW[os.CommandResult] = upickle.default.macroRW +trait JsonFormatters extends mill.api.JsonFormatters{ implicit lazy val modFormat: RW[coursier.Module] = upickle.default.macroRW implicit lazy val depFormat: RW[coursier.Dependency]= upickle.default.macroRW implicit lazy val attrFormat: RW[coursier.Attributes] = upickle.default.macroRW - implicit val stackTraceRW = upickle.default.readwriter[ujson.Obj].bimap[StackTraceElement]( - ste => ujson.Obj( - "declaringClass" -> ujson.Str(ste.getClassName), - "methodName" -> ujson.Str(ste.getMethodName), - "fileName" -> ujson.Str(ste.getFileName), - "lineNumber" -> ujson.Num(ste.getLineNumber) - ), - {case json: ujson.Obj => - new StackTraceElement( - json("declaringClass").str.toString, - json("methodName").str.toString, - json("fileName").str.toString, - json("lineNumber").num.toInt - ) - } - ) - - } +object JsonFormatters extends JsonFormatters diff --git a/main/core/src/mill/util/Logger.scala b/main/core/src/mill/util/Loggers.scala index 4857953d..aab1a324 100644 --- a/main/core/src/mill/util/Logger.scala +++ b/main/core/src/mill/util/Loggers.scala @@ -1,46 +1,7 @@ package mill.util import java.io._ - -import ammonite.util.Colors - -/** - * The standard logging interface of the Mill build tool. - * - * Contains these primary logging methods, in order of increasing importance: - * - * - `debug` : internal debug messages normally not shown to the user; - * mostly useful when debugging issues - * - * - `ticker`: short-lived logging output where consecutive lines over-write - * each other; useful for information which is transient and disposable - * - * - `info`: miscellaneous logging output which isn't part of the main output - * a user is looking for, but useful to provide context on what Mill is doing - * - * - `error`: logging output which represents problems the user should care - * about - * - * - * Also contains the two forwarded stdout and stderr streams, for code executed - * by Mill to use directly. Typically these correspond to the stdout and stderr, - * but when `show` is used both are forwarded to stderr and stdout is only - * used to display the final `show` output for easy piping. - */ -trait Logger { - def colored: Boolean - - val errorStream: PrintStream - val outputStream: PrintStream - val inStream: InputStream - - def info(s: String): Unit - def error(s: String): Unit - def ticker(s: String): Unit - def debug(s: String): Unit - - def close(): Unit = () -} +import mill.api.Logger object DummyLogger extends Logger { def colored = false @@ -160,7 +121,7 @@ case class FileLogger(colored: Boolean, file: os.Path, debugEnabled: Boolean) ex def error(s: String) = outputStream.println(s) def ticker(s: String) = outputStream.println(s) def debug(s: String) = if (debugEnabled) outputStream.println(s) - val inStream: InputStream = DummyInputStream + val inStream: InputStream = mill.api.DummyInputStream override def close() = { if (outputStreamUsed) outputStream.close() diff --git a/main/core/src/mill/util/Watched.scala b/main/core/src/mill/util/Watched.scala index f1ef4fee..29be53c3 100644 --- a/main/core/src/mill/util/Watched.scala +++ b/main/core/src/mill/util/Watched.scala @@ -1,6 +1,6 @@ package mill.util -import mill.eval.PathRef +import mill.api.PathRef case class Watched[T](value: T, watched: Seq[PathRef]) object Watched{ diff --git a/main/core/src/mill/util/package.scala b/main/core/src/mill/util/package.scala new file mode 100644 index 00000000..ec5d2efc --- /dev/null +++ b/main/core/src/mill/util/package.scala @@ -0,0 +1,7 @@ +package mill + +package object util { + // Backwards compat stubs + val Ctx = mill.api.Ctx + type Ctx = mill.api.Ctx +} |