diff options
author | Olivier Melois <olivierm@cakesolutions.net> | 2018-03-29 21:03:27 +0100 |
---|---|---|
committer | Olivier Melois <olivierm@cakesolutions.net> | 2018-03-29 21:12:55 +0100 |
commit | a96754b75c1fbf1959aeac59040588211f5327c2 (patch) | |
tree | 75e2d6c69c2e28d4500505da002ea387f2771027 /core | |
parent | 41ca6c22894e863f5042cd8f49f5c3c6d52acc23 (diff) | |
download | mill-a96754b75c1fbf1959aeac59040588211f5327c2.tar.gz mill-a96754b75c1fbf1959aeac59040588211f5327c2.tar.bz2 mill-a96754b75c1fbf1959aeac59040588211f5327c2.zip |
Adds envVars propagation client -> server
Since Mill now executes in a long-lived JVM, the builds do not have a
chance to use environment variables as inputs. This propagates the
environment variables from the client all the way down to the context
available to the tasks as a `Map[String, String]` so that they can be
used as inputs should the user choose to do so.
https://github.com/lihaoyi/mill/issues/257
Diffstat (limited to 'core')
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 10 | ||||
-rw-r--r-- | core/src/mill/util/Ctx.scala | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index 33141c0a..7b3634ad 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -2,6 +2,8 @@ package mill.eval import java.net.URLClassLoader +import scala.collection.JavaConverters._ + import mill.util.Router.EntryPoint import ammonite.ops._ import ammonite.runtime.SpecialClassLoader @@ -32,7 +34,8 @@ case class Evaluator[T](home: Path, rootModule: mill.define.BaseModule, log: Logger, classLoaderSig: Seq[(Either[String, Path], Long)] = Evaluator.classLoaderSig, - workerCache: mutable.Map[Segments, (Int, Any)] = mutable.Map.empty){ + workerCache: mutable.Map[Segments, (Int, Any)] = mutable.Map.empty, + env : Map[String, String] = Evaluator.defaultEnv){ val classLoaderSignHash = classLoaderSig.hashCode() def evaluate(goals: Agg[Task[_]]): Evaluator.Results = { mkdir(outPath) @@ -271,7 +274,8 @@ case class Evaluator[T](home: Path, } }, multiLogger, - home + home, + env ) val out = System.out @@ -335,6 +339,8 @@ object Evaluator{ // in directly) we are forced to pass it in via a ThreadLocal val currentEvaluator = new ThreadLocal[mill.eval.Evaluator[_]] + val defaultEnv: Map[String, String] = System.getenv().asScala.toMap + case class Paths(out: Path, dest: Path, meta: Path, diff --git a/core/src/mill/util/Ctx.scala b/core/src/mill/util/Ctx.scala index 99818194..88a8baec 100644 --- a/core/src/mill/util/Ctx.scala +++ b/core/src/mill/util/Ctx.scala @@ -36,7 +36,8 @@ object Ctx{ class Ctx(val args: IndexedSeq[_], dest0: () => Path, val log: Logger, - val home: Path) + val home: Path, + val env : Map[String, String]) extends Ctx.Dest with Ctx.Log with Ctx.Args |