Allow proguarded jar to be launched straightaway

With the right bash header
This commit is contained in:
Alexandre Archambault 2017-03-14 15:39:01 +01:00
parent 23ea3ff6fa
commit 11a1e509b5
1 changed files with 11 additions and 0 deletions

View File

@ -230,6 +230,17 @@ lazy val cli = project
},
packExcludeArtifactTypes += "pom",
resourceGenerators in Compile += packageBin.in(bootstrap).in(Compile).map { jar =>
import java.nio.file.Files
import java.nio.charset.StandardCharsets
val content = Files.readAllBytes(jar.toPath)
val header =
"""#!/usr/bin/env sh
|exec java $JAVA_OPTS -noverify -jar "$0" "$@"
""".stripMargin
Files.write(jar.toPath, header.getBytes(StandardCharsets.UTF_8) ++ content)
Seq(jar)
}.taskValue,
ProguardKeys.proguardVersion in Proguard := "5.3",