summaryrefslogtreecommitdiff
path: root/main/src/mill/main/MainRunner.scala
diff options
context:
space:
mode:
authorOlivier Mélois <baccata64@gmail.com>2018-04-18 22:36:00 +0100
committerLi Haoyi <haoyi.sg@gmail.com>2018-04-18 14:36:00 -0700
commit7898368fe809779e73ef1cd909f1b2e5de84e6c1 (patch)
tree1ebe94dd2066fdb7db07ea8d3fd486d9775138ec /main/src/mill/main/MainRunner.scala
parent5314da0e2dea8d61400241d6c9899ea9077fff8d (diff)
downloadmill-7898368fe809779e73ef1cd909f1b2e5de84e6c1.tar.gz
mill-7898368fe809779e73ef1cd909f1b2e5de84e6c1.tar.bz2
mill-7898368fe809779e73ef1cd909f1b2e5de84e6c1.zip
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
Diffstat (limited to 'main/src/mill/main/MainRunner.scala')
-rw-r--r--main/src/mill/main/MainRunner.scala15
1 files changed, 11 insertions, 4 deletions
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...