diff --git a/runner/src/mill/runner/MillBuildBootstrap.scala b/runner/src/mill/runner/MillBuildBootstrap.scala index 71dcc8dab4e..f1eff7214e2 100644 --- a/runner/src/mill/runner/MillBuildBootstrap.scala +++ b/runner/src/mill/runner/MillBuildBootstrap.scala @@ -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