diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/mill/define/Ctx.scala | 10 | ||||
-rw-r--r-- | core/src/mill/define/Module.scala | 16 | ||||
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 10 | ||||
-rw-r--r-- | core/test/src/mill/eval/ModuleTests.scala | 3 | ||||
-rw-r--r-- | core/test/src/mill/util/TestEvaluator.scala | 4 |
5 files changed, 29 insertions, 14 deletions
diff --git a/core/src/mill/define/Ctx.scala b/core/src/mill/define/Ctx.scala index ddbdca96..405f45ed 100644 --- a/core/src/mill/define/Ctx.scala +++ b/core/src/mill/define/Ctx.scala @@ -47,23 +47,27 @@ case class Ctx(enclosing: String, segment: Segment, millSourcePath: Path, segments: Segments, - overrides: Int){ + overrides: Int, + external: Boolean){ } object Ctx{ + case class External(value: Boolean) implicit def make(implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, millName0: sourcecode.Name, millModuleBasePath0: BasePath, segments0: Segments, - overrides0: Overrides): Ctx = { + overrides0: Overrides, + external0: External): Ctx = { Ctx( millModuleEnclosing0.value, millModuleLine0.value, Segment.Label(millName0.value), millModuleBasePath0.value, segments0, - overrides0.value + overrides0.value, + external0.value ) } }
\ No newline at end of file diff --git a/core/src/mill/define/Module.scala b/core/src/mill/define/Module.scala index 039011d8..e765a6b4 100644 --- a/core/src/mill/define/Module.scala +++ b/core/src/mill/define/Module.scala @@ -25,6 +25,7 @@ class Module(implicit outerCtx0: mill.define.Ctx) extends mill.moduledefs.Cacher lazy val millModuleDirectChildren = millInternal.reflectNestedObjects[Module] def millOuterCtx = outerCtx0 def millSourcePath: Path = millOuterCtx.millSourcePath / millOuterCtx.segment.pathSegments + implicit def millModuleExternal: Ctx.External = Ctx.External(millOuterCtx.external) implicit def millModuleBasePath: BasePath = BasePath(millSourcePath) implicit def millModuleSegments: Segments = { millOuterCtx.segments ++ Seq(millOuterCtx.segment) @@ -92,12 +93,20 @@ trait TaskModule extends Module { object BaseModule{ case class Implicit(value: BaseModule) } -class BaseModule(millSourcePath0: Path) +class BaseModule(millSourcePath0: Path, external0: Boolean = false) (implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, millName0: sourcecode.Name) extends Module()( - mill.define.Ctx.make(implicitly, implicitly, implicitly, BasePath(millSourcePath0), Segments(), Overrides(0)) + mill.define.Ctx.make( + implicitly, + implicitly, + implicitly, + BasePath(millSourcePath0), + Segments(), + Overrides(0), + Ctx.External(external0) + ) ){ // A BaseModule should provide an empty Segments list to it's children, since // it is the root of the module tree, and thus must not include it's own @@ -110,7 +119,8 @@ class BaseModule(millSourcePath0: Path) class ExternalModule(implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, - millName0: sourcecode.Name) extends BaseModule(ammonite.ops.pwd){ + millName0: sourcecode.Name) + extends BaseModule(ammonite.ops.pwd, external0 = true){ assert( !" #".exists(millModuleEnclosing0.value.contains(_)), "External modules must be at a top-level static path, not " + millModuleEnclosing0.value diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index 21e3d3a9..d8d690ac 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -126,11 +126,11 @@ class Evaluator[T](val outPath: Path, ) case Right(labelledNamedTask) => - val paths = if (labelledNamedTask.task.asTarget.exists(rootModule.millInternal.targets.contains)){ - Evaluator.resolveDestPaths(outPath, labelledNamedTask.segments) - }else{ - Evaluator.resolveDestPaths(externalOutPath, labelledNamedTask.segments) - } + val paths = Evaluator.resolveDestPaths( + if (!labelledNamedTask.task.ctx.external) outPath else externalOutPath, + labelledNamedTask.segments + ) + val groupBasePath = millSourcePath / Evaluator.makeSegmentStrings(labelledNamedTask.segments) mkdir(paths.out) val cached = for{ diff --git a/core/test/src/mill/eval/ModuleTests.scala b/core/test/src/mill/eval/ModuleTests.scala index 56c1a47b..db70fee3 100644 --- a/core/test/src/mill/eval/ModuleTests.scala +++ b/core/test/src/mill/eval/ModuleTests.scala @@ -18,10 +18,11 @@ object ModuleTests extends TestSuite{ def z = T{ ExternalModule.x() + ExternalModule.inner.y() } } val tests = Tests { + rm(TestEvaluator.externalOutPath) 'externalModuleTargetsAreNamespacedByModulePackagePath - { val check = new TestEvaluator( Build, - pwd / 'target / 'workspace / "module-tests" / "externalModule", + pwd / 'target / 'external, pwd ) diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala index 26577f3e..416ed71c 100644 --- a/core/test/src/mill/util/TestEvaluator.scala +++ b/core/test/src/mill/util/TestEvaluator.scala @@ -16,8 +16,8 @@ class TestEvaluator[T <: TestUtil.TestBuild](module: T, workspacePath: Path, millSourcePath: Path) (implicit discover: Discover[T]){ - val logger = DummyLogger -// val logger = new PrintLogger(true, ammonite.util.Colors.Default, System.out, System.out, System.err) +// 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) def apply[T](t: Task[T]): Either[Result.Failing, (T, Int)] = { |