Adjust fat jar central directory to account for launch script

An upgrade to Apache Commons Compress allows the build plugins to write
the launch script to the fat jar as a proper preamble, making the file
compatible with more jar and zip tooling.

Fixes gh-22336
This commit is contained in:
Scott Frederick
2021-07-19 15:02:05 -05:00
parent b5ef5a2d90
commit 9f001efa29
11 changed files with 36 additions and 46 deletions

View File

@@ -135,8 +135,8 @@ class BootZipCopyAction implements CopyAction {
}
private void writeArchive(CopyActionProcessingStream copyActions, OutputStream output) throws IOException {
writeLaunchScriptIfNecessary(output);
ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(output);
writeLaunchScriptIfNecessary(zipOutput);
try {
setEncodingIfNecessary(zipOutput);
Processor processor = new Processor(zipOutput);
@@ -148,15 +148,14 @@ class BootZipCopyAction implements CopyAction {
}
}
private void writeLaunchScriptIfNecessary(OutputStream outputStream) {
private void writeLaunchScriptIfNecessary(ZipArchiveOutputStream outputStream) {
if (this.launchScript == null) {
return;
}
try {
File file = this.launchScript.getScript();
Map<String, String> properties = this.launchScript.getProperties();
outputStream.write(new DefaultLaunchScript(file, properties).toByteArray());
outputStream.flush();
outputStream.writePreamble(new DefaultLaunchScript(file, properties).toByteArray());
this.output.setExecutable(true);
}
catch (IOException ex) {