diff options
Diffstat (limited to 'main/src/main')
-rw-r--r-- | main/src/main/MainRunner.scala | 5 | ||||
-rw-r--r-- | main/src/main/MillIvyHook.scala | 15 |
2 files changed, 19 insertions, 1 deletions
diff --git a/main/src/main/MainRunner.scala b/main/src/main/MainRunner.scala index 6705a4b3..354b6173 100644 --- a/main/src/main/MainRunner.scala +++ b/main/src/main/MainRunner.scala @@ -9,6 +9,7 @@ import mill.eval.{Evaluator, PathRef} import mill.util.PrintLogger import scala.annotation.tailrec +import ammonite.runtime.ImportHook /** @@ -120,11 +121,13 @@ class MainRunner(val config: ammonite.main.Cli.Config, } override def initMain(isRepl: Boolean) = { + val hooks = ImportHook.defaults + (Seq("ivy") -> MillIvyHook) super.initMain(isRepl).copy( scriptCodeWrapper = CustomCodeWrapper, // Ammonite does not properly forward the wd from CliConfig to Main, so // force forward it outselves - wd = config.wd + wd = config.wd, + importHooks = hooks ) } diff --git a/main/src/main/MillIvyHook.scala b/main/src/main/MillIvyHook.scala new file mode 100644 index 00000000..2b4eb6a7 --- /dev/null +++ b/main/src/main/MillIvyHook.scala @@ -0,0 +1,15 @@ +package mill.main +import ammonite.runtime.ImportHook.BaseIvy +import ammonite.runtime.ImportHook +import java.io.File + +/** + * Overrides the ivy hook to interpret $MILL_VERSION as the version of mill + * the user runs. + * + * Can be used to ensure loaded contrib modules keep up to date. + */ +object MillIvyHook extends BaseIvy(plugin = false){ + override def resolve(interp: ImportHook.InterpreterInterface, signatures: Seq[String]): Either[String,Set[File]] = + super.resolve(interp, signatures.map(_.replace("$MILL_VERSION", mill.BuildInfo.millVersion))) +} |