summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-04-09 22:16:27 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2018-04-09 22:51:42 -0700
commitf79e9bbad7aefd9aeea89fd4c456b1eb447917db (patch)
treefc52e1452f359a1b09b39b8650aec29a07373b95 /main
parent8bd438bf84c1b221bcc122b3abe5d4ec37495071 (diff)
downloadmill-f79e9bbad7aefd9aeea89fd4c456b1eb447917db.tar.gz
mill-f79e9bbad7aefd9aeea89fd4c456b1eb447917db.tar.bz2
mill-f79e9bbad7aefd9aeea89fd4c456b1eb447917db.zip
- Swap client-server integer encoding over to a more standard format (32-bit)
- Unit tests for client code using the new Java support - Make server auto-shutdown when the client version changes, to avoid stale-server confusion
Diffstat (limited to 'main')
-rw-r--r--main/src/mill/Main.scala8
-rw-r--r--main/src/mill/main/Server.scala22
-rw-r--r--main/test/src/mill/main/ClientServerTests.scala6
3 files changed, 19 insertions, 17 deletions
diff --git a/main/src/mill/Main.scala b/main/src/mill/Main.scala
index a349321e..2992afa4 100644
--- a/main/src/mill/Main.scala
+++ b/main/src/mill/Main.scala
@@ -3,16 +3,12 @@ package mill
import java.io.{InputStream, PrintStream}
import scala.collection.JavaConverters._
-
import ammonite.main.Cli._
import ammonite.ops._
-import ammonite.util.Util
import io.github.retronym.java9rtexport.Export
-import mill.client.ClientServer
import mill.eval.Evaluator
import mill.util.DummyInputStream
-
object Main {
def main(args: Array[String]): Unit = {
@@ -73,7 +69,7 @@ object Main {
s"""Mill Build Tool
|usage: mill [mill-options] [target [target-options]]
|
- |${formatBlock(millArgSignature, leftMargin).mkString(Util.newLine)}""".stripMargin
+ |${formatBlock(millArgSignature, leftMargin).mkString(ammonite.util.Util.newLine)}""".stripMargin
)
(true, None)
case Right((cliConfig, leftoverArgs)) =>
@@ -110,7 +106,7 @@ object Main {
env
)
- if (ClientServer.isJava9OrAbove) {
+ if (mill.client.Util.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 ...")
diff --git a/main/src/mill/main/Server.scala b/main/src/mill/main/Server.scala
index 14aade4c..275767c8 100644
--- a/main/src/mill/main/Server.scala
+++ b/main/src/mill/main/Server.scala
@@ -61,8 +61,8 @@ class Server[T](lockBase: String,
var running = true
while (running) {
Server.lockBlock(locks.serverLock){
- val (serverSocket, socketClose) = if (ClientServer.isWindows) {
- val socketName = ClientServer.WIN32_PIPE_PREFIX + new File(lockBase).getName
+ val (serverSocket, socketClose) = if (Util.isWindows) {
+ val socketName = Util.WIN32_PIPE_PREFIX + new File(lockBase).getName
(new Win32NamedPipeServerSocket(socketName), () => new Win32NamedPipeSocket(socketName).close())
} else {
val socketName = lockBase + "/io"
@@ -96,19 +96,25 @@ class Server[T](lockBase: String,
def handleRun(clientSocket: Socket) = {
val currentOutErr = clientSocket.getOutputStream
+ val stdout = new PrintStream(new ProxyOutputStream(currentOutErr, 0), true)
+ val stderr = new PrintStream(new ProxyOutputStream(currentOutErr, 1), true)
val socketIn = clientSocket.getInputStream
val argStream = new FileInputStream(lockBase + "/run")
- val interactive = argStream.read() != 0;
- val args = ClientServer.parseArgs(argStream)
- val env = ClientServer.parseMap(argStream)
+ val interactive = argStream.read() != 0
+ val clientMillVersion = Util.readString(argStream)
+ val serverMillVersion = sys.props("MILL_VERSION")
+ if (clientMillVersion != serverMillVersion) {
+ stdout.println(s"Mill version changed ($serverMillVersion -> $clientMillVersion), re-starting server")
+ System.exit(0)
+ }
+ val args = Util.parseArgs(argStream)
+ val env = Util.parseMap(argStream)
argStream.close()
var done = false
val t = new Thread(() =>
try {
- val stdout = new PrintStream(new ProxyOutputStream(currentOutErr, 0), true)
- val stderr = new PrintStream(new ProxyOutputStream(currentOutErr, 1), true)
val (result, newStateCache) = sm.main0(
args,
sm.stateCache,
@@ -144,7 +150,7 @@ class Server[T](lockBase: String,
t.interrupt()
t.stop()
- if (ClientServer.isWindows) {
+ if (Util.isWindows) {
// Closing Win32NamedPipeSocket can often take ~5s
// It seems OK to exit the client early and subsequently
// start up mill client again (perhaps closing the server
diff --git a/main/test/src/mill/main/ClientServerTests.scala b/main/test/src/mill/main/ClientServerTests.scala
index 60c9c9e6..7139c4db 100644
--- a/main/test/src/mill/main/ClientServerTests.scala
+++ b/main/test/src/mill/main/ClientServerTests.scala
@@ -2,7 +2,7 @@ package mill.main
import java.io._
import java.nio.file.Path
-import mill.client.{ClientServer, Locks}
+import mill.client.{Util, Locks}
import scala.collection.JavaConverters._
import utest._
@@ -77,7 +77,7 @@ object ClientServerTests extends TestSuite{
def tests = Tests{
'hello - {
- if (!ClientServer.isWindows){
+ if (!Util.isWindows){
val (tmpDir, locks) = init()
def runClient(s: String) = runClientAux(tmpDir, locks)(Map.empty, Array(s))
@@ -132,7 +132,7 @@ object ClientServerTests extends TestSuite{
}
'envVars - {
- if (!ClientServer.isWindows){
+ if (!Util.isWindows){
val (tmpDir, locks) = init()
def runClient(env : Map[String, String]) = runClientAux(tmpDir, locks)(env, Array())