diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:36:35 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:36:35 -0800 |
commit | 4c76e9668ab9683dad1966bcd6fb5031a81f8460 (patch) | |
tree | 333a31b9f5dc247f94ea7011b108502a0fb1bdf1 /core | |
parent | 932bc5c53bb380930e04765ae51c5a128f3b35fb (diff) | |
download | mill-4c76e9668ab9683dad1966bcd6fb5031a81f8460.tar.gz mill-4c76e9668ab9683dad1966bcd6fb5031a81f8460.tar.bz2 mill-4c76e9668ab9683dad1966bcd6fb5031a81f8460.zip |
- Renamed `Ctx.FooCtx` => `Ctx.Foo`
- Remove un-used `Evaluator#millSourcePath` parameter
Diffstat (limited to 'core')
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 6 | ||||
-rw-r--r-- | core/src/mill/main/ReplApplyHandler.scala | 3 | ||||
-rw-r--r-- | core/src/mill/main/RunScript.scala | 2 | ||||
-rw-r--r-- | core/src/mill/modules/Jvm.scala | 6 | ||||
-rw-r--r-- | core/src/mill/modules/Util.scala | 6 | ||||
-rw-r--r-- | core/src/mill/util/Ctx.scala | 29 | ||||
-rw-r--r-- | core/test/src/mill/define/CacherTests.scala | 2 | ||||
-rw-r--r-- | core/test/src/mill/eval/CrossTests.scala | 12 | ||||
-rw-r--r-- | core/test/src/mill/eval/EvaluationTests.scala | 2 | ||||
-rw-r--r-- | core/test/src/mill/eval/FailureTests.scala | 10 | ||||
-rw-r--r-- | core/test/src/mill/eval/JavaCompileJarTests.scala | 8 | ||||
-rw-r--r-- | core/test/src/mill/eval/ModuleTests.scala | 3 | ||||
-rw-r--r-- | core/test/src/mill/eval/TaskTests.scala | 9 | ||||
-rw-r--r-- | core/test/src/mill/util/TestEvaluator.scala | 6 |
14 files changed, 39 insertions, 65 deletions
diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index 4028588b..78317474 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -25,7 +25,6 @@ case class Labelled[T](task: NamedTask[T], } } class Evaluator[T](val outPath: Path, - val millSourcePath: Path, val externalOutPath: Path, val rootModule: mill.Module, val discover: Discover[T], @@ -119,7 +118,6 @@ class Evaluator[T](val outPath: Path, group, results, inputsHash, - groupBasePath = None, paths = None, maybeTargetLabel = None, counterMsg = counterMsg @@ -131,7 +129,6 @@ class Evaluator[T](val outPath: Path, labelledNamedTask.segments ) - val groupBasePath = millSourcePath / Evaluator.makeSegmentStrings(labelledNamedTask.segments) mkdir(paths.out) val cached = for{ json <- scala.util.Try(upickle.json.read(read(paths.meta))).toOption @@ -166,7 +163,6 @@ class Evaluator[T](val outPath: Path, group, results, inputsHash, - groupBasePath = Some(groupBasePath), paths = Some(paths), maybeTargetLabel = Some(msgParts.mkString), counterMsg = counterMsg @@ -206,7 +202,6 @@ class Evaluator[T](val outPath: Path, def evaluateGroup(group: Agg[Task[_]], results: collection.Map[Task[_], Result[(Any, Int)]], inputsHash: Int, - groupBasePath: Option[Path], paths: Option[Evaluator.Paths], maybeTargetLabel: Option[String], counterMsg: String) = { @@ -263,7 +258,6 @@ class Evaluator[T](val outPath: Path, throw new Exception("No `dest` folder available here") } }, - groupBasePath.orNull, multiLogger ) diff --git a/core/src/mill/main/ReplApplyHandler.scala b/core/src/mill/main/ReplApplyHandler.scala index 67ff8498..bea68d94 100644 --- a/core/src/mill/main/ReplApplyHandler.scala +++ b/core/src/mill/main/ReplApplyHandler.scala @@ -15,10 +15,9 @@ object ReplApplyHandler{ discover: Discover[_]) = { new ReplApplyHandler( pprinter0, - new mill.eval.Evaluator( + new Evaluator( ammonite.ops.pwd, ammonite.ops.pwd / 'out, - ammonite.ops.pwd / 'out, rootModule, discover, new mill.util.PrintLogger( diff --git a/core/src/mill/main/RunScript.scala b/core/src/mill/main/RunScript.scala index dfe49c57..a38baedd 100644 --- a/core/src/mill/main/RunScript.scala +++ b/core/src/mill/main/RunScript.scala @@ -42,7 +42,7 @@ object RunScript{ val eval = for((mapping, discover) <- evaluateMapping(wd, path, interp)) yield new Evaluator[Any]( - wd / 'out, wd / 'out, wd, mapping, discover, log, + wd / 'out, wd, mapping, discover, log, mapping.getClass.getClassLoader.asInstanceOf[SpecialClassLoader].classpathSignature ) diff --git a/core/src/mill/modules/Jvm.scala b/core/src/mill/modules/Jvm.scala index a22f0c77..4ac03a97 100644 --- a/core/src/mill/modules/Jvm.scala +++ b/core/src/mill/modules/Jvm.scala @@ -10,7 +10,7 @@ import ammonite.ops._ import mill.define.Task import mill.eval.PathRef import mill.util.{Ctx, Loose} -import mill.util.Ctx.LogCtx +import mill.util.Ctx.Log import mill.util.Loose.Agg import upickle.default.{Reader, Writer} @@ -161,7 +161,7 @@ object Jvm { } def createJar(inputPaths: Agg[Path], mainClass: Option[String] = None) - (implicit ctx: Ctx.DestCtx): PathRef = { + (implicit ctx: Ctx.Dest): PathRef = { val outputPath = ctx.dest / "out.jar" rm(outputPath) @@ -198,7 +198,7 @@ object Jvm { def createAssembly(inputPaths: Agg[Path], mainClass: Option[String] = None, prependShellScript: String = "") - (implicit ctx: Ctx.DestCtx): PathRef = { + (implicit ctx: Ctx.Dest): PathRef = { val outputPath = ctx.dest / "out.jar" rm(outputPath) diff --git a/core/src/mill/modules/Util.scala b/core/src/mill/modules/Util.scala index ce1203cf..cef11859 100644 --- a/core/src/mill/modules/Util.scala +++ b/core/src/mill/modules/Util.scala @@ -6,7 +6,7 @@ import mill.eval.PathRef import mill.util.Ctx object Util { - def download(url: String, dest: RelPath = "download")(implicit ctx: Ctx.DestCtx) = { + def download(url: String, dest: RelPath = "download")(implicit ctx: Ctx.Dest) = { val out = ctx.dest / dest val website = new java.net.URI(url).toURL @@ -25,7 +25,7 @@ object Util { } def downloadUnpackZip(url: String, dest: RelPath = "unpacked") - (implicit ctx: Ctx.DestCtx) = { + (implicit ctx: Ctx.Dest) = { val tmpName = if (dest == empty / "tmp.zip") "tmp2.zip" else "tmp.zip" val downloaded = download(url, tmpName) @@ -33,7 +33,7 @@ object Util { } def unpackZip(src: Path, dest: RelPath = "unpacked") - (implicit ctx: Ctx.DestCtx) = { + (implicit ctx: Ctx.Dest) = { val byteStream = read.getInputStream(src) val zipStream = new java.util.zip.ZipInputStream(byteStream) diff --git a/core/src/mill/util/Ctx.scala b/core/src/mill/util/Ctx.scala index fb5384ef..55cc05ab 100644 --- a/core/src/mill/util/Ctx.scala +++ b/core/src/mill/util/Ctx.scala @@ -2,7 +2,6 @@ package mill.util import ammonite.ops.Path import mill.define.Applicative.ImplicitStub -import mill.util.Ctx.{ArgCtx, BaseCtx, DestCtx, LogCtx} import scala.annotation.compileTimeOnly import scala.language.implicitConversions @@ -12,37 +11,29 @@ object Ctx{ @ImplicitStub implicit def taskCtx: Ctx = ??? - object DestCtx { - implicit def pathToCtx(path: Path): DestCtx = new DestCtx { def dest = path } + object Dest { + implicit def pathToCtx(path: Path): Dest = new Dest { def dest = path } } - trait DestCtx{ + trait Dest{ def dest: Path } - trait BaseCtx{ - def base: Path - } - object BaseCtx { - implicit def pathToCtx(path: Path): BaseCtx = new BaseCtx { def base = path } - } - trait LogCtx{ + trait Log{ def log: Logger } - object LogCtx{ - implicit def logToCtx(l: Logger): LogCtx = new LogCtx { def log = l } + object Log{ + implicit def logToCtx(l: Logger): Log = new Log { def log = l } } - trait ArgCtx{ + trait Args{ def args: IndexedSeq[_] } } class Ctx(val args: IndexedSeq[_], dest0: () => Path, - val base: Path, val log: Logger) - extends DestCtx - with LogCtx - with ArgCtx - with BaseCtx{ + extends Ctx.Dest + with Ctx.Log + with Ctx.Args{ def dest = dest0() def length = args.length diff --git a/core/test/src/mill/define/CacherTests.scala b/core/test/src/mill/define/CacherTests.scala index 7619e770..a14f2f34 100644 --- a/core/test/src/mill/define/CacherTests.scala +++ b/core/test/src/mill/define/CacherTests.scala @@ -29,7 +29,7 @@ object CacherTests extends TestSuite{ def eval[T <: TestUtil.TestBuild, V](mapping: T, v: Task[V]) (implicit discover: Discover[T], tp: TestPath) = { val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value - val evaluator = new TestEvaluator(mapping, workspace, pwd) + val evaluator = new TestEvaluator(mapping, workspace) evaluator(v).right.get._1 } diff --git a/core/test/src/mill/eval/CrossTests.scala b/core/test/src/mill/eval/CrossTests.scala index 6c369cc0..af13474b 100644 --- a/core/test/src/mill/eval/CrossTests.scala +++ b/core/test/src/mill/eval/CrossTests.scala @@ -13,8 +13,7 @@ object CrossTests extends TestSuite{ 'singleCross - { val check = new TestEvaluator( singleCross, - pwd / 'target / 'workspace / "cross-tests" / "inputs", - pwd + pwd / 'target / 'workspace / "cross-tests" / "inputs" ) val Right(("210", 1)) = check.apply(singleCross.cross("210").suffix) @@ -25,8 +24,7 @@ object CrossTests extends TestSuite{ 'crossResolved - { val check = new TestEvaluator( crossResolved, - pwd / 'target / 'workspace / "cross-tests" / "crossResolved", - pwd + pwd / 'target / 'workspace / "cross-tests" / "crossResolved" ) val Right(("2.10", 1)) = check.apply(crossResolved.foo("2.10").suffix) @@ -42,8 +40,7 @@ object CrossTests extends TestSuite{ 'doubleCross - { val check = new TestEvaluator( doubleCross, - pwd / 'target / 'workspace / "cross-tests" / "doubleCross", - pwd + pwd / 'target / 'workspace / "cross-tests" / "doubleCross" ) val Right(("210_jvm", 1)) = check.apply(doubleCross.cross("210", "jvm").suffix) @@ -58,8 +55,7 @@ object CrossTests extends TestSuite{ 'nestedCrosses - { val check = new TestEvaluator( nestedCrosses, - pwd / 'target / 'workspace / "cross-tests" / "nestedCrosses", - pwd + pwd / 'target / 'workspace / "cross-tests" / "nestedCrosses" ) val Right(("210_jvm", 1)) = check.apply(nestedCrosses.cross("210").cross2("jvm").suffix) diff --git a/core/test/src/mill/eval/EvaluationTests.scala b/core/test/src/mill/eval/EvaluationTests.scala index 386d5340..9fabe623 100644 --- a/core/test/src/mill/eval/EvaluationTests.scala +++ b/core/test/src/mill/eval/EvaluationTests.scala @@ -17,7 +17,7 @@ object EvaluationTests extends TestSuite{ rm(Path(workspace, pwd)) // Make sure data is persisted even if we re-create the evaluator each time - def evaluator = new TestEvaluator(module, workspace, pwd).evaluator + def evaluator = new TestEvaluator(module, workspace).evaluator def apply(target: Task[_], expValue: Any, expEvaled: Agg[Task[_]], diff --git a/core/test/src/mill/eval/FailureTests.scala b/core/test/src/mill/eval/FailureTests.scala index d4758a12..e7c231ee 100644 --- a/core/test/src/mill/eval/FailureTests.scala +++ b/core/test/src/mill/eval/FailureTests.scala @@ -1,7 +1,7 @@ package mill.eval import mill.T import mill.util.{TestEvaluator, TestUtil} -import ammonite.ops.pwd +import ammonite.ops.{Path, pwd, rm} import utest._ import utest.framework.TestPath import mill.util.TestEvaluator.implicitDisover @@ -18,7 +18,7 @@ object FailureTests extends TestSuite{ 'evaluateSingle - { ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd)) - val check = new TestEvaluator(singleton, workspace, pwd) + val check = new TestEvaluator(singleton, workspace) check.fail( target = singleton.single, expectedFailCount = 0, @@ -53,8 +53,8 @@ object FailureTests extends TestSuite{ ) } 'evaluatePair - { - val check = new TestEvaluator(pair, workspace, pwd) - ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd)) + val check = new TestEvaluator(pair, workspace) + rm(Path(workspace, pwd)) check.fail( pair.down, expectedFailCount = 0, @@ -95,7 +95,7 @@ object FailureTests extends TestSuite{ def right = T{ task() + left() + T.ctx().dest.toString().length } } - val check = new TestEvaluator(build, workspace, pwd) + val check = new TestEvaluator(build, workspace) val Right(_) = check(build.left) val Left(Result.Exception(e, _)) = check(build.right) assert(e.getMessage.contains("`dest` can only be used in one place")) diff --git a/core/test/src/mill/eval/JavaCompileJarTests.scala b/core/test/src/mill/eval/JavaCompileJarTests.scala index 0137f372..ba80cc3c 100644 --- a/core/test/src/mill/eval/JavaCompileJarTests.scala +++ b/core/test/src/mill/eval/JavaCompileJarTests.scala @@ -4,7 +4,7 @@ import ammonite.ops.ImplicitWd._ import ammonite.ops._ import mill.define.{Discover, Input, Target, Task} import mill.modules.Jvm -import mill.util.Ctx.DestCtx +import mill.util.Ctx.Dest import mill.{Module, T} import mill.util.{DummyLogger, Loose, TestEvaluator, TestUtil} import mill.util.Strict.Agg @@ -12,7 +12,7 @@ import utest._ import mill._ import TestEvaluator.implicitDisover object JavaCompileJarTests extends TestSuite{ - def compileAll(sources: Seq[PathRef])(implicit ctx: DestCtx) = { + def compileAll(sources: Seq[PathRef])(implicit ctx: Dest) = { mkdir(ctx.dest) import ammonite.ops._ %("javac", sources.map(_.path.toString()), "-d", ctx.dest)(wd = ctx.dest) @@ -50,11 +50,11 @@ object JavaCompileJarTests extends TestSuite{ import Build._ def eval[T](t: Task[T]) = { - val evaluator = new TestEvaluator(Build, workspacePath, pwd) + val evaluator = new TestEvaluator(Build, workspacePath) evaluator.apply(t) } def check(targets: Agg[Task[_]], expected: Agg[Task[_]]) = { - val evaluator = new TestEvaluator(Build, workspacePath, pwd) + val evaluator = new TestEvaluator(Build, workspacePath) evaluator.check(targets, expected) } diff --git a/core/test/src/mill/eval/ModuleTests.scala b/core/test/src/mill/eval/ModuleTests.scala index db70fee3..c7e85169 100644 --- a/core/test/src/mill/eval/ModuleTests.scala +++ b/core/test/src/mill/eval/ModuleTests.scala @@ -22,8 +22,7 @@ object ModuleTests extends TestSuite{ 'externalModuleTargetsAreNamespacedByModulePackagePath - { val check = new TestEvaluator( Build, - pwd / 'target / 'external, - pwd + pwd / 'target / 'external ) val Right((30, 1)) = check.apply(Build.z) diff --git a/core/test/src/mill/eval/TaskTests.scala b/core/test/src/mill/eval/TaskTests.scala index 9d868006..af2e19a9 100644 --- a/core/test/src/mill/eval/TaskTests.scala +++ b/core/test/src/mill/eval/TaskTests.scala @@ -58,8 +58,7 @@ object TaskTests extends TestSuite{ // to re-evaluate, but normal Tasks behind a Target run once then are cached val check = new TestEvaluator( build, - pwd / 'target / 'workspace / "task-tests" / "inputs", - pwd + pwd / 'target / 'workspace / "task-tests" / "inputs" ) val Right((1, 1)) = check.apply(build.taskInput) @@ -75,8 +74,7 @@ object TaskTests extends TestSuite{ // Persistent tasks keep the working dir around between runs val check = new TestEvaluator( build, - pwd / 'target / 'workspace / "task-tests" / "persistent", - pwd + pwd / 'target / 'workspace / "task-tests" / "persistent" ) val Right((1, 1)) = check.apply(build.persistent) val Right((2, 1)) = check.apply(build.persistent) @@ -91,8 +89,7 @@ object TaskTests extends TestSuite{ // Persistent task def check = new TestEvaluator( build, - pwd / 'target / 'workspace / "task-tests" / "worker", - pwd + pwd / 'target / 'workspace / "task-tests" / "worker" ) val Right((2, 1)) = check.apply(build.noisyWorkerDownstream) diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala index 416ed71c..dd113b55 100644 --- a/core/test/src/mill/util/TestEvaluator.scala +++ b/core/test/src/mill/util/TestEvaluator.scala @@ -12,13 +12,11 @@ object TestEvaluator{ implicit def implicitDisover[T]: Discover[T] = macro applyImpl[T] val externalOutPath = pwd / 'target / 'external } -class TestEvaluator[T <: TestUtil.TestBuild](module: T, - workspacePath: Path, - millSourcePath: Path) +class TestEvaluator[T <: TestUtil.TestBuild](module: T, workspacePath: Path) (implicit discover: Discover[T]){ // val logger = DummyLogger val logger = new PrintLogger(true, ammonite.util.Colors.Default, System.out, System.out, System.err) - val evaluator = new Evaluator(workspacePath, millSourcePath, TestEvaluator.externalOutPath, module, discover, logger) + val evaluator = new Evaluator(workspacePath, TestEvaluator.externalOutPath, module, discover, logger) def apply[T](t: Task[T]): Either[Result.Failing, (T, Int)] = { val evaluated = evaluator.evaluate(Agg(t)) |