diff options
author | André Duarte <atduarte@users.noreply.github.com> | 2017-11-25 19:42:22 +0000 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-25 11:42:22 -0800 |
commit | f747228b08016723d1289bb09a278ff3cc25ed94 (patch) | |
tree | c59916f72931d0bb179f631c41f531017398f10d /core/src | |
parent | ff852a7a7602030b57af6f7fa499742b5c76d771 (diff) | |
download | mill-f747228b08016723d1289bb09a278ff3cc25ed94.tar.gz mill-f747228b08016723d1289bb09a278ff3cc25ed94.tar.bz2 mill-f747228b08016723d1289bb09a278ff3cc25ed94.zip |
Allow the definition of a prependShellScript in a ScalaModule (#13)
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/mill/modules/Jvm.scala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/core/src/main/scala/mill/modules/Jvm.scala b/core/src/main/scala/mill/modules/Jvm.scala index 84ae5c42..bccdfece 100644 --- a/core/src/main/scala/mill/modules/Jvm.scala +++ b/core/src/main/scala/mill/modules/Jvm.scala @@ -1,7 +1,7 @@ package mill.modules import java.io.FileOutputStream -import java.util.jar.{JarEntry, JarFile, JarInputStream, JarOutputStream} +import java.util.jar.{JarEntry, JarFile, JarOutputStream} import ammonite.ops._ import mill.define.Task @@ -65,21 +65,32 @@ object Jvm { def createAssembly(outputPath: Path, inputPaths: Seq[Path], - mainClass: Option[String] = None): Option[Path] = { + mainClass: Option[String] = None, + prependShellScript: String = "\n"): Option[Path] = { rm(outputPath) if(inputPaths.isEmpty) None else { mkdir(outputPath/up) + val output = new FileOutputStream(outputPath.toIO) + + // Prepend shell script + output.write((prependShellScript + "\n").getBytes) + if (prependShellScript.nonEmpty) { + import ammonite.ops.ImplicitWd._ + %%("chmod", "+x", outputPath) + } + val jar = new JarOutputStream( - new FileOutputStream(outputPath.toIO), + output, createManifest(mainClass) ) val seen = mutable.Set("META-INF/MANIFEST.MF") try{ assert(inputPaths.forall(exists(_))) + for{ p <- inputPaths @@ -106,6 +117,7 @@ object Jvm { } } finally { jar.close() + output.close() } Some(outputPath) |