Skip to content

Commit

Permalink
Set context classloader during Mill evaluation (#3940)
Browse files Browse the repository at this point in the history
Seems to be necessary for some of the libraries people `import $ivy`,
such as Guardrail
  • Loading branch information
lihaoyi authored Nov 11, 2024
1 parent a7d4813 commit 67db6b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion runner/src/mill/runner/MillBuildBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,12 @@ object MillBuildBootstrap {
targetsAndParams: Seq[String]
): (Either[String, Seq[Any]], Seq[Watchable], Seq[Watchable]) = {
rootModule.evalWatchedValues.clear()
val previousClassloader = Thread.currentThread().getContextClassLoader
val evalTaskResult =
RunScript.evaluateTasksNamed(evaluator, targetsAndParams, SelectMode.Separated)
try {
Thread.currentThread().setContextClassLoader(rootModule.getClass.getClassLoader)
RunScript.evaluateTasksNamed(evaluator, targetsAndParams, SelectMode.Separated)
} finally Thread.currentThread().setContextClassLoader(previousClassloader)
val moduleWatched = rootModule.watchedValues.toVector
val addedEvalWatched = rootModule.evalWatchedValues.toVector

Expand Down

0 comments on commit 67db6b5

Please sign in to comment.