diff options
18 files changed, 146 insertions, 41 deletions
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index 3a00bdb8..66f7ee59 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -46,7 +46,8 @@ object Main { else cliConfig.copy( predefCode = """import $file.build, build._ - |implicit val replApplyHandler = mill.main.ReplApplyHandler(build.mapping) + |implicit val replApplyHandler = mill.main.ReplApplyHandler(repl.pprinter(), build.mapping) + |repl.pprinter() = replApplyHandler.pprinter |import replApplyHandler.generatedEval._ | """.stripMargin, diff --git a/core/src/main/scala/mill/define/Cross.scala b/core/src/main/scala/mill/define/Cross.scala index 55d7b59c..90a383a6 100644 --- a/core/src/main/scala/mill/define/Cross.scala +++ b/core/src/main/scala/mill/define/Cross.scala @@ -1,6 +1,6 @@ package mill.define -case class Cross[+T](items: List[(List[Any], T)]){ +case class Cross[+T](items: List[(List[Any], T)])(implicit val e: sourcecode.Enclosing, val l: sourcecode.Line){ def flatMap[V](f: T => Cross[V]): Cross[V] = new Cross( items.flatMap{ case (l, v) => f(v).items.map{case (l2, v2) => (l2 ::: l, v2)} @@ -27,4 +27,5 @@ object Cross{ } class CrossModule[T, V](constructor: T => V, cases: T*) + (implicit e: sourcecode.Enclosing, l: sourcecode.Line) extends Cross[V](cases.toList.map(x => (List(x), constructor(x))))
\ No newline at end of file diff --git a/core/src/main/scala/mill/define/Task.scala b/core/src/main/scala/mill/define/Task.scala index b29f173b..6ee9c606 100644 --- a/core/src/main/scala/mill/define/Task.scala +++ b/core/src/main/scala/mill/define/Task.scala @@ -42,6 +42,7 @@ trait NamedTask[+T] extends Task[T]{ trait Target[+T] extends NamedTask[T]{ override def asTarget = Some(this) def enclosing: String + def lineNum: Int def readWrite: RW[_] } @@ -51,6 +52,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (implicit r: R[T], w: W[T], e: sourcecode.Enclosing, + l: sourcecode.Line, n: sourcecode.Name, cl: Caller[mill.define.Task.Module], o: Overrides): Target[T] = macro targetImpl[T] @@ -60,6 +62,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (r: c.Expr[R[T]], w: c.Expr[W[T]], e: c.Expr[sourcecode.Enclosing], + l: c.Expr[sourcecode.Line], n: c.Expr[sourcecode.Name], cl: c.Expr[Caller[mill.define.Task.Module]], o: c.Expr[Overrides]): c.Expr[Target[T]] = { @@ -71,6 +74,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul new TargetImpl[T]( lhs.splice, e.splice.value, + l.splice.value, cl.splice.value, n.splice.value, upickle.default.ReadWriter(w.splice.write, r.splice.read), o.splice.value @@ -83,6 +87,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (implicit r: R[T], w: W[T], e: sourcecode.Enclosing, + l: sourcecode.Line, n: sourcecode.Name, cl: Caller[mill.define.Task.Module], o: Overrides): Target[T] = macro targetResultImpl[T] @@ -92,6 +97,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (r: c.Expr[R[T]], w: c.Expr[W[T]], e: c.Expr[sourcecode.Enclosing], + l: c.Expr[sourcecode.Line], n: c.Expr[sourcecode.Name], cl: c.Expr[Caller[mill.define.Task.Module]], o: c.Expr[Overrides]): c.Expr[Target[T]] = { @@ -101,6 +107,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul new TargetImpl[T]( Applicative.impl0[Task, T, Ctx](c)(t.tree).splice, e.splice.value, + l.splice.value, cl.splice.value, n.splice.value, upickle.default.ReadWriter(w.splice.write, r.splice.read), @@ -114,6 +121,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (implicit r: R[T], w: W[T], e: sourcecode.Enclosing, + l: sourcecode.Line, n: sourcecode.Name, cl: Caller[mill.define.Task.Module], o: Overrides): Target[T] = macro targetTaskImpl[T] @@ -123,6 +131,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (r: c.Expr[R[T]], w: c.Expr[W[T]], e: c.Expr[sourcecode.Enclosing], + l: c.Expr[sourcecode.Line], n: c.Expr[sourcecode.Name], cl: c.Expr[Caller[mill.define.Task.Module]], o: c.Expr[Overrides]): c.Expr[Target[T]] = { @@ -132,6 +141,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul new TargetImpl[T]( t.splice, e.splice.value, + l.splice.value, cl.splice.value, n.splice.value, upickle.default.ReadWriter(w.splice.write, r.splice.read), @@ -152,6 +162,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (implicit r: R[PathRef], w: W[PathRef], e: sourcecode.Enclosing, + l: sourcecode.Line, n: sourcecode.Name, cl: Caller[mill.define.Task.Module], o: Overrides): Input[PathRef] = macro sourceImpl @@ -161,6 +172,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (r: c.Expr[R[PathRef]], w: c.Expr[W[PathRef]], e: c.Expr[sourcecode.Enclosing], + l: c.Expr[sourcecode.Line], n: c.Expr[sourcecode.Name], cl: c.Expr[Caller[mill.define.Task.Module]], o: c.Expr[Overrides]): c.Expr[Input[PathRef]] = { @@ -174,6 +186,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul new Input[PathRef]( Applicative.impl0[Task, PathRef, Ctx](c)(wrapped.tree).splice, e.splice.value, + l.splice.value, cl.splice.value, n.splice.value, upickle.default.ReadWriter(w.splice.write, r.splice.read), @@ -187,6 +200,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (implicit r: R[T], w: W[T], e: sourcecode.Enclosing, + l: sourcecode.Line, n: sourcecode.Name, cl: Caller[mill.define.Task.Module], o: Overrides): Input[T] = macro inputImpl[T] @@ -196,6 +210,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (r: c.Expr[R[T]], w: c.Expr[W[T]], e: c.Expr[sourcecode.Enclosing], + l: c.Expr[sourcecode.Line], n: c.Expr[sourcecode.Name], cl: c.Expr[Caller[mill.define.Task.Module]], o: c.Expr[Overrides]): c.Expr[Input[T]] = { @@ -206,6 +221,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul new Input[T]( Applicative.impl[Task, T, Ctx](c)(value).splice, e.splice.value, + l.splice.value, cl.splice.value, n.splice.value, upickle.default.ReadWriter(w.splice.write, r.splice.read), @@ -247,6 +263,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul def persistent[T](t: Result[T])(implicit r: R[T], w: W[T], e: sourcecode.Enclosing, + l: sourcecode.Line, n: sourcecode.Name, cl: Caller[mill.define.Task.Module], o: Overrides): Target[T] = macro persistentImpl[T] @@ -256,6 +273,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul (r: c.Expr[R[T]], w: c.Expr[W[T]], e: c.Expr[sourcecode.Enclosing], + l: c.Expr[sourcecode.Line], n: c.Expr[sourcecode.Name], cl: c.Expr[Caller[mill.define.Task.Module]], o: c.Expr[Overrides]): c.Expr[Persistent[T]] = { @@ -267,6 +285,7 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul new Persistent[T]( Applicative.impl[Task, T, Ctx](c)(t).splice, e.splice.value, + l.splice.value, cl.splice.value, n.splice.value, upickle.default.ReadWriter(w.splice.write, r.splice.read), @@ -301,6 +320,7 @@ object Caller { class TargetImpl[+T](t: Task[T], val enclosing: String, + val lineNum: Int, val owner: Task.Module, val name: String, val readWrite: RW[_], @@ -321,16 +341,18 @@ class Command[+T](t: Task[T], } class Persistent[+T](t: Task[T], enclosing: String, + lineNum: Int, owner: Task.Module, name: String, readWrite: RW[_], overrides: Int) - extends TargetImpl[T](t, enclosing, owner, name, readWrite, overrides) { + extends TargetImpl[T](t, enclosing, lineNum, owner, name, readWrite, overrides) { override def flushDest = false override def asPersistent = Some(this) } class Input[T](t: Task[T], val enclosing: String, + val lineNum: Int, val owner: Task.Module, val name: String, val readWrite: RW[_], @@ -346,7 +368,21 @@ object Task { trait TaskModule extends Module { def defaultCommandName(): String } - trait Module extends mill.moduledefs.Cacher + + /** + * `Module` is a class meant to be extended by `trait`s *only*, in order to + * propagate the implicit parameters forward to the final concrete + * instantiation site so they can capture the enclosing/line information of + * the concrete instance. + */ + class Module(implicit millModuleEnclosing0: sourcecode.Enclosing, + millModuleLine0: sourcecode.Line) extends mill.moduledefs.Cacher{ + // Ensure we do not propagate the implicit parameters as implicits within + // the body of any inheriting class/trait/objects, as it would screw up any + // one else trying to use sourcecode.{Enclosing,Line} to capture debug info + val millModuleEnclosing = millModuleEnclosing0 + val millModuleLine = millModuleLine0 + } class Task0[T](t: T) extends Task[T]{ lazy val t0 = t diff --git a/core/src/main/scala/mill/discover/Discovered.scala b/core/src/main/scala/mill/discover/Discovered.scala index 9528a310..58e2c3bb 100644 --- a/core/src/main/scala/mill/discover/Discovered.scala +++ b/core/src/main/scala/mill/discover/Discovered.scala @@ -24,7 +24,7 @@ object Discovered { } case class Mapping[T](mirror: Mirror[T, T], base: T){ - val modules = Mirror.traverse(base, mirror){ (mirror, segmentsRev) => + val modulesToPaths = Mirror.traverse(base, mirror){ (mirror, segmentsRev) => val resolvedNode = mirror.node( base, segmentsRev.reverse.map{case Mirror.Segment.Cross(vs) => vs.toList case _ => Nil}.toList @@ -32,7 +32,15 @@ object Discovered { Seq(resolvedNode -> segmentsRev.reverse) }.toMap - val targets = Mirror.traverse(base, mirror){ (mirror, segmentsRev) => + val modulesToMirrors = Mirror.traverse[T, T, (Any, Mirror[_, _])](base, mirror){ (mirror, segmentsRev) => + val resolvedNode = mirror.node( + base, + segmentsRev.reverse.map{case Mirror.Segment.Cross(vs) => vs.toList case _ => Nil}.toList + ) + Seq(resolvedNode -> mirror) + }.toMap + + val targetsToSegments = Mirror.traverse(base, mirror){ (mirror, segmentsRev) => val resolvedNode = mirror.node( base, segmentsRev.reverse.map{case Mirror.Segment.Cross(vs) => vs.toList case _ => Nil}.toList @@ -48,14 +56,14 @@ object Discovered { yield (segmentsRev.reverse :+ Segment.Label(command.name)) -> command }.toMap - val segmentsToTargets = targets.map(_.swap) + val segmentsToTargets = targetsToSegments.map(_.swap) } def consistencyCheck[T](mapping: Discovered.Mapping[T]) = { val mapping2 = Discovered.Mapping(mapping.mirror, mapping.base) for{ - (t1, t2) <- mapping2.targets.zip(mapping.targets) + (t1, t2) <- mapping2.targetsToSegments.zip(mapping.targetsToSegments) if t1._1 ne t2._1 } yield t1._2 } diff --git a/core/src/main/scala/mill/discover/Mirror.scala b/core/src/main/scala/mill/discover/Mirror.scala index 42339fd7..63b6900b 100644 --- a/core/src/main/scala/mill/discover/Mirror.scala +++ b/core/src/main/scala/mill/discover/Mirror.scala @@ -20,13 +20,14 @@ case class Mirror[-T, V](node: (T, List[List[Any]]) => V, crossChildren: Option[(V => List[List[Any]], Mirror[T, _])]) object Mirror{ - def renderSelector(selector: Seq[Mirror.Segment]) = { - val Mirror.Segment.Label(head) :: rest = selector.toList - val stringSegments = rest.map{ - case Mirror.Segment.Label(s) => "." + s - case Mirror.Segment.Cross(vs) => "[" + vs.mkString(",") + "]" - } - head + stringSegments.mkString + def renderSelector(selector: Seq[Mirror.Segment]) = selector.toList match { + case Nil => "" + case Mirror.Segment.Label(head) :: rest => + val stringSegments = rest.map{ + case Mirror.Segment.Label(s) => "." + s + case Mirror.Segment.Cross(vs) => "[" + vs.mkString(",") + "]" + } + head + stringSegments.mkString } sealed trait Segment diff --git a/core/src/main/scala/mill/eval/Evaluator.scala b/core/src/main/scala/mill/eval/Evaluator.scala index 5aa3439c..ccb81da3 100644 --- a/core/src/main/scala/mill/eval/Evaluator.scala +++ b/core/src/main/scala/mill/eval/Evaluator.scala @@ -40,8 +40,8 @@ class Evaluator[T](val workspacePath: Path, val transitive = Graph.transitiveTargets(goals) val topoSorted = Graph.topoSorted(transitive) val sortedGroups = Graph.groupAroundImportantTargets(topoSorted){ - case t: NamedTask[Any] if mapping.modules.contains(t.owner) => - val segments = mapping.modules(t.owner) :+ Segment.Label(t.name) + case t: NamedTask[Any] if mapping.modulesToPaths.contains(t.owner) => + val segments = mapping.modulesToPaths(t.owner) :+ Segment.Label(t.name) val (finalTaskOverrides, enclosing) = t match{ case t: Target[_] => mapping.segmentsToTargets(segments).overrides -> t.enclosing case c: mill.define.Command[_] => mapping.segmentsToCommands(segments).overrides -> c.enclosing diff --git a/core/src/main/scala/mill/main/ReplApplyHandler.scala b/core/src/main/scala/mill/main/ReplApplyHandler.scala index 7817a77f..a2da4a2f 100644 --- a/core/src/main/scala/mill/main/ReplApplyHandler.scala +++ b/core/src/main/scala/mill/main/ReplApplyHandler.scala @@ -2,13 +2,17 @@ package mill.main import mill.define.Applicative.ApplyHandler -import mill.define.Task -import mill.discover.Discovered +import mill.define.{Cross, Target, Task} +import mill.discover.Mirror.Segment +import mill.discover.{Discovered, Mirror} import mill.eval.Evaluator import mill.util.OSet + +import scala.collection.mutable object ReplApplyHandler{ - def apply[T](mapping: Discovered.Mapping[T]) = { + def apply[T](pprinter0: pprint.PPrinter, mapping: Discovered.Mapping[T]) = { new ReplApplyHandler( + pprinter0, new mill.eval.Evaluator( ammonite.ops.pwd / 'out, ammonite.ops.pwd, @@ -18,7 +22,7 @@ object ReplApplyHandler{ ) } } -class ReplApplyHandler(evaluator: Evaluator[_]) extends ApplyHandler[Task] { +class ReplApplyHandler(pprinter0: pprint.PPrinter, evaluator: Evaluator[_]) extends ApplyHandler[Task] { // Evaluate classLoaderSig only once in the REPL to avoid busting caches // as the user enters more REPL commands and changes the classpath val classLoaderSig = Evaluator.classLoaderSig @@ -27,4 +31,53 @@ class ReplApplyHandler(evaluator: Evaluator[_]) extends ApplyHandler[Task] { } val generatedEval = new EvalGenerated(evaluator) + + val millHandlers: PartialFunction[Any, pprint.Tree] = { + case c: Cross[_] => + pprint.Tree.Lazy( ctx => + Iterator(c.e.value, ":", c.l.value.toString) ++ + c.items.iterator.map(x => + "\n (" + x._1.map(pprint.PPrinter.BlackWhite.apply(_)).mkString(", ") + ")" + ) + ) + case m: mill.Module if evaluator.mapping.modulesToMirrors.contains(m) => + val mirror = evaluator.mapping.modulesToMirrors(m) + pprint.Tree.Lazy( ctx => + Iterator(m.millModuleEnclosing.value, ":", m.millModuleLine.value.toString) ++ + (if (mirror.children.isEmpty) Nil + else ctx.applyPrefixColor("\nChildren:").toString +: mirror.children.map("\n ." + _._1)) ++ + (if (mirror.commands.isEmpty) Nil + else ctx.applyPrefixColor("\nCommands:").toString +: mirror.commands.sortBy(_.name).map{c => + "\n ." + c.name + "(" + + c.argSignatures.map(s => s.name + ": " + s.typeString).mkString(", ") + + ")()" + }) ++ + (if (mirror.targets.isEmpty) Nil + else ctx.applyPrefixColor("\nTargets:").toString +: mirror.targets.sortBy(_.label).map(t => + "\n ." + t.label + "()" + )) + + ) + case t: mill.define.Target[_] if evaluator.mapping.targetsToSegments.contains(t) => + val seen = mutable.Set.empty[Task[_]] + def rec(t: Task[_]): Seq[Seq[Segment]] = { + if (seen(t)) Nil // do nothing + else t match { + case t: Target[_] if evaluator.mapping.targetsToSegments.contains(t) => + Seq(evaluator.mapping.targetsToSegments(t)) + case _ => + seen.add(t) + t.inputs.flatMap(rec) + } + } + pprint.Tree.Lazy(ctx => + Iterator(t.enclosing, ":", t.lineNum.toString, "\n", ctx.applyPrefixColor("Inputs:").toString) ++ + t.inputs.iterator.flatMap(rec).map("\n " + Mirror.renderSelector(_)) + ) + + } + ammonite.main.Cli + val pprinter = pprinter0.copy( + additionalHandlers = millHandlers orElse pprinter0.additionalHandlers + ) } diff --git a/core/src/main/scala/mill/main/RunScript.scala b/core/src/main/scala/mill/main/RunScript.scala index f5523bb6..e2c8ce6c 100644 --- a/core/src/main/scala/mill/main/RunScript.scala +++ b/core/src/main/scala/mill/main/RunScript.scala @@ -163,7 +163,7 @@ object RunScript{ val json = for(t <- Seq(target)) yield { t match { case t: mill.define.NamedTask[_] => - for (segments <- evaluator.mapping.modules.get(t.owner)) yield { + for (segments <- evaluator.mapping.modulesToPaths.get(t.owner)) yield { val jsonFile = Evaluator.resolveDestPaths(evaluator.workspacePath, segments :+ Segment.Label(t.name)).meta val metadata = upickle.json.read(jsonFile.toIO) metadata(1) diff --git a/core/src/test/scala/mill/define/GraphTests.scala b/core/src/test/scala/mill/define/GraphTests.scala index d17f125f..a850a0d2 100644 --- a/core/src/test/scala/mill/define/GraphTests.scala +++ b/core/src/test/scala/mill/define/GraphTests.scala @@ -157,7 +157,7 @@ object GraphTests extends TestSuite{ Graph.transitiveTargets(OSet.from(goals)) ) val grouped = Graph.groupAroundImportantTargets(topoSorted) { - case t: NamedTask[Any] if mapping.modules.contains(t.owner) => t + case t: NamedTask[Any] if mapping.modulesToPaths.contains(t.owner) => t case t if goals.contains(t) => t } grouped.keyCount diff --git a/core/src/test/scala/mill/discover/CrossModuleTests.scala b/core/src/test/scala/mill/discover/CrossModuleTests.scala index 99d33800..e0a7a1a0 100644 --- a/core/src/test/scala/mill/discover/CrossModuleTests.scala +++ b/core/src/test/scala/mill/discover/CrossModuleTests.scala @@ -77,14 +77,14 @@ object CrossModuleTests extends TestSuite{ val discovered = Discovered.mapping(singleCross) - val segments = discovered.targets.values.toSet + val segments = discovered.targetsToSegments.values.toSet val expectedSegments = Set( List(Label("cross"), Segment.Cross(List("210")), Label("suffix")), List(Label("cross"), Segment.Cross(List("211")), Label("suffix")), List(Label("cross"), Segment.Cross(List("212")), Label("suffix")) ) assert(segments == expectedSegments) - val targets = discovered.targets.keys.toSet + val targets = discovered.targetsToSegments.keys.toSet val expected = Set( singleCross.cross("210").suffix, singleCross.cross("211").suffix, @@ -95,7 +95,7 @@ object CrossModuleTests extends TestSuite{ 'doubleCrossTargetDiscovery - { val discovered = Discovered.mapping(doubleCross) - val targets = discovered.targets.keys.toSet + val targets = discovered.targetsToSegments.keys.toSet val expected = Set( doubleCross.cross("jvm", "210").suffix, @@ -110,7 +110,7 @@ object CrossModuleTests extends TestSuite{ } 'nestedCrosses - { - val discovered = Discovered.mapping(nestedCrosses).targets + val discovered = Discovered.mapping(nestedCrosses).targetsToSegments assert(discovered.size == 9) } } diff --git a/core/src/test/scala/mill/discover/DiscoveredTests.scala b/core/src/test/scala/mill/discover/DiscoveredTests.scala index 8501f4cc..1a22e901 100644 --- a/core/src/test/scala/mill/discover/DiscoveredTests.scala +++ b/core/src/test/scala/mill/discover/DiscoveredTests.scala @@ -26,7 +26,7 @@ object DiscoveredTests extends TestSuite{ ) assert(flattenedHierarchy == expectedHierarchy) - val mapped = discovered.targets.map(_.swap) + val mapped = discovered.targetsToSegments.map(_.swap) val expected = Seq( (List(Label("classInstance"), Label("single")), nestedModule.classInstance.single), @@ -38,7 +38,7 @@ object DiscoveredTests extends TestSuite{ 'traitWithModule - { val discovered = Discovered.mapping(TraitWithModuleObject) - val mapped = discovered.targets.map(_.swap) + val mapped = discovered.targetsToSegments.map(_.swap) val expected = Map( ( List(Label("TraitModule"), Label("testFramework")), diff --git a/core/src/test/scala/mill/discover/LabelingTests.scala b/core/src/test/scala/mill/discover/LabelingTests.scala index 71c6a6bf..595d3ad9 100644 --- a/core/src/test/scala/mill/discover/LabelingTests.scala +++ b/core/src/test/scala/mill/discover/LabelingTests.scala @@ -16,7 +16,7 @@ object LabelingTests extends TestSuite{ def check(mapping: Discovered.Mapping[_], t: Task[_], relPath: Option[String]) = { - val names: Seq[(Task[_], Seq[Mirror.Segment])] = mapping.targets.toSeq + val names: Seq[(Task[_], Seq[Mirror.Segment])] = mapping.targetsToSegments.toSeq val nameMap = names.toMap val targetLabel = nameMap.get(t).map(_.map{case Label(v) => v}.mkString(".")) diff --git a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala index 5ddbb68e..ca317a06 100644 --- a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala +++ b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala @@ -58,7 +58,7 @@ object JavaCompileJarTests extends TestSuite{ Right(Tuple2( evaluated.rawValues(0).asInstanceOf[Result.Success[T]].value, evaluated.evaluated.collect{ - case t: Target[_] if mapping.targets.contains(t) => t + case t: Target[_] if mapping.targetsToSegments.contains(t) => t case t: mill.define.Command[_] => t }.size )) @@ -73,7 +73,7 @@ object JavaCompileJarTests extends TestSuite{ val evaluated = evaluator.evaluate(targets) .evaluated .flatMap(_.asTarget) - .filter(mapping.targets.contains) + .filter(mapping.targetsToSegments.contains) .filter(!_.isInstanceOf[Input[_]]) assert(evaluated == expected) } diff --git a/core/src/test/scala/mill/util/TestEvaluator.scala b/core/src/test/scala/mill/util/TestEvaluator.scala index 646ca418..f18cfabf 100644 --- a/core/src/test/scala/mill/util/TestEvaluator.scala +++ b/core/src/test/scala/mill/util/TestEvaluator.scala @@ -18,7 +18,7 @@ class TestEvaluator(mapping: Discovered.Mapping[_], Tuple2( evaluated.rawValues.head.asInstanceOf[Result.Success[T]].value, evaluated.evaluated.collect { - case t: Target[_] if mapping.targets.contains(t) && !t.isInstanceOf[Input[_]] => t + case t: Target[_] if mapping.targetsToSegments.contains(t) && !t.isInstanceOf[Input[_]] => t case t: mill.define.Command[_] => t }.size )) diff --git a/core/src/test/scala/mill/util/TestGraphs.scala b/core/src/test/scala/mill/util/TestGraphs.scala index 0f2c769f..25c806fa 100644 --- a/core/src/test/scala/mill/util/TestGraphs.scala +++ b/core/src/test/scala/mill/util/TestGraphs.scala @@ -92,7 +92,10 @@ class TestGraphs(){ val e = { val c = test.anon(a) val d = test.anon(a) - test(test.anon(test.anon(), test.anon(c)), test.anon(test.anon(c, test.anon(d, b)))) + test( + test.anon(test.anon(), test.anon(c)), + test.anon(test.anon(c, test.anon(d, b))) + ) } val f = test(test.anon(test.anon(), test.anon(e))) diff --git a/core/src/test/scala/mill/util/TestUtil.scala b/core/src/test/scala/mill/util/TestUtil.scala index b1e37481..0d28fcf6 100644 --- a/core/src/test/scala/mill/util/TestUtil.scala +++ b/core/src/test/scala/mill/util/TestUtil.scala @@ -36,14 +36,16 @@ object TestUtil { * test how changes propagate. */ class TestTarget(inputs: Seq[Task[Int]], - val pure: Boolean) - (implicit enclosing0: sourcecode.Enclosing, - owner0: Caller[mill.Module], - name0: sourcecode.Name, - o: Overrides) + val pure: Boolean) + (implicit enclosing0: sourcecode.Enclosing, + lineNum0: sourcecode.Line, + owner0: Caller[mill.Module], + name0: sourcecode.Name, + o: Overrides) extends Test(inputs) with Target[Int]{ val overrides = o.value val enclosing = enclosing0.value + val lineNum = lineNum0.value val owner = owner0.value val name = name0.value val readWrite = upickle.default.IntRW diff --git a/scalalib/src/main/scala/mill/scalalib/GenIdea.scala b/scalalib/src/main/scala/mill/scalalib/GenIdea.scala index 99d8a9ad..cb059def 100644 --- a/scalalib/src/main/scala/mill/scalalib/GenIdea.scala +++ b/scalalib/src/main/scala/mill/scalalib/GenIdea.scala @@ -79,7 +79,7 @@ object GenIdea { val paths = Evaluator.resolveDestPaths( evaluator.workspacePath, - evaluator.mapping.modules(mod.compile) + evaluator.mapping.modulesToPaths(mod.compile) ) val elem = moduleXmlTemplate( diff --git a/scalalib/src/test/scala/mill/scalalib/HelloWorldTests.scala b/scalalib/src/test/scala/mill/scalalib/HelloWorldTests.scala index eb883469..4cd1d58d 100644 --- a/scalalib/src/test/scala/mill/scalalib/HelloWorldTests.scala +++ b/scalalib/src/test/scala/mill/scalalib/HelloWorldTests.scala @@ -176,7 +176,7 @@ object HelloWorldTests extends TestSuite { val paths = Evaluator.resolveDestPaths( outPath, - helloWorldEvaluator.evaluator.mapping.targets(HelloWorld.compile) + helloWorldEvaluator.evaluator.mapping.targetsToSegments(HelloWorld.compile) ) assert( |