summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-26 21:35:32 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-26 21:52:42 -0800
commitfd8a2567ad32c11bcf8adbaca85bdba72bb4f935 (patch)
tree618d27157adab6508a4a6804e5c857975fcfb8cd /main
parent02e64b943b90387993f8f7bd7e3cd265ee569d27 (diff)
downloadmill-fd8a2567ad32c11bcf8adbaca85bdba72bb4f935.tar.gz
mill-fd8a2567ad32c11bcf8adbaca85bdba72bb4f935.tar.bz2
mill-fd8a2567ad32c11bcf8adbaca85bdba72bb4f935.zip
Port Mill client over to Java
This helps us avoid accidentally depending on the Scala library, whose classloading takes tens to hundreds of milliseconds. This removes the last parts of the Scala library used in the client (e.g. lambdas) and reduces `mill show core.compile` from ~380ms to ~290ms
Diffstat (limited to 'main')
-rw-r--r--main/src/mill/Main.scala53
-rw-r--r--main/src/mill/modules/Jvm.scala4
2 files changed, 2 insertions, 55 deletions
diff --git a/main/src/mill/Main.scala b/main/src/mill/Main.scala
index 4a2ccba0..6c10f6f2 100644
--- a/main/src/mill/Main.scala
+++ b/main/src/mill/Main.scala
@@ -5,63 +5,10 @@ import java.io.{InputStream, PrintStream}
import ammonite.main.Cli._
import ammonite.ops._
import ammonite.util.Util
-import mill.clientserver.{Client, FileLocks}
import mill.eval.Evaluator
import mill.util.DummyInputStream
-object ClientMain {
- def initServer(lockBase: String) = {
- val selfJars = new java.lang.StringBuilder
- var current = getClass.getClassLoader
- while(current != null){
- getClass.getClassLoader match{
- case e: java.net.URLClassLoader =>
- val urls = e.getURLs
- var i = 0
- while(i < urls.length){
- if (selfJars.length() != 0) selfJars.append(':')
- selfJars.append(urls(i))
- i += 1
- }
- case _ =>
- }
- current = current.getParent
- }
-
- val l = new java.util.ArrayList[String]
- l.add("java")
- val props = System.getProperties
- val keys = props.stringPropertyNames().iterator()
- while(keys.hasNext){
- val k = keys.next()
- if (k.startsWith("MILL_")) l.add("-D" + k + "=" + props.getProperty(k))
- }
- l.add("-cp")
- l.add(selfJars.toString)
- l.add("mill.ServerMain")
- l.add(lockBase)
- new java.lang.ProcessBuilder()
- .command(l)
- .redirectOutput(new java.io.File(lockBase + "/logs"))
- .redirectError(new java.io.File(lockBase + "/logs"))
- .start()
- }
- def main(args: Array[String]): Unit = {
- val exitCode = Client.WithLock(1) { lockBase =>
- val c = new Client(
- lockBase,
- () => initServer(lockBase),
- new FileLocks(lockBase),
- System.in,
- System.out,
- System.err
- )
- c.run(args)
- }
- System.exit(exitCode)
- }
-}
object ServerMain extends mill.clientserver.ServerMain[Evaluator.State]{
def main0(args: Array[String],
stateCache: Option[Evaluator.State],
diff --git a/main/src/mill/modules/Jvm.scala b/main/src/mill/modules/Jvm.scala
index 5e297072..57e02dd4 100644
--- a/main/src/mill/modules/Jvm.scala
+++ b/main/src/mill/modules/Jvm.scala
@@ -7,7 +7,7 @@ import java.nio.file.attribute.PosixFilePermission
import java.util.jar.{JarEntry, JarFile, JarOutputStream}
import ammonite.ops._
-import mill.clientserver.{ClientInputPumper, ClientServer}
+import mill.clientserver.{ClientServer, InputPumper}
import mill.define.Task
import mill.eval.PathRef
import mill.util.{Ctx, Loose}
@@ -62,7 +62,7 @@ object Jvm {
)
for((std, dest) <- sources){
- new Thread(new ClientInputPumper(std, dest)).start()
+ new Thread(new InputPumper(std, dest, false)).start()
}
process
}else{