Skip to content

Commit d035514

Browse files
committed
Add MappedRoots.requireMappedPaths API
1 parent d0faad3 commit d035514

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

core/api/src/mill/api/MappedRoots.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,17 @@ trait MappedRootsImpl {
7878
}
7979
}
8080

81+
/**
82+
* Use this to assert at runtime, that a root path with the given `key` is defined.
83+
* @throws NoSuchElementException when no path was mapped under the given `key`.
84+
*/
85+
def requireMappedPaths(key: String*): Unit = {
86+
val map = toMap
87+
for {
88+
singleKey <- key
89+
} {
90+
if (!map.contains(singleKey)) throw new NoSuchElementException(s"No root path mapping defined for '${key}'")
91+
}
92+
}
93+
8194
}

runner/daemon/src/mill/daemon/MillBuildBootstrap.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class MillBuildBootstrap(
8787
}
8888

8989
def evaluateRec(depth: Int): RunnerState = {
90+
91+
// We need relocatable PathRef for meta-builds for a stable classpathSig
92+
MappedRoots.requireMappedPaths(
93+
mill.constants.PathVars.WORKSPACE,
94+
mill.constants.PathVars.HOME,
95+
mill.constants.PathVars.MILL_OUT
96+
)
97+
9098
logger.withChromeProfile(s"meta-level $depth") {
9199
// println(s"+evaluateRec($depth) " + recRoot(projectRoot, depth))
92100
val currentRoot = recRoot(projectRoot, depth)

0 commit comments

Comments
 (0)