Skip to content

Commit

Permalink
Preserve caches between interactive and client/server mode (#342)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lihaoyi committed May 20, 2018
1 parent 40838f9 commit ed48bcd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
6 changes: 5 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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""")
Expand Down Expand Up @@ -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
Expand Down
16 changes: 2 additions & 14 deletions main/client/src/mill/main/client/MillClientMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@

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();
Expand Down
1 change: 1 addition & 0 deletions main/src/mill/main/RunScript.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scratch/build.sc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def thingy = T {
1234567
12345678
}

0 comments on commit ed48bcd

Please sign in to comment.