Skip to content

Commit ea4c3ce

Browse files
committed
Add MappedRoots.requireMappedPaths API
1 parent 1c5d1a8 commit ea4c3ce

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
@@ -86,6 +86,14 @@ class MillBuildBootstrap(
8686
}
8787

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

0 commit comments

Comments
 (0)