diff options
author | Olivier Mélois <baccata64@gmail.com> | 2019-07-08 10:33:31 +0200 |
---|---|---|
committer | Tobias Roeser <le.petit.fou@web.de> | 2019-07-08 10:33:31 +0200 |
commit | fe8667d58aef03e8b97c1361495ab5d851deee60 (patch) | |
tree | a652df66b0d873f0635b2f6a55122195e9412a3a /main/src | |
parent | 83aa7de17bf175ce64869f70c54de3882e047a1f (diff) | |
download | mill-fe8667d58aef03e8b97c1361495ab5d851deee60.tar.gz mill-fe8667d58aef03e8b97c1361495ab5d851deee60.tar.bz2 mill-fe8667d58aef03e8b97c1361495ab5d851deee60.zip |
Interpolates $MILL_VERSION in ivy imports (#649)
* Interpolates $MILL_VERSION in ivy imports
This overrides the default $ivy magic import by replacing the
`$MILL_VERSION` string with mill's version, in order to facilitate
the loading/update of contrib modules.
Ammonite had to be bumped to 1.6.9
* Removed bloop import
* AmmoniteExit import fix
* Removed repl dep check
* Removed problematic check
* Made ammonite version override-able
Diffstat (limited to 'main/src')
-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))) +} |