diff options
-rwxr-xr-x | build.sc | 3 | ||||
-rw-r--r-- | clientserver/src/mill/clientserver/Client.java | 19 | ||||
-rw-r--r-- | core/src/mill/util/ClassLoader.scala | 11 | ||||
-rw-r--r-- | scalalib/src/mill/scalalib/ScalaModule.scala | 2 | ||||
-rw-r--r-- | scalalib/src/mill/scalalib/ScalaWorkerApi.scala | 4 |
5 files changed, 28 insertions, 11 deletions
@@ -69,6 +69,7 @@ trait MillModule extends MillPublishModule{ outer => object clientserver extends MillModule{ def ivyDeps = Agg( + ivy"com.lihaoyi:::ammonite:1.0.5-4-c0cdbaf", ivy"org.scala-sbt.ipcsocket:ipcsocket:1.0.0" ) val test = new Tests(implicitly) @@ -83,7 +84,7 @@ object core extends MillModule { def ivyDeps = Agg( ivy"com.lihaoyi::sourcecode:0.1.4", - ivy"com.lihaoyi:::ammonite:1.0.5-1-819bc80", + ivy"com.lihaoyi:::ammonite:1.0.5-4-c0cdbaf", ivy"jline:jline:2.14.5" ) diff --git a/clientserver/src/mill/clientserver/Client.java b/clientserver/src/mill/clientserver/Client.java index 1870c8a4..ed2fe6ad 100644 --- a/clientserver/src/mill/clientserver/Client.java +++ b/clientserver/src/mill/clientserver/Client.java @@ -1,29 +1,38 @@ package mill.clientserver; +import io.github.retronym.java9rtexport.Export; import org.scalasbt.ipcsocket.UnixDomainSocket; import java.io.*; import java.net.URL; import java.nio.channels.FileChannel; +import java.nio.file.Files; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.Properties; public class Client { static void initServer(String lockBase) throws IOException{ - StringBuilder selfJars = new java.lang.StringBuilder(); + ArrayList<String> selfJars = new ArrayList<String>(); ClassLoader current = Client.class.getClassLoader(); while(current != null){ if (current instanceof java.net.URLClassLoader) { URL[] urls = ((java.net.URLClassLoader) current).getURLs(); for (URL url: urls) { - if (selfJars.length() != 0) selfJars.append(':'); - selfJars.append(url); + selfJars.add(url.toString()); } } current = current.getParent(); } - + if (!System.getProperty("java.specification.version").startsWith("1.")) { + selfJars.addAll(Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator))); + File rtFile = new File(lockBase + "/rt-" + System.getProperty("java.version") + ".jar"); + if (!rtFile.exists()) { + Files.copy(Export.export().toPath(), rtFile.toPath()); + } + selfJars.add(rtFile.getCanonicalPath()); + } ArrayList<String> l = new java.util.ArrayList<String>(); l.add("java"); Properties props = System.getProperties(); @@ -33,7 +42,7 @@ public class Client { if (k.startsWith("MILL_")) l.add("-D" + k + "=" + props.getProperty(k)); } l.add("-cp"); - l.add(selfJars.toString()); + l.add(String.join(File.pathSeparator, selfJars)); l.add("mill.ServerMain"); l.add(lockBase); new java.lang.ProcessBuilder() diff --git a/core/src/mill/util/ClassLoader.scala b/core/src/mill/util/ClassLoader.scala index 7f4a9836..a1b42158 100644 --- a/core/src/mill/util/ClassLoader.scala +++ b/core/src/mill/util/ClassLoader.scala @@ -6,7 +6,14 @@ import io.github.retronym.java9rtexport.Export object ClassLoader { def create(urls: Seq[URL], parent: java.lang.ClassLoader): URLClassLoader = { - val rtOpt = if (ammonite.util.Util.java9OrAbove) Some(Export.export().toURI.toURL) else None - new URLClassLoader((urls ++ rtOpt).toArray, parent) + val cl = new URLClassLoader(urls.toArray, parent) + if (!ammonite.util.Util.java9OrAbove) return cl + try { + cl.loadClass("javax.script.ScriptEngineManager") + cl + } catch { + case _: ClassNotFoundException => + new URLClassLoader((urls ++ Some(Export.export().toURI.toURL)).toArray, parent) + } } } diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index 119d4d47..c06fb8f3 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -316,7 +316,7 @@ trait ScalaModule extends mill.Module with TaskModule { outer => } def ammoniteReplClasspath = T{ - resolveDeps(T.task{Agg(ivy"com.lihaoyi:::ammonite:1.0.3")})() + resolveDeps(T.task{Agg(ivy"com.lihaoyi:::ammonite:1.0.5-4-c0cdbaf")})() } def repl() = T.command{ if (T.ctx().log.inStream == DummyInputStream){ diff --git a/scalalib/src/mill/scalalib/ScalaWorkerApi.scala b/scalalib/src/mill/scalalib/ScalaWorkerApi.scala index 2d04ac4e..91222524 100644 --- a/scalalib/src/mill/scalalib/ScalaWorkerApi.scala +++ b/scalalib/src/mill/scalalib/ScalaWorkerApi.scala @@ -31,8 +31,8 @@ trait ScalaWorkerModule extends mill.Module{ } } def worker: Worker[ScalaWorkerApi] = T.worker{ - val cl = new java.net.URLClassLoader( - classpath().map(_.toNIO.toUri.toURL).toArray, + val cl = mill.util.ClassLoader.create( + classpath().map(_.toNIO.toUri.toURL).toVector, getClass.getClassLoader ) val cls = cl.loadClass("mill.scalaworker.ScalaWorker") |