diff options
-rw-r--r-- | core/src/mill/define/Module.scala | 2 | ||||
-rw-r--r-- | core/src/mill/main/MainRunner.scala | 5 | ||||
-rw-r--r-- | core/test/src/mill/define/BasePathTests.scala | 19 |
3 files changed, 23 insertions, 3 deletions
diff --git a/core/src/mill/define/Module.scala b/core/src/mill/define/Module.scala index dd451c9c..09e8e974 100644 --- a/core/src/mill/define/Module.scala +++ b/core/src/mill/define/Module.scala @@ -104,7 +104,7 @@ class BaseModule(basePath0: Path) // it is the root of the module tree, and thus must not include it's own // sourcecode.Name as part of the list, override implicit def millModuleSegments: Segments = Segments() - override implicit def millModuleBasePath: BasePath = BasePath(millOuterCtx.basePath) override def basePath = millOuterCtx.basePath + override implicit def millModuleBasePath: BasePath = BasePath(basePath) implicit def millImplicitBaseModule: BaseModule.Implicit = BaseModule.Implicit(this) }
\ No newline at end of file diff --git a/core/src/mill/main/MainRunner.scala b/core/src/mill/main/MainRunner.scala index e098144f..06e1795f 100644 --- a/core/src/mill/main/MainRunner.scala +++ b/core/src/mill/main/MainRunner.scala @@ -84,13 +84,16 @@ class MainRunner(config: ammonite.main.Cli.Config, object CustomCodeWrapper extends Preprocessor.CodeWrapper { def top(pkgName: Seq[Name], imports: Imports, indexedWrapperName: Name) = { val wrapName = indexedWrapperName.backticked + val literalPath = pprint.Util.literalize(config.wd.toString) s""" |package ${pkgName.head.encoded} |package ${Util.encodeScalaSourcePath(pkgName.tail)} |$imports |import mill._ | - |object $wrapName extends mill.define.BaseModule(ammonite.ops.Path(${pprint.Util.literalize(config.wd.toString)})) with $wrapName{ + |object $wrapName + |extends mill.define.BaseModule(ammonite.ops.Path($literalPath)) + |with $wrapName{ | // Stub to make sure Ammonite has something to call after it evaluates a script, | // even if it does nothing... | def $$main() = Iterator[String]() diff --git a/core/test/src/mill/define/BasePathTests.scala b/core/test/src/mill/define/BasePathTests.scala index a0be4762..62f84787 100644 --- a/core/test/src/mill/define/BasePathTests.scala +++ b/core/test/src/mill/define/BasePathTests.scala @@ -1,8 +1,9 @@ package mill.define -import mill.util.TestGraphs +import mill.util.{TestGraphs, TestUtil} import utest._ import ammonite.ops._ +import mill.{Module, T} object BasePathTests extends TestSuite{ val testGraphs = new TestGraphs val tests = Tests{ @@ -44,6 +45,22 @@ object BasePathTests extends TestSuite{ "cross", "210", "cross2", "js" ) } + 'overriden - { + object overridenBasePath extends TestUtil.BaseModule { + override def basePath = pwd / 'overridenBasePathRootValue + object nested extends Module{ + override def basePath = super.basePath / 'overridenBasePathNested + object nested extends Module{ + override def basePath = super.basePath / 'overridenBasePathDoubleNested + } + } + } + assert( + overridenBasePath.basePath == pwd / 'overridenBasePathRootValue, + overridenBasePath.nested.basePath == pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested, + overridenBasePath.nested.nested.basePath == pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested / 'nested / 'overridenBasePathDoubleNested + ) + } } } |