Skip to content

Commit

Permalink
Ensure that subsequent uberJar creations doesn't fail
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Oct 25, 2019
1 parent 0780b64 commit 131441b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.quarkus.deployment.pkg.steps;

import static io.quarkus.bootstrap.util.ZipUtils.wrapForJDK8232879;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
import static java.nio.file.StandardOpenOption.WRITE;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -426,7 +429,10 @@ private void copyCommonContent(FileSystem runnerZipFs, Map<String, List<byte[]>>
copyFiles(appArchives.getRootArchive().getArchiveRoot(), runnerZipFs, services);

for (Map.Entry<String, List<byte[]>> entry : services.entrySet()) {
try (final OutputStream os = wrapForJDK8232879(Files.newOutputStream(runnerZipFs.getPath(entry.getKey())))) {
try (final OutputStream os = wrapForJDK8232879(
// we shouldn't have to specify these flags (since they are the default ones), but failure to do so
// makes a subsequent uberJar creation fail in java 8 (but works fine in Java 11)
Files.newOutputStream(runnerZipFs.getPath(entry.getKey()), TRUNCATE_EXISTING, WRITE, CREATE))) {
for (byte[] i : entry.getValue()) {
os.write(i);
os.write('\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public void testPackageWorksWhenUberjarIsTrue()
throws MavenInvocationException, FileNotFoundException, InterruptedException {
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-true");

createAndVerifyUberJar();
// ensure that subsequent package without clean also works
createAndVerifyUberJar();
}

private void createAndVerifyUberJar() throws FileNotFoundException, MavenInvocationException, InterruptedException {
running = new RunningInvoker(testDir, false);
final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"),
Collections.singletonMap("QUARKUS_PACKAGE_TYPES", "uber-jar"));
Expand Down

0 comments on commit 131441b

Please sign in to comment.