diff --git a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java index 04ff42b5acbf8..ef9302e534ea4 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java @@ -77,7 +77,6 @@ protected boolean beforeExecute() throws MojoExecutionException { @Override protected void doExecute() throws MojoExecutionException { - boolean clear = false; try { try (CuratedApplication curatedApplication = bootstrapApplication()) { @@ -110,10 +109,6 @@ protected void doExecute() throws MojoExecutionException { } } catch (Exception e) { throw new MojoExecutionException("Failed to build quarkus application", e); - } finally { - if (clear) { - System.clearProperty(QUARKUS_PACKAGE_UBER_JAR); - } } } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java index bf6d0ed94b8f9..031a190bb73f9 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java @@ -76,21 +76,13 @@ public abstract class QuarkusBootstrapMojo extends AbstractMojo { private String[] ignoredEntries; private AppArtifactKey projectId; - private boolean clearUberJarProp; @Override public void execute() throws MojoExecutionException, MojoFailureException { if (!beforeExecute()) { return; } - try { - doExecute(); - } finally { - if (clearUberJarProp) { - System.clearProperty(BuildMojo.QUARKUS_PACKAGE_UBER_JAR); - clearUberJarProp = false; - } - } + doExecute(); } @Override @@ -99,10 +91,6 @@ public void setLog(Log log) { MojoLogger.delegate = log; } - protected void clearUberJarProp() { - this.clearUberJarProp = true; - } - /** * This callback allows to evaluate whether this mojo should be executed, skipped or fail. * diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java index ce99a24d91f10..c479752bbbf39 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java @@ -161,7 +161,6 @@ protected QuarkusBootstrap bootstrapQuarkus(QuarkusBootstrapMojo mojo) throws Mo } if (mojo.uberJar() && System.getProperty(BuildMojo.QUARKUS_PACKAGE_UBER_JAR) == null) { System.setProperty(BuildMojo.QUARKUS_PACKAGE_UBER_JAR, "true"); - mojo.clearUberJarProp(); } effectiveProperties.putIfAbsent("quarkus.application.name", mojo.mavenProject().getArtifactId()); effectiveProperties.putIfAbsent("quarkus.application.version", mojo.mavenProject().getVersion()); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/PackageIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/PackageIT.java index 5755ab3d22a43..3e9e52a7679e4 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/PackageIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/PackageIT.java @@ -34,6 +34,18 @@ public class PackageIT extends MojoTestBase { private RunningInvoker running; private File testDir; + @Test + public void testUberJarMavenPluginConfiguration() + throws MavenInvocationException, IOException, InterruptedException { + testDir = initProject("projects/uberjar-maven-plugin-config"); + running = new RunningInvoker(testDir, false); + final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"), + Collections.emptyMap()); + assertThat(result.getProcess().waitFor()).isEqualTo(0); + + verifyUberJar(); + } + @Test public void testPackageWorksWhenUberjarIsFalse() throws MavenInvocationException, IOException, InterruptedException { @@ -126,6 +138,10 @@ private void createAndVerifyUberJar() throws IOException, MavenInvocationExcepti Collections.emptyMap(), p); assertThat(result.getProcess().waitFor()).isEqualTo(0); + verifyUberJar(); + } + + private void verifyUberJar() throws IOException { final File targetDir = getTargetDir(); List jars = getFilesEndingWith(targetDir, ".jar"); assertThat(jars).hasSize(1); diff --git a/integration-tests/maven/src/test/resources/projects/uberjar-maven-plugin-config/pom.xml b/integration-tests/maven/src/test/resources/projects/uberjar-maven-plugin-config/pom.xml new file mode 100644 index 0000000000000..4730ebcc7796c --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/uberjar-maven-plugin-config/pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + org.acme + acme + 1.0-SNAPSHOT + + io.quarkus + quarkus-bom + @project.version@ + @project.version@ + 1.8 + UTF-8 + 1.8 + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus-plugin.version} + + + + generate-code + generate-code-tests + build + + + true + + + + + + + + + native + + + + io.quarkus + quarkus-maven-plugin + ${quarkus-plugin.version} + + + + native-image + + + true + + + + + + + + + diff --git a/integration-tests/maven/src/test/resources/projects/uberjar-maven-plugin-config/src/main/java/org/acme/HelloResource.java b/integration-tests/maven/src/test/resources/projects/uberjar-maven-plugin-config/src/main/java/org/acme/HelloResource.java new file mode 100644 index 0000000000000..e05e3fc81410a --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/uberjar-maven-plugin-config/src/main/java/org/acme/HelloResource.java @@ -0,0 +1,16 @@ +package org.acme; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/hello") +public class HelloResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "hello"; + } +}