The root location of each defined module is defined in def millSourcePath: os.Path
, and it's the preferred way to access the module path.
Example:
import mill._, mill.scalalib._
object mymodule extends JavaModule {
def sources = T.sources(millSourcePath / "src")
}
$ mill show __.sources
No mill version specified.
You should provide a version via '.mill-version' file or --mill-version option.
Using mill version 0.9.9
Compiling /tmp/stackoverflow/build.sc
[1/1] show
[1/1] show > [1/1] mymodule.sources
[
"ref:c984eca8:/tmp/stackoverflow/mymodule/src"
]
If you need to access the path of project itself, notice, that it's a mill.define.Module
itself and you can access it via the variable build
. The project directory is therefore accessible via build.millSourcePath
.
Example:
import mill._, mill.scalalib._
val baseDir = build.millSourcePath
object mymodule extends JavaModule {
def sources = T.sources {
super.sources() ++ Seq(PathRef(baseDir / "src"))
}
}
$ mill show __.sources
No mill version specified.
You should provide a version via '.mill-version' file or --mill-version option.
Using mill version 0.9.9
Compiling /tmp/stackoverflow/build.sc
[1/1] show
[1/1] show > [2/2] mymodule.sources
[
"ref:c984eca8:/tmp/stackoverflow/mymodule/src",
"ref:c984eca8:/tmp/stackoverflow/src"
]