forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce UberJarMergedResourceBuildItem and UberJarIgnoredResourceBu…
…ildItem Fixes quarkusio#5677
- Loading branch information
Showing
6 changed files
with
244 additions
and
8 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...nt/src/main/java/io/quarkus/deployment/pkg/builditem/UberJarIgnoredResourceBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.deployment.pkg.builditem; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
import io.smallrye.common.constraint.Assert; | ||
|
||
/** | ||
* Ignore resources when building an Uber Jar | ||
*/ | ||
public final class UberJarIgnoredResourceBuildItem extends MultiBuildItem { | ||
|
||
private final String path; | ||
|
||
public UberJarIgnoredResourceBuildItem(String path) { | ||
this.path = Assert.checkNotEmptyParam("UberJarIgnoredResourceBuildItem.path", path); | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ent/src/main/java/io/quarkus/deployment/pkg/builditem/UberJarMergedResourceBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.deployment.pkg.builditem; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
import io.smallrye.common.constraint.Assert; | ||
|
||
/** | ||
* Merge duplicate resources from multiple JARs when building an Uber Jar | ||
*/ | ||
public final class UberJarMergedResourceBuildItem extends MultiBuildItem { | ||
|
||
private final String path; | ||
|
||
public UberJarMergedResourceBuildItem(String path) { | ||
this.path = Assert.checkNotEmptyParam("UberJarMergedResourceBuildItem.path", path); | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...tension/deployment/src/main/java/io/quarkus/extest/deployment/UberJarConfigBuildStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.quarkus.extest.deployment; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.pkg.builditem.UberJarIgnoredResourceBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.UberJarMergedResourceBuildItem; | ||
|
||
/** | ||
* Used in UberJarMergedResourceBuildItemTest | ||
*/ | ||
public class UberJarConfigBuildStep { | ||
|
||
@BuildStep | ||
UberJarMergedResourceBuildItem uberJarMergedResourceBuildItem() { | ||
return new UberJarMergedResourceBuildItem("META-INF/cxf/bus-extensions.txt"); | ||
} | ||
|
||
@BuildStep | ||
UberJarIgnoredResourceBuildItem uberJarIgnoredResourceBuildItem() { | ||
return new UberJarIgnoredResourceBuildItem("META-INF/cxf/cxf.fixml"); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...rc/test/java/io/quarkus/deployment/pkg/builditem/UberJarIgnoredResourceBuildItemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.quarkus.deployment.pkg.builditem; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.bootstrap.model.AppArtifact; | ||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
class UberJarIgnoredResourceBuildItemTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest runner = new QuarkusProdModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsManifestResource("application.properties", "microprofile-config.properties") | ||
.addClass(UberJarMain.class)) | ||
.setApplicationName("uber-jar-ignored") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setRun(true) | ||
.setExpectExit(true) | ||
.overrideConfigKey("quarkus.package.type", "uber-jar") | ||
.setForcedDependencies( | ||
Collections.singletonList( | ||
// META-INF/cxf/cxf.fixml should be present in the cxf-rt-transports-http and cxf-core JARs | ||
new AppArtifact("org.apache.cxf", "cxf-rt-transports-http", "3.4.3"))); | ||
|
||
@Test | ||
public void testResourceWasIgnored() throws IOException { | ||
assertThat(runner.getStartupConsoleOutput()).contains("RESOURCES: 0"); | ||
assertThat(runner.getExitCode()).isZero(); | ||
} | ||
|
||
@QuarkusMain | ||
public static class UberJarMain { | ||
|
||
public static void main(String[] args) throws IOException { | ||
List<URL> resources = Collections | ||
.list(UberJarMain.class.getClassLoader().getResources("META-INF/cxf/cxf.fixml")); | ||
System.out.println("RESOURCES: " + resources.size()); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.