diff --git a/build.sc b/build.sc index 7f0f6e100bb..f5b61d4c690 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 17a043f6b67..e3d3ec6ea35 100644 --- a/main/client/src/mill/main/client/MillClientMain.java +++ b/main/client/src/mill/main/client/MillClientMain.java @@ -11,20 +11,8 @@ public class MillClientMain { static void initServer(String lockBase, boolean setJnaNoSys) throws IOException,URISyntaxException{ - ArrayList selfJars = new ArrayList(); - 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 l = new java.util.ArrayList(); l.add("java"); Properties props = System.getProperties(); diff --git a/main/src/mill/main/RunScript.scala b/main/src/mill/main/RunScript.scala index 50cbb213dae..aea66988364 100644 --- a/main/src/mill/main/RunScript.scala +++ b/main/src/mill/main/RunScript.scala @@ -39,6 +39,24 @@ object RunScript{ instantiateInterpreter match{ case Left((res, watched)) => (res, watched) case Right(interp) => + val mainThread = Thread.currentThread() + val allClassloaders = { + val all = mutable.Buffer.empty[ClassLoader] + var current = mainThread.getContextClassLoader + while(current != null){ + all.append(current) + current = current.getParent + } + all + } + + log.outputStream.println(pprint.apply(allClassloaders, height = 9999)) + log.outputStream.println(pprint.apply( + allClassloaders + .collect{case cl: java.net.URLClassLoader => cl -> cl.getURLs.filter(_.getProtocol == "file")}, + height = 9999 + )) +// log.outputStream.println(pprint.apply(SpecialClassLoader.initialClasspathSignature(mainThread.getContextClassLoader), height = 9999)) interp.watch(path) val eval = for(rootModule <- evaluateRootModule(wd, path, interp, log)) @@ -76,6 +94,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 9ee78d63c0b..ae763e4d767 100644 --- a/scratch/build.sc +++ b/scratch/build.sc @@ -1,3 +1,3 @@ def thingy = T { - 1234567 + 12345678 } \ No newline at end of file