diff options
Diffstat (limited to 'scalalib')
-rw-r--r-- | scalalib/src/mill/scalalib/Lib.scala | 4 | ||||
-rw-r--r-- | scalalib/src/mill/scalalib/ScalaModule.scala | 31 |
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 + ) } |