summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/mill/define/Discover.scala25
-rw-r--r--core/src/mill/define/Task.scala41
-rw-r--r--core/src/mill/eval/Evaluator.scala26
-rw-r--r--core/src/mill/main/MainRunner.scala4
-rw-r--r--core/src/mill/main/ReplApplyHandler.scala5
-rw-r--r--core/src/mill/main/Resolve.scala4
-rw-r--r--core/src/mill/main/RunScript.scala4
-rw-r--r--core/test/src/mill/define/CacherTests.scala16
-rw-r--r--core/test/src/mill/eval/EvaluationTests.scala77
-rw-r--r--core/test/src/mill/eval/FailureTests.scala10
-rw-r--r--core/test/src/mill/eval/JavaCompileJarTests.scala6
-rw-r--r--core/test/src/mill/eval/TaskTests.scala4
-rw-r--r--core/test/src/mill/util/TestEvaluator.scala5
-rw-r--r--core/test/src/mill/util/TestGraphs.scala2
-rw-r--r--integration/test/src/mill/integration/IntegrationTestSuite.scala1
-rw-r--r--scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala4
-rw-r--r--scalalib/src/mill/scalalib/GenIdea.scala8
-rw-r--r--scalalib/test/src/mill/scalalib/GenIdeaTests.scala3
-rw-r--r--scalalib/test/src/mill/scalalib/HelloWorldTests.scala8
19 files changed, 187 insertions, 66 deletions
diff --git a/core/src/mill/define/Discover.scala b/core/src/mill/define/Discover.scala
index 52f4ab77..5e0e9a05 100644
--- a/core/src/mill/define/Discover.scala
+++ b/core/src/mill/define/Discover.scala
@@ -1,11 +1,14 @@
package mill.define
import language.experimental.macros
-import ammonite.main.Router.EntryPoint
+import ammonite.main.Router.{EntryPoint, Overrides}
+import sourcecode.Compat.Context
import scala.collection.mutable
import scala.reflect.macros.blackbox
-case class Discover(value: Map[Class[_], Seq[EntryPoint[_]]])
+
+
+case class Discover(value: Map[Class[_], Seq[(Int, EntryPoint[_])]])
object Discover {
def apply[T]: Discover = macro applyImpl[T]
@@ -41,14 +44,20 @@ object Discover {
val router = new ammonite.main.Router(c)
val mapping = for{
discoveredModuleType <- seen
- val routes = router.getAllRoutesForClass(
- discoveredModuleType.asInstanceOf[router.c.Type],
- _.returnType <:< weakTypeOf[mill.define.Command[_]].asInstanceOf[router.c.Type]
- ).map(_.asInstanceOf[c.Tree])
- if routes.nonEmpty
+ val curCls = discoveredModuleType.asInstanceOf[router.c.Type]
+ val methods = router.getValsOrMeths(curCls)
+ val overridesRoutes = {
+ for{
+ m <- methods.toList
+ if m.returnType <:< weakTypeOf[mill.define.Command[_]].asInstanceOf[router.c.Type]
+ } yield (m.overrides.length, router.extractMethod(m, curCls).asInstanceOf[c.Tree])
+ }
+ if overridesRoutes.nonEmpty
+ val (overrides, routes) = overridesRoutes.unzip
+
} yield {
val lhs = q"classOf[${discoveredModuleType.typeSymbol.asClass}]"
- val rhs = q"scala.Seq[ammonite.main.Router.EntryPoint[${discoveredModuleType.typeSymbol.asClass}]](..$routes)"
+ val rhs = q"scala.Seq[(Int, ammonite.main.Router.EntryPoint[${discoveredModuleType.typeSymbol.asClass}])](..$overridesRoutes)"
q"$lhs -> $rhs"
}
diff --git a/core/src/mill/define/Task.scala b/core/src/mill/define/Task.scala
index a6d90922..f74171ec 100644
--- a/core/src/mill/define/Task.scala
+++ b/core/src/mill/define/Task.scala
@@ -1,13 +1,26 @@
package mill.define
+import ammonite.main.Router.Overrides
import mill.define.Applicative.Applyable
import mill.eval.{PathRef, Result}
-
+import sourcecode.Compat.Context
import upickle.default.{ReadWriter => RW, Reader => R, Writer => W}
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
+case class EnclosingClass(value: Class[_])
+object EnclosingClass{
+ def apply()(implicit c: EnclosingClass) = c.value
+ implicit def generate: EnclosingClass = macro impl
+ def impl(c: Context): c.Tree = {
+ import c.universe._
+ val cls = c.internal.enclosingOwner.owner.asType.asClass
+// q"new _root_.mill.define.EnclosingClass(classOf[$cls])"
+ q"new _root_.mill.define.EnclosingClass(this.getClass)"
+ }
+}
+
/**
* Models a single node in the Mill build graph, with a list of inputs and a
* single output of type [[T]].
@@ -164,19 +177,33 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul
def command[T](t: Task[T])
(implicit ctx: mill.define.Ctx,
- w: W[T]): Command[T] = new Command(t, ctx, w)
+ w: W[T],
+ cls: EnclosingClass,
+ overrides: Overrides): Command[T] = {
+ new Command(t, ctx, w, cls.value, overrides.value)
+ }
def command[T](t: Result[T])
(implicit w: W[T],
- ctx: mill.define.Ctx): Command[T] = macro commandImpl[T]
+ ctx: mill.define.Ctx,
+ cls: EnclosingClass,
+ overrides: Overrides): Command[T] = macro commandImpl[T]
def commandImpl[T: c.WeakTypeTag](c: Context)
(t: c.Expr[T])
(w: c.Expr[W[T]],
- ctx: c.Expr[mill.define.Ctx]): c.Expr[Command[T]] = {
+ ctx: c.Expr[mill.define.Ctx],
+ cls: c.Expr[EnclosingClass],
+ overrides: c.Expr[Overrides]): c.Expr[Command[T]] = {
import c.universe._
reify(
- new Command[T](Applicative.impl[Task, T, mill.util.Ctx](c)(t).splice, ctx.splice, w.splice)
+ new Command[T](
+ Applicative.impl[Task, T, mill.util.Ctx](c)(t).splice,
+ ctx.splice,
+ w.splice,
+ cls.splice.value,
+ overrides.splice.value
+ )
)
}
@@ -255,7 +282,9 @@ class TargetImpl[+T](t: Task[T],
class Command[+T](t: Task[T],
ctx0: mill.define.Ctx,
- val writer: W[_]) extends NamedTaskImpl[T](ctx0, t) {
+ val writer: W[_],
+ val cls: Class[_],
+ val overrides: Int) extends NamedTaskImpl[T](ctx0, t) {
override def asCommand = Some(this)
}
diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala
index f1a34e69..d5c273d2 100644
--- a/core/src/mill/eval/Evaluator.scala
+++ b/core/src/mill/eval/Evaluator.scala
@@ -2,6 +2,7 @@ package mill.eval
import java.net.URLClassLoader
+import ammonite.main.Router.EntryPoint
import ammonite.ops._
import ammonite.runtime.SpecialClassLoader
import mill.define.{Ctx => _, _}
@@ -26,6 +27,7 @@ case class Labelled[T](target: NamedTask[T],
class Evaluator[T](val workspacePath: Path,
val basePath: Path,
val rootModule: mill.Module,
+ val discover: Discover,
log: Logger,
val classLoaderSig: Seq[(Path, Long)] = Evaluator.classLoaderSig){
@@ -38,16 +40,30 @@ class Evaluator[T](val workspacePath: Path,
val topoSorted = Graph.topoSorted(transitive)
val sortedGroups = Graph.groupAroundImportantTargets(topoSorted){
case t: NamedTask[Any] =>
+
val segments = t.ctx.segments
- val (finalTaskOverrides, enclosing) = t match{
+ val finalTaskOverrides = t match{
case t: Target[_] =>
- rootModule.millInternal.segmentsToTargets.get(segments).fold(0)(_.ctx.overrides) -> t.ctx.enclosing
- case c: mill.define.Command[_] => 0 -> c.ctx.enclosing
- case c: mill.define.Worker[_] => 0 -> c.ctx.enclosing
+ rootModule.millInternal.segmentsToTargets.get(segments).fold(0)(_.ctx.overrides)
+ case c: mill.define.Command[_] =>
+ def findMatching(cls: Class[_]): Option[Seq[(Int, EntryPoint[_])]] = {
+ discover.value.get(cls) match{
+ case Some(v) => Some(v)
+ case None =>
+ cls.getSuperclass match{
+ case null => None
+ case superCls => findMatching(superCls)
+ }
+ }
+ }
+ val public = findMatching(c.cls).get.find(_._2.name == c.ctx.segment.pathSegments.head).get._1
+ public
+ case c: mill.define.Worker[_] => 0
}
+
val additional =
if (finalTaskOverrides == t.ctx.overrides) Nil
- else Seq(Segment.Label("overriden"), Segment.Label(enclosing))
+ else Seq(Segment.Label("overriden"), Segment.Label(t.ctx.enclosing))
Right(Labelled(t, segments ++ additional))
case t if goals.contains(t) => Left(t)
diff --git a/core/src/mill/main/MainRunner.scala b/core/src/mill/main/MainRunner.scala
index d3053d7a..81450ba9 100644
--- a/core/src/mill/main/MainRunner.scala
+++ b/core/src/mill/main/MainRunner.scala
@@ -95,13 +95,15 @@ class MainRunner(config: ammonite.main.Cli.Config,
| // even if it does nothing...
| def $$main() = Iterator[String]()
|
- | val millDiscover: mill.define.Discover = mill.define.Discover[this.type]
+ | implicit def millDiscover: mill.define.Discover = mill.define.Discover[this.type]
| // Need to wrap the returned Module in Some(...) to make sure it
| // doesn't get picked up during reflective child-module discovery
| val millSelf = Some(this)
|}
|
|sealed trait $wrapName extends mill.Module{this: mill.define.BaseModule =>
+ |
+ | implicit def millDiscover: mill.define.Discover
|""".stripMargin
}
diff --git a/core/src/mill/main/ReplApplyHandler.scala b/core/src/mill/main/ReplApplyHandler.scala
index cc4d3c64..9b3a29bb 100644
--- a/core/src/mill/main/ReplApplyHandler.scala
+++ b/core/src/mill/main/ReplApplyHandler.scala
@@ -19,6 +19,7 @@ object ReplApplyHandler{
ammonite.ops.pwd / 'out,
ammonite.ops.pwd,
rootModule,
+ discover,
new mill.util.PrintLogger(
colors != ammonite.util.Colors.BlackWhite,
colors,
@@ -86,8 +87,8 @@ class ReplApplyHandler(pprinter0: pprint.PPrinter,
case None => Nil
case Some(commands) =>
ctx.applyPrefixColor("\nCommands:").toString +: commands.map{c =>
- "\n ." + c.name + "(" +
- c.argSignatures.map(s => s.name + ": " + s.typeString).mkString(", ") +
+ "\n ." + c._2.name + "(" +
+ c._2.argSignatures.map(s => s.name + ": " + s.typeString).mkString(", ") +
")()"
}
}) ++
diff --git a/core/src/mill/main/Resolve.scala b/core/src/mill/main/Resolve.scala
index b01391d0..d8c0ede0 100644
--- a/core/src/mill/main/Resolve.scala
+++ b/core/src/mill/main/Resolve.scala
@@ -28,8 +28,8 @@ object Resolve {
for{
(cls, entryPoints) <- discover.value.filterKeys(_.isAssignableFrom(target.getClass))
ep <- entryPoints
- if ep.name == name
- } yield ep.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match {
+ if ep._2.name == name
+ } yield ep._2.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match {
case Router.Result.Success(v) => Right(v)
case _ => Left(s"Command failed $last")
}
diff --git a/core/src/mill/main/RunScript.scala b/core/src/mill/main/RunScript.scala
index a69f87be..b4de2966 100644
--- a/core/src/mill/main/RunScript.scala
+++ b/core/src/mill/main/RunScript.scala
@@ -43,7 +43,7 @@ object RunScript{
for((mapping, discover) <- evaluateMapping(wd, path, interp))
yield (
new Evaluator(
- wd / 'out, wd, mapping, log,
+ wd / 'out, wd, mapping, discover, log,
mapping.getClass.getClassLoader.asInstanceOf[SpecialClassLoader].classpathSignature
),
discover
@@ -120,7 +120,7 @@ object RunScript{
Util.withContextClassloader(interp.evalClassloader) {
Res.Success(
buildCls.getMethod("millDiscover")
- .invoke(null)
+ .invoke(module)
.asInstanceOf[Discover]
)
}
diff --git a/core/test/src/mill/define/CacherTests.scala b/core/test/src/mill/define/CacherTests.scala
index eb981d46..20e2be2c 100644
--- a/core/test/src/mill/define/CacherTests.scala
+++ b/core/test/src/mill/define/CacherTests.scala
@@ -27,36 +27,36 @@ object CacherTests extends TestSuite{
val tests = Tests{
- def eval[V](mapping: mill.Module, v: Task[V])(implicit tp: TestPath) = {
+ def eval[V](mapping: mill.Module, discover: Discover, v: Task[V])(implicit tp: TestPath) = {
val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value
- val evaluator = new Evaluator(workspace, ammonite.ops.pwd, mapping, DummyLogger)
+ val evaluator = new Evaluator(workspace, ammonite.ops.pwd, mapping, discover, DummyLogger)
evaluator.evaluate(Agg(v)).values(0)
}
'simpleDefIsCached - assert(
Base.value eq Base.value,
- eval(Base, Base.value) == 1
+ eval(Base, Discover[Base.type], Base.value) == 1
)
'resultDefIsCached - assert(
Base.result eq Base.result,
- eval(Base, Base.result) == 1
+ eval(Base, Discover[Base.type], Base.result) == 1
)
'overridingDefIsAlsoCached - assert(
- eval(Middle, Middle.value) == 3,
+ eval(Middle, Discover[Middle.type], Middle.value) == 3,
Middle.value eq Middle.value
)
'overridenDefRemainsAvailable - assert(
- eval(Middle, Middle.overriden) == 1
+ eval(Middle, Discover[Middle.type], Middle.overriden) == 1
)
'multipleOverridesWork- assert(
- eval(Terminal, Terminal.value) == 7,
- eval(Terminal, Terminal.overriden) == 1
+ eval(Terminal, Discover[Terminal.type], Terminal.value) == 7,
+ eval(Terminal, Discover[Terminal.type], Terminal.overriden) == 1
)
// Doesn't fail, presumably compileError doesn't go far enough in the
// compilation pipeline to hit the override checks
diff --git a/core/test/src/mill/eval/EvaluationTests.scala b/core/test/src/mill/eval/EvaluationTests.scala
index 0d14988a..563a2428 100644
--- a/core/test/src/mill/eval/EvaluationTests.scala
+++ b/core/test/src/mill/eval/EvaluationTests.scala
@@ -2,7 +2,7 @@ package mill.eval
import mill.util.TestUtil.{Test, test}
-import mill.define.{Graph, Target, Task}
+import mill.define.{Discover, Graph, Target, Task}
import mill.{Module, T}
import mill.util.{DummyLogger, TestGraphs, TestUtil}
import mill.util.Strict.Agg
@@ -10,11 +10,11 @@ import utest._
import utest.framework.TestPath
object EvaluationTests extends TestSuite{
- class Checker(module: mill.Module)(implicit tp: TestPath) {
+ class Checker(module: mill.Module, discover: Discover)(implicit tp: TestPath) {
val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value
ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd))
// Make sure data is persisted even if we re-create the evaluator each time
- def evaluator = new Evaluator(workspace, ammonite.ops.pwd, module, DummyLogger)
+ def evaluator = new Evaluator(workspace, ammonite.ops.pwd, module, discover, DummyLogger)
def apply(target: Task[_], expValue: Any,
expEvaled: Agg[Task[_]],
@@ -28,7 +28,8 @@ object EvaluationTests extends TestSuite{
val evaled = evaluator.evaluate(Agg(target))
- val (matchingReturnedEvaled, extra) = evaled.evaluated.indexed.partition(expEvaled.contains)
+ val (matchingReturnedEvaled, extra) =
+ evaled.evaluated.indexed.partition(expEvaled.contains)
assert(
evaled.values == Seq(expValue),
@@ -57,7 +58,7 @@ object EvaluationTests extends TestSuite{
'singleton - {
import singleton._
- val check = new Checker(singleton)
+ val check = new Checker(singleton, Discover[singleton.type])
// First time the target is evaluated
check(single, expValue = 0, expEvaled = Agg(single))
@@ -67,7 +68,7 @@ object EvaluationTests extends TestSuite{
}
'pair - {
import pair._
- val check = new Checker(pair)
+ val check = new Checker(pair, Discover[pair.type])
check(down, expValue = 0, expEvaled = Agg(up, down))
down.counter += 1
@@ -78,7 +79,7 @@ object EvaluationTests extends TestSuite{
}
'anonTriple - {
import anonTriple._
- val check = new Checker(anonTriple)
+ val check = new Checker(anonTriple, Discover[anonTriple.type])
val middle = down.inputs(0)
check(down, expValue = 0, expEvaled = Agg(up, middle, down))
@@ -94,7 +95,7 @@ object EvaluationTests extends TestSuite{
}
'diamond - {
import diamond._
- val check = new Checker(diamond)
+ val check = new Checker(diamond, Discover[diamond.type])
check(down, expValue = 0, expEvaled = Agg(up, left, right, down))
down.counter += 1
@@ -112,7 +113,7 @@ object EvaluationTests extends TestSuite{
}
'anonDiamond - {
import anonDiamond._
- val check = new Checker(anonDiamond)
+ val check = new Checker(anonDiamond, Discover[anonDiamond.type])
val left = down.inputs(0).asInstanceOf[TestUtil.Test]
val right = down.inputs(1).asInstanceOf[TestUtil.Test]
check(down, expValue = 0, expEvaled = Agg(up, left, right, down))
@@ -133,7 +134,7 @@ object EvaluationTests extends TestSuite{
'bigSingleTerminal - {
import bigSingleTerminal._
- val check = new Checker(bigSingleTerminal)
+ val check = new Checker(bigSingleTerminal, Discover[bigSingleTerminal.type])
check(j, expValue = 0, expEvaled = Agg(a, b, e, f, i, j), extraEvaled = 22)
@@ -156,7 +157,7 @@ object EvaluationTests extends TestSuite{
// even though one depends on the other
import separateGroups._
- val checker = new Checker(separateGroups)
+ val checker = new Checker(separateGroups, Discover[separateGroups.type])
val evaled1 = checker.evaluator.evaluate(Agg(right, left))
val filtered1 = evaled1.evaluated.filter(_.isInstanceOf[Target[_]])
assert(filtered1 == Agg(change, left, right))
@@ -173,7 +174,7 @@ object EvaluationTests extends TestSuite{
'triangleTask - {
import triangleTask._
- val checker = new Checker(triangleTask)
+ val checker = new Checker(triangleTask, Discover[triangleTask.type])
checker(right, 3, Agg(left, right), extraEvaled = -1)
checker(left, 1, Agg(), extraEvaled = -1)
@@ -181,7 +182,7 @@ object EvaluationTests extends TestSuite{
'multiTerminalGroup - {
import multiTerminalGroup._
- val checker = new Checker(multiTerminalGroup)
+ val checker = new Checker(multiTerminalGroup, Discover[multiTerminalGroup.type])
checker(right, 1, Agg(right), extraEvaled = -1)
checker(left, 1, Agg(left), extraEvaled = -1)
}
@@ -190,16 +191,60 @@ object EvaluationTests extends TestSuite{
import multiTerminalBoundary._
- val checker = new Checker(multiTerminalBoundary)
+ val checker = new Checker(multiTerminalBoundary, Discover[multiTerminalBoundary.type])
checker(task2, 4, Agg(right, left), extraEvaled = -1, secondRunNoOp = false)
checker(task2, 4, Agg(), extraEvaled = -1, secondRunNoOp = false)
}
'overrideSuperTask - {
+ // Make sure you can override targets, call their supers, and have the
+ // overriden target be allocated a spot within the overriden/ folder of
+ // the main publically-available target
import canOverrideSuper._
- val checker = new Checker(canOverrideSuper)
+ val checker = new Checker(canOverrideSuper, Discover[canOverrideSuper.type])
checker(foo, Seq("base", "object"), Agg(foo), extraEvaled = -1)
+
+
+ val public = ammonite.ops.read(checker.workspace / 'foo / "meta.json")
+ val overriden = ammonite.ops.read(
+ checker.workspace / 'foo /
+ 'overriden / "mill.util.TestGraphs.BaseModule#foo" / "meta.json"
+ )
+ assert(
+ public.contains("base"),
+ public.contains("object"),
+ overriden.contains("base"),
+ !overriden.contains("object")
+ )
+ }
+ 'overrideSuperCommand - {
+ // Make sure you can override commands, call their supers, and have the
+ // overriden command be allocated a spot within the overriden/ folder of
+ // the main publically-available command
+ import canOverrideSuper._
+
+ val checker = new Checker(canOverrideSuper, Discover[canOverrideSuper.type])
+ val runCmd = cmd(1)
+ checker(
+ runCmd,
+ Seq("base1", "object1"),
+ Agg(runCmd),
+ extraEvaled = -1,
+ secondRunNoOp = false
+ )
+
+ val public = ammonite.ops.read(checker.workspace / 'cmd / "meta.json")
+ val overriden = ammonite.ops.read(
+ checker.workspace / 'cmd /
+ 'overriden / "mill.util.TestGraphs.BaseModule#cmd" / "meta.json"
+ )
+ assert(
+ public.contains("base1"),
+ public.contains("object1"),
+ overriden.contains("base1"),
+ !overriden.contains("object1")
+ )
}
'tasksAreUncached - {
@@ -235,7 +280,7 @@ object EvaluationTests extends TestSuite{
// During the first evaluation, they get computed normally like any
// cached target
- val check = new Checker(build)
+ val check = new Checker(build, Discover[build.type])
assert(leftCount == 0, rightCount == 0)
check(down, expValue = 10101, expEvaled = Agg(up, right, down), extraEvaled = 8)
assert(leftCount == 1, middleCount == 1, rightCount == 1)
diff --git a/core/test/src/mill/eval/FailureTests.scala b/core/test/src/mill/eval/FailureTests.scala
index 12ed345d..7d0d6421 100644
--- a/core/test/src/mill/eval/FailureTests.scala
+++ b/core/test/src/mill/eval/FailureTests.scala
@@ -1,6 +1,6 @@
package mill.eval
-import mill.define.Target
+import mill.define.{Discover, Target}
import mill.util.DummyLogger
import mill.util.Strict.Agg
import utest._
@@ -11,9 +11,9 @@ object FailureTests extends TestSuite{
def workspace(implicit tp: TestPath) = {
ammonite.ops.pwd / 'target / 'workspace / 'failure / implicitly[TestPath].value
}
- class Checker(module: mill.Module)(implicit tp: TestPath){
+ class Checker(module: mill.Module, discover: Discover)(implicit tp: TestPath){
- val evaluator = new Evaluator(workspace, ammonite.ops.pwd, module, DummyLogger)
+ val evaluator = new Evaluator(workspace, ammonite.ops.pwd, module, discover, DummyLogger)
def apply(target: Target[_], expectedFailCount: Int, expectedRawValues: Seq[Result[_]]) = {
@@ -37,7 +37,7 @@ object FailureTests extends TestSuite{
'evaluateSingle - {
ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd))
- val check = new Checker(singleton)
+ val check = new Checker(singleton, Discover[singleton.type])
check(
target = singleton.single,
expectedFailCount = 0,
@@ -73,7 +73,7 @@ object FailureTests extends TestSuite{
}
'evaluatePair - {
ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd))
- val check = new Checker(pair)
+ val check = new Checker(pair, Discover[pair.type])
check(
pair.down,
expectedFailCount = 0,
diff --git a/core/test/src/mill/eval/JavaCompileJarTests.scala b/core/test/src/mill/eval/JavaCompileJarTests.scala
index 5dd9cae1..961c4b1f 100644
--- a/core/test/src/mill/eval/JavaCompileJarTests.scala
+++ b/core/test/src/mill/eval/JavaCompileJarTests.scala
@@ -2,7 +2,7 @@ package mill.eval
import ammonite.ops.ImplicitWd._
import ammonite.ops._
-import mill.define.{Input, Target, Task}
+import mill.define.{Discover, Input, Target, Task}
import mill.modules.Jvm
import mill.util.Ctx.DestCtx
import mill.{Module, T}
@@ -50,7 +50,7 @@ object JavaCompileJarTests extends TestSuite{
import Build._
def eval[T](t: Task[T]) = {
- val evaluator = new Evaluator(workspacePath, pwd, Build, DummyLogger)
+ val evaluator = new Evaluator(workspacePath, pwd, Build, Discover[Build.type], DummyLogger)
val evaluated = evaluator.evaluate(Agg(t))
if (evaluated.failing.keyCount == 0){
@@ -67,7 +67,7 @@ object JavaCompileJarTests extends TestSuite{
}
def check(targets: Agg[Task[_]], expected: Agg[Task[_]]) = {
- val evaluator = new Evaluator(workspacePath, pwd, Build, DummyLogger)
+ val evaluator = new Evaluator(workspacePath, pwd, Build, Discover[Build.type], DummyLogger)
val evaluated = evaluator.evaluate(targets)
.evaluated
diff --git a/core/test/src/mill/eval/TaskTests.scala b/core/test/src/mill/eval/TaskTests.scala
index 3f265618..538b0c12 100644
--- a/core/test/src/mill/eval/TaskTests.scala
+++ b/core/test/src/mill/eval/TaskTests.scala
@@ -3,6 +3,7 @@ package mill.eval
import utest._
import ammonite.ops._
import mill.T
+import mill.define.Discover
import mill.util.TestEvaluator
object TaskTests extends TestSuite{
val tests = Tests{
@@ -57,6 +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,
+ Discover[build.type],
pwd / 'target / 'workspace / "task-tests" / "inputs",
pwd
)
@@ -74,6 +76,7 @@ object TaskTests extends TestSuite{
// Persistent tasks keep the working dir around between runs
val check = new TestEvaluator(
build,
+ Discover[build.type],
pwd / 'target / 'workspace / "task-tests" / "persistent",
pwd
)
@@ -90,6 +93,7 @@ object TaskTests extends TestSuite{
// Persistent task
def check = new TestEvaluator(
build,
+ Discover[build.type],
pwd / 'target / 'workspace / "task-tests" / "worker",
pwd
)
diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala
index e437017a..10483aae 100644
--- a/core/test/src/mill/util/TestEvaluator.scala
+++ b/core/test/src/mill/util/TestEvaluator.scala
@@ -1,13 +1,14 @@
package mill.util
import ammonite.ops.Path
-import mill.define.{Input, Target, Task}
+import mill.define.{Discover, Input, Target, Task}
import mill.eval.{Evaluator, Result}
import mill.util.Strict.Agg
class TestEvaluator(module: mill.Module,
+ discover: Discover,
workspacePath: Path,
basePath: Path){
- val evaluator = new Evaluator(workspacePath, basePath, module, DummyLogger)
+ val evaluator = new Evaluator(workspacePath, basePath, module, discover, DummyLogger)
//val evaluator = new Evaluator(workspacePath, basePath, module, new PrintLogger(true, ammonite.util.Colors.Default, System.out, System.out, System.err))
def apply[T](t: Task[T]): Either[Result.Failing, (T, Int)] = {
val evaluated = evaluator.evaluate(Agg(t))
diff --git a/core/test/src/mill/util/TestGraphs.scala b/core/test/src/mill/util/TestGraphs.scala
index 54c8d815..aa8865ce 100644
--- a/core/test/src/mill/util/TestGraphs.scala
+++ b/core/test/src/mill/util/TestGraphs.scala
@@ -174,10 +174,12 @@ object TestGraphs{
trait BaseModule extends Module {
def foo = T{ Seq("base") }
+ def cmd(i: Int) = T.command{ Seq("base" + i) }
}
object canOverrideSuper extends TestUtil.BaseModule with BaseModule {
override def foo = T{ super.foo() ++ Seq("object") }
+ override def cmd(i: Int) = T.command{ super.cmd(i)() ++ Seq("object" + i) }
}
trait TraitWithModule extends Module{ outer =>
diff --git a/integration/test/src/mill/integration/IntegrationTestSuite.scala b/integration/test/src/mill/integration/IntegrationTestSuite.scala
index 4649abdb..043e4afa 100644
--- a/integration/test/src/mill/integration/IntegrationTestSuite.scala
+++ b/integration/test/src/mill/integration/IntegrationTestSuite.scala
@@ -11,6 +11,7 @@ abstract class IntegrationTestSuite(repoKey: String, workspaceSlug: String) exte
val workspacePath = pwd / 'target / 'workspace / workspaceSlug
val buildFilePath = pwd / 'integration / 'test / 'resources / workspaceSlug
val stdOutErr = new PrintStream(new ByteArrayOutputStream())
+// val stdOutErr = new PrintStream(System.out)
val stdIn = new ByteArrayInputStream(Array())
val runner = new mill.main.MainRunner(
ammonite.main.Cli.Config(wd = workspacePath), false,
diff --git a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
index 1e41cfdf..d954619f 100644
--- a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
+++ b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
@@ -6,7 +6,8 @@ import javax.script.{ScriptContext, ScriptEngineManager}
import ammonite.ops._
import mill._
-import mill.scalalib.PublishModule
+import mill.define.Discover
+import mill.scalalib.{DepSyntax, PublishModule, TestRunner}
import mill.scalalib.publish.{Developer, License, PomSettings, SCM}
import mill.util.{TestEvaluator, TestUtil}
import utest._
@@ -57,6 +58,7 @@ object HelloJSWorldTests extends TestSuite {
val helloWorldEvaluator = new TestEvaluator(
HelloJSWorld,
+ Discover[HelloJSWorld.type],
workspacePath,
srcPath
)
diff --git a/scalalib/src/mill/scalalib/GenIdea.scala b/scalalib/src/mill/scalalib/GenIdea.scala
index 927c39d7..45475368 100644
--- a/scalalib/src/mill/scalalib/GenIdea.scala
+++ b/scalalib/src/mill/scalalib/GenIdea.scala
@@ -1,7 +1,7 @@
package mill.scalalib
import ammonite.ops._
-import mill.define.{BaseModule, Segment, Segments, Target}
+import mill.define._
import mill.eval.{Evaluator, PathRef}
import mill.scalalib
import mill.util.Ctx.LogCtx
@@ -10,14 +10,16 @@ import mill.util.Strict.Agg
object GenIdea {
- def apply()(implicit ctx: LogCtx, rootModule0: BaseModule.Implicit): Unit = {
+ def apply()(implicit ctx: LogCtx,
+ rootModule0: BaseModule.Implicit,
+ discover: Discover): Unit = {
val rootModule = rootModule0.value
val pp = new scala.xml.PrettyPrinter(999, 4)
rm! pwd/".idea"
rm! pwd/".idea_modules"
- val evaluator = new Evaluator(pwd / 'out, pwd, rootModule , ctx.log)
+ val evaluator = new Evaluator(pwd / 'out, pwd, rootModule, discover, ctx.log)
for((relPath, xml) <- xmlFileLayout(evaluator, rootModule)){
write.over(pwd/relPath, pp.format(xml))
diff --git a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala
index 3bafcfe3..d49e6a1c 100644
--- a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala
+++ b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala
@@ -2,7 +2,7 @@ package mill.scalalib
import ammonite.ops._
import mill._
-
+import mill.define.Discover
import mill.util.{TestEvaluator, TestUtil}
import utest._
@@ -21,6 +21,7 @@ object GenIdeaTests extends TestSuite {
val helloWorldEvaluator = new TestEvaluator(
HelloWorld,
+ Discover[HelloWorld.type],
outPath,
workingSrcPath
)
diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
index 0f2826bb..85e53703 100644
--- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
+++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
@@ -5,7 +5,7 @@ import java.util.jar.JarFile
import ammonite.ops._
import ammonite.ops.ImplicitWd._
import mill._
-import mill.define.Target
+import mill.define.{Discover, Target}
import mill.eval.{Evaluator, Result}
import mill.scalalib.publish._
import mill.util.{TestEvaluator, TestUtil}
@@ -84,31 +84,37 @@ object HelloWorldTests extends TestSuite {
val helloWorldEvaluator = new TestEvaluator(
HelloWorld,
+ Discover[HelloWorld.type],
outPath,
workingSrcPath
)
val helloWorldWithMainEvaluator = new TestEvaluator(
HelloWorldWithMain,
+ Discover[HelloWorldWithMain.type],
outPath,
workingSrcPath
)
val helloWorldWithMainAssemblyEvaluator = new TestEvaluator(
HelloWorldWithMainAssembly,
+ Discover[HelloWorldWithMainAssembly.type],
outPath,
workingSrcPath
)
val helloWorldFatalEvaluator = new TestEvaluator(
HelloWorldFatalWarnings,
+ Discover[HelloWorldFatalWarnings.type],
outPath,
workingSrcPath
)
val helloWorldOverrideEvaluator = new TestEvaluator(
HelloWorldScalaOverride,
+ Discover[HelloWorldScalaOverride.type],
outPath,
workingSrcPath
)
val helloWorldCrossEvaluator = new TestEvaluator(
CrossHelloWorld,
+ Discover[CrossHelloWorld.type],
outPath,
workingSrcPath
)