summaryrefslogtreecommitdiff
path: root/scalalib/src
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-21 21:05:37 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-24 17:13:03 -0800
commitc98408adf2d96928fe227a740631a8efd8e0c339 (patch)
tree5a36d9ee7d8ee6e1f7f9247cd7ddd31b194df5df /scalalib/src
parent51db54d4f1deefb34b9d7f6581611ae166652493 (diff)
downloadmill-c98408adf2d96928fe227a740631a8efd8e0c339.tar.gz
mill-c98408adf2d96928fe227a740631a8efd8e0c339.tar.bz2
mill-c98408adf2d96928fe227a740631a8efd8e0c339.zip
Clean up the provisional client-server code with unit tests and proper file-sockets
Seems to work well enough for interactive scala consoles, though still not Ammonite Also Added ScalaModule#launcher and re-worked our build.sc file to use it
Diffstat (limited to 'scalalib/src')
-rw-r--r--scalalib/src/mill/scalalib/Lib.scala4
-rw-r--r--scalalib/src/mill/scalalib/ScalaModule.scala31
2 files changed, 28 insertions, 7 deletions
diff --git a/scalalib/src/mill/scalalib/Lib.scala b/scalalib/src/mill/scalalib/Lib.scala
index 50e19b16..208d545e 100644
--- a/scalalib/src/mill/scalalib/Lib.scala
+++ b/scalalib/src/mill/scalalib/Lib.scala
@@ -112,8 +112,4 @@ object Lib{
cross = false
)
- val DefaultShellScript: Seq[String] = Seq(
- "#!/usr/bin/env sh",
- "exec java -jar \"$0\" \"$@\""
- )
}
diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala
index ffaaeac8..a2888048 100644
--- a/scalalib/src/mill/scalalib/ScalaModule.scala
+++ b/scalalib/src/mill/scalalib/ScalaModule.scala
@@ -112,7 +112,17 @@ trait ScalaModule extends mill.Module with TaskModule { outer =>
}
- def prependShellScript: T[String] = T{ "" }
+ def prependShellScript: T[String] = T{
+ mainClass() match{
+ case None => ""
+ case Some(cls) =>
+ mill.modules.Jvm.launcherShellScript(
+ cls,
+ Agg("$0"),
+ forkArgs()
+ )
+ }
+ }
def sources = T.sources{ millSourcePath / 'src }
def resources = T.sources{ millSourcePath / 'resources }
@@ -189,7 +199,7 @@ trait ScalaModule extends mill.Module with TaskModule { outer =>
if (files.nonEmpty) subprocess(
"scala.tools.nsc.ScalaDoc",
- runClasspath().filter(_.path.ext != "pom").map(_.path),
+ scalaCompilerClasspath().map(_.path) ++ runClasspath().filter(_.path.ext != "pom").map(_.path),
mainArgs = (files ++ options).toSeq
)
@@ -204,6 +214,20 @@ trait ScalaModule extends mill.Module with TaskModule { outer =>
def forkEnv = T{ sys.env.toMap }
+ def launcher = T{
+ mainClass() match {
+ case None => Result.Failure("Need to specify a main class for launcher")
+ case Some(cls) =>
+ Result.Success(
+ Jvm.createLauncher(
+ cls,
+ runClasspath().map(_.path),
+ forkArgs()
+ )
+ )
+ }
+ }
+
def runLocal(args: String*) = T.command {
Jvm.runLocal(
finalMainClass(),
@@ -219,7 +243,8 @@ trait ScalaModule extends mill.Module with TaskModule { outer =>
forkArgs(),
forkEnv(),
args,
- workingDir = ammonite.ops.pwd)
+ workingDir = ammonite.ops.pwd
+ )
}