summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clientserver/src/mill/clientserver/Client.java30
-rw-r--r--clientserver/src/mill/clientserver/ClientServer.java3
-rw-r--r--core/src/mill/util/ClassLoader.scala7
-rw-r--r--main/src/mill/Main.scala9
-rw-r--r--scalalib/src/mill/scalalib/ScalaModule.scala2
5 files changed, 33 insertions, 18 deletions
diff --git a/clientserver/src/mill/clientserver/Client.java b/clientserver/src/mill/clientserver/Client.java
index e2a92f7f..c4cbc265 100644
--- a/clientserver/src/mill/clientserver/Client.java
+++ b/clientserver/src/mill/clientserver/Client.java
@@ -25,7 +25,7 @@ public class Client {
}
current = current.getParent();
}
- if (!System.getProperty("java.specification.version").startsWith("1.")) {
+ if (ClientServer.isJava9OrAbove) {
selfJars.addAll(Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator)));
}
ArrayList<String> l = new java.util.ArrayList<String>();
@@ -166,14 +166,15 @@ class ClientOutputPumper implements Runnable{
this.dest2 = dest2;
}
- boolean running = true;
public void run() {
byte[] buffer = new byte[1024];
int state = 0;
- try {
- while(running){
-
+ boolean running = true;
+ boolean first = true;
+ while (running) {
+ try {
int n = src.read(buffer);
+ first = false;
if (n == -1) running = false;
else {
int i = 0;
@@ -197,12 +198,21 @@ class ClientOutputPumper implements Runnable{
dest1.flush();
dest2.flush();
}
+ } catch (IOException e) {
+ // Win32NamedPipeSocket input stream somehow doesn't return -1,
+ // instead it throws an IOException whose message contains "ReadFile()".
+ // However, if it throws an IOException before ever reading some bytes,
+ // it could not connect to the server, so exit.
+ if (ClientServer.isWindows && e.getMessage().contains("ReadFile()")) {
+ if (first) {
+ System.err.println("Failed to connect to server");
+ System.exit(1);
+ } else running = false;
+ } else {
+ e.printStackTrace();
+ System.exit(1);
+ }
}
- }catch(IOException e){
- // Win32NamedPipeSocket input stream somehow doesn't return -1,
- // but throw IOException whose message contains "ReadFile()" with a ccode
- if (ClientServer.isWindows && e.getMessage().contains("ReadFile()")) running = false;
- else throw new RuntimeException(e);
}
}
diff --git a/clientserver/src/mill/clientserver/ClientServer.java b/clientserver/src/mill/clientserver/ClientServer.java
index 7af5845b..e2e63dcf 100644
--- a/clientserver/src/mill/clientserver/ClientServer.java
+++ b/clientserver/src/mill/clientserver/ClientServer.java
@@ -5,8 +5,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-class ClientServer {
+public class ClientServer {
public static boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
+ public static boolean isJava9OrAbove = !System.getProperty("java.specification.version").startsWith("1.");
// Windows named pipe prefix (see https://github.com/sbt/ipcsocket/blob/v1.0.0/README.md)
// Win32NamedPipeServerSocket automatically adds this as a prefix (if it is not already is prefixed),
diff --git a/core/src/mill/util/ClassLoader.scala b/core/src/mill/util/ClassLoader.scala
index 9f0a7ab3..9678989e 100644
--- a/core/src/mill/util/ClassLoader.scala
+++ b/core/src/mill/util/ClassLoader.scala
@@ -52,12 +52,7 @@ object ClassLoader {
private def makeUrls(urls: Seq[URL])(implicit ctx: Ctx.Home): Seq[URL] = {
if (ammonite.util.Util.java9OrAbove) {
-
- val rtFile = ctx.home / io.github.retronym.java9rtexport.Export.rtJarName
- if (!exists(rtFile)) {
- cp(Path(Export.rt()), rtFile)
- }
- urls :+ rtFile.toNIO.toUri.toURL
+ urls :+ Export.rtAt(ctx.home.toIO).toURI.toURL
} else {
urls
}
diff --git a/main/src/mill/Main.scala b/main/src/mill/Main.scala
index 0844e485..e026dfe0 100644
--- a/main/src/mill/Main.scala
+++ b/main/src/mill/Main.scala
@@ -5,6 +5,7 @@ import java.io.{InputStream, PrintStream}
import ammonite.main.Cli._
import ammonite.ops._
import ammonite.util.Util
+import io.github.retronym.java9rtexport.Export
import mill.eval.Evaluator
import mill.util.DummyInputStream
@@ -118,6 +119,14 @@ object Main {
stateCache
)
+ if (mill.clientserver.ClientServer.isJava9OrAbove) {
+ val rt = cliConfig.home / Export.rtJarName
+ if (!exists(rt)) {
+ runner.printInfo(s"Preparing Java ${System.getProperty("java.version")} runtime; this may take a minute or two ...")
+ Export.rtTo(rt.toIO, false)
+ }
+ }
+
if (repl){
runner.printInfo("Loading...")
(runner.watchLoop(isRepl = true, printing = false, _.run()), runner.stateCache)
diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala
index fdc83cbf..dc39a4a8 100644
--- a/scalalib/src/mill/scalalib/ScalaModule.scala
+++ b/scalalib/src/mill/scalalib/ScalaModule.scala
@@ -330,7 +330,7 @@ trait ScalaModule extends mill.Module with TaskModule { outer =>
}
def ammoniteReplClasspath = T{
- resolveDeps(T.task{Agg(ivy"com.lihaoyi:::ammonite:1.1.0-3-73d5734")})()
+ resolveDeps(T.task{Agg(ivy"com.lihaoyi:::ammonite:1.1.0-7-33b728c")})()
}
def repl() = T.command{
if (T.ctx().log.inStream == DummyInputStream){