From 7898368fe809779e73ef1cd909f1b2e5de84e6c1 Mon Sep 17 00:00:00 2001 From: Olivier Mélois Date: Wed, 18 Apr 2018 22:36:00 +0100 Subject: Make builds able to depend on external projects (#291) * Make builds able to depend on external projects Builds are now able to load external projects and depend on them as if they were local submodules. `import $file.external.path.build` * Disambiguate "dest" for foreign modules. * Calling modules loaded from external directories "Foreign" to avoid conflicting with the already existing concept of "ExternalModule". * Amended the way `dest` is computed for foreign modules * Added tests to check that the source paths and dest are as expected * Added a test to show that local modules do not conflict with foreign modules when they are named the same * WIP windows build fail * Added bootstrapping step in CYGWIN CI job * * Revert externalOutPath deletion * Add documentation for foreign-modules * reverting appveyor changes * Disabling Foreign modules tests against Java9 See https://github.com/lihaoyi/mill/issues/302 --- main/src/mill/main/MainRunner.scala | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'main/src') diff --git a/main/src/mill/main/MainRunner.scala b/main/src/mill/main/MainRunner.scala index fed664fd..a289db5f 100644 --- a/main/src/mill/main/MainRunner.scala +++ b/main/src/mill/main/MainRunner.scala @@ -1,9 +1,10 @@ package mill.main -import java.io.{InputStream, OutputStream, PrintStream} +import java.io.{InputStream, PrintStream} import ammonite.Main import ammonite.interp.{Interpreter, Preprocessor} import ammonite.ops.Path +import ammonite.util.Util.CodeSource import ammonite.util._ import mill.eval.{Evaluator, PathRef} import mill.util.PrintLogger @@ -120,20 +121,26 @@ class MainRunner(val config: ammonite.main.Cli.Config, object CustomCodeWrapper extends Preprocessor.CodeWrapper { def apply(code: String, - pkgName: Seq[ammonite.util.Name], + source: CodeSource, imports: ammonite.util.Imports, printCode: String, indexedWrapperName: ammonite.util.Name, extraCode: String): (String, String, Int) = { + import source.pkgName val wrapName = indexedWrapperName.backticked - val literalPath = pprint.Util.literalize(config.wd.toString) + val path = source + .path + .map(path => path.toNIO.getParent) + .getOrElse(config.wd.toNIO) + val literalPath = pprint.Util.literalize(path.toString) + val external = !(path.compareTo(config.wd.toNIO) == 0) val top = s""" |package ${pkgName.head.encoded} |package ${Util.encodeScalaSourcePath(pkgName.tail)} |$imports |import mill._ |object $wrapName - |extends mill.define.BaseModule(ammonite.ops.Path($literalPath)) + |extends mill.define.BaseModule(ammonite.ops.Path($literalPath), foreign0 = $external) |with $wrapName{ | // Stub to make sure Ammonite has something to call after it evaluates a script, | // even if it does nothing... -- cgit v1.2.3