Add option not to add preamble to generated bootstraps (#854)

This commit is contained in:
Alexandre Archambault 2018-05-08 17:34:37 +02:00 committed by GitHub
parent 8427be2d45
commit b59ada58df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -53,7 +53,20 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
}
}
private def createJarBootstrap(javaOpts: Seq[String], output: File, content: Array[Byte]): Unit = {
private def createJarBootstrap(javaOpts: Seq[String], output: File, content: Array[Byte], withPreamble: Boolean): Unit =
if (withPreamble)
createJarBootstrapWithPreamble(javaOpts, output, content)
else
createSimpleJarBootstrap(output, content)
private def createSimpleJarBootstrap(output: File, content: Array[Byte]): Unit =
try Files.write(output.toPath, content)
catch { case e: IOException =>
Console.err.println(s"Error while writing $output${Option(e.getMessage).fold("")(" (" + _ + ")")}")
sys.exit(1)
}
private def createJarBootstrapWithPreamble(javaOpts: Seq[String], output: File, content: Array[Byte]): Unit = {
val javaCmd = Seq("java") ++
javaOpts
@ -221,7 +234,8 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
createJarBootstrap(
javaOpts,
output,
buffer.toByteArray
buffer.toByteArray,
options.options.preamble
)
}
@ -267,7 +281,8 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
createJarBootstrap(
javaOpts,
output,
baos.toByteArray
baos.toByteArray,
options.options.preamble
)
}

View File

@ -38,6 +38,8 @@ final case class BootstrapSpecificOptions(
rule: List[String] = Nil,
@Help("Add default rules to assembly rule list")
defaultRules: Boolean = true,
@Help("Add preamble")
preamble: Boolean = true,
@Recurse
isolated: IsolatedLoaderOptions = IsolatedLoaderOptions(),
@Recurse