From ea7fceb6e56f53bde3517586dfc57e10a605a524 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 12 Dec 2018 22:15:38 +0800 Subject: 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 --- contrib/twirllib/src/mill/twirllib/TwirlModule.scala | 4 ++-- contrib/twirllib/src/mill/twirllib/TwirlWorker.scala | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'contrib/twirllib') diff --git a/contrib/twirllib/src/mill/twirllib/TwirlModule.scala b/contrib/twirllib/src/mill/twirllib/TwirlModule.scala index 8f735f3a..328afc47 100644 --- a/contrib/twirllib/src/mill/twirllib/TwirlModule.scala +++ b/contrib/twirllib/src/mill/twirllib/TwirlModule.scala @@ -3,7 +3,7 @@ package twirllib import coursier.{Cache, MavenRepository} import mill.define.Sources -import mill.eval.PathRef +import mill.api.PathRef import mill.scalalib.Lib.resolveDependencies import mill.scalalib._ import mill.util.Loose @@ -41,7 +41,7 @@ trait TwirlModule extends mill.Module { private def twirlInclusiveDot: Boolean = false - def compileTwirl: T[CompilationResult] = T.persistent { + def compileTwirl: T[mill.scalalib.api.CompilationResult] = T.persistent { TwirlWorkerApi.twirlWorker .compile( twirlClasspath().map(_.path), diff --git a/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala b/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala index b8fe9c66..09376a6f 100644 --- a/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala +++ b/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala @@ -5,11 +5,10 @@ import java.io.File import java.lang.reflect.Method import java.net.URLClassLoader -import mill.eval.PathRef -import mill.scalalib.CompilationResult +import mill.api.PathRef +import mill.scalalib.api.CompilationResult import scala.io.Codec - class TwirlWorker { private var twirlInstanceCache = Option.empty[(Long, TwirlWorkerApi)] @@ -103,7 +102,7 @@ class TwirlWorker { constructorAnnotations: Seq[String], codec: Codec, inclusiveDot: Boolean) - (implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = { + (implicit ctx: mill.api.Ctx): mill.api.Result[CompilationResult] = { val compiler = twirl(twirlClasspath) def compileTwirlDir(inputDir: os.Path) { @@ -127,7 +126,7 @@ class TwirlWorker { val zincFile = ctx.dest / 'zinc val classesDir = ctx.dest - mill.eval.Result.Success(CompilationResult(zincFile, PathRef(classesDir))) + mill.api.Result.Success(CompilationResult(zincFile, PathRef(classesDir))) } private def twirlExtensionFormat(name: String) = -- cgit v1.2.3