summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-05-19 23:30:22 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2018-05-19 23:33:52 -0700
commited48bcdd96c3e465d76bac93591b53a54a3d9eb3 (patch)
treebcf2e54d999c6b4d25c1ccc4f937cdead5b50cbe
parent40838f958810a4c8158239eef8e96394fea23c89 (diff)
downloadmill-ed48bcdd96c3e465d76bac93591b53a54a3d9eb3.tar.gz
mill-ed48bcdd96c3e465d76bac93591b53a54a3d9eb3.tar.bz2
mill-ed48bcdd96c3e465d76bac93591b53a54a3d9eb3.zip
Preserve caches between interactive and client/server mode (#342)
We were incorrectly duplicating the JDK classpath as part of the application classpath when we spawned the Mill server from the Mill client. This makes the transmission of application classpath to the Mill server explicit via an environment variable, so we don't end up including random things from the client classloader hierarchy that we didn't expect
-rwxr-xr-xbuild.sc6
-rw-r--r--main/client/src/mill/main/client/MillClientMain.java16
-rw-r--r--main/src/mill/main/RunScript.scala1
-rw-r--r--scratch/build.sc2
4 files changed, 9 insertions, 16 deletions
diff --git a/build.sc b/build.sc
index 7f0f6e10..f5b61d4c 100755
--- a/build.sc
+++ b/build.sc
@@ -316,7 +316,10 @@ object dev extends MillModule{
val classpath = runClasspath().map(_.path.toString)
val args = forkArgs().distinct
val (shellArgs, cmdArgs) =
- if (!scala.util.Properties.isWin) (args, args)
+ if (!scala.util.Properties.isWin) (
+ Seq("-DMILL_CLASSPATH=" + classpath.mkString(":")) ++ args,
+ Seq("-DMILL_CLASSPATH=" + classpath.mkString(";")) ++ args
+ )
else (
Seq("""-XX:VMOptionsFile="$( dirname "$0" )"/mill.vmoptions"""),
Seq("""-XX:VMOptionsFile=%~dp0\mill.vmoptions""")
@@ -345,6 +348,7 @@ def release = T{
val dest = T.ctx().dest
val filename = if (scala.util.Properties.isWin) "mill.bat" else "mill"
val args = Seq(
+ "-DMILL_CLASSPATH=$0",
"-DMILL_VERSION=" + publishVersion()._2,
// Workaround for Zinc/JNA bug
// https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130
diff --git a/main/client/src/mill/main/client/MillClientMain.java b/main/client/src/mill/main/client/MillClientMain.java
index 17a043f6..e3d3ec6e 100644
--- a/main/client/src/mill/main/client/MillClientMain.java
+++ b/main/client/src/mill/main/client/MillClientMain.java
@@ -11,20 +11,8 @@ import java.util.*;
public class MillClientMain {
static void initServer(String lockBase, boolean setJnaNoSys) throws IOException,URISyntaxException{
- ArrayList<String> selfJars = new ArrayList<String>();
- ClassLoader current = MillClientMain.class.getClassLoader();
- while(current != null){
- if (current instanceof java.net.URLClassLoader) {
- URL[] urls = ((java.net.URLClassLoader) current).getURLs();
- for (URL url: urls) {
- selfJars.add(new File(url.toURI()).getCanonicalPath());
- }
- }
- current = current.getParent();
- }
- if (Util.isJava9OrAbove) {
- selfJars.addAll(Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator)));
- }
+ String[] selfJars = System.getProperty("MILL_CLASSPATH").split(File.pathSeparator);
+
ArrayList<String> l = new java.util.ArrayList<String>();
l.add("java");
Properties props = System.getProperties();
diff --git a/main/src/mill/main/RunScript.scala b/main/src/mill/main/RunScript.scala
index 50cbb213..5f10db44 100644
--- a/main/src/mill/main/RunScript.scala
+++ b/main/src/mill/main/RunScript.scala
@@ -76,6 +76,7 @@ object RunScript{
log: Logger
): Res[mill.define.BaseModule] = {
+ log.info("RunScript.evaluateRootModule")
val (pkg, wrapper) = Util.pathToPackageWrapper(Seq(), path relativeTo wd)
for {
diff --git a/scratch/build.sc b/scratch/build.sc
index 9ee78d63..ae763e4d 100644
--- a/scratch/build.sc
+++ b/scratch/build.sc
@@ -1,3 +1,3 @@
def thingy = T {
- 1234567
+ 12345678
} \ No newline at end of file