What is the preferred way in mill to point to the directory where build.sc
file is located?
In the mill documentation os.pwd
is used e.g. here, but if it is possible to start/run mill from elsewhere, then os.pwd
points to incorrect location.
import mill._, mill.modules.Jvm
def sourceRoot = T.sources { os.pwd / "src" }
def resourceRoot = T.sources { os.pwd / "resources" }
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:
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 variablebuild
. The project directory is therefore accessible viabuild.millSourcePath
.Example: