This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 29e55dc Add manifest to camel-quarkus-support-spring source JARs 29e55dc is described below commit 29e55dc8f9195203f6936f08cd4d28bb05e5718e Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Wed Nov 24 10:33:03 2021 +0000 Add manifest to camel-quarkus-support-spring source JARs Fixes #3321 --- .../support/spring/test/SpringSupportTest.java | 44 ++++++++++++++++++++++ pom.xml | 5 +++ 2 files changed, 49 insertions(+) diff --git a/extensions-support/spring/integration-test/src/test/java/org/apache/camel/quarkus/support/spring/test/SpringSupportTest.java b/extensions-support/spring/integration-test/src/test/java/org/apache/camel/quarkus/support/spring/test/SpringSupportTest.java index e1c43d7..2ae0fd9 100644 --- a/extensions-support/spring/integration-test/src/test/java/org/apache/camel/quarkus/support/spring/test/SpringSupportTest.java +++ b/extensions-support/spring/integration-test/src/test/java/org/apache/camel/quarkus/support/spring/test/SpringSupportTest.java @@ -16,10 +16,20 @@ */ package org.apache.camel.quarkus.support.spring.test; +import java.io.File; +import java.net.JarURLConnection; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; + @QuarkusTest public class SpringSupportTest { @@ -45,4 +55,38 @@ public class SpringSupportTest { .statusCode(204); } } + + @Test + public void verifySourcesJarManifest() throws Exception { + String[] springModules = new String[] { "beans", "context", "core" }; + for (String module : springModules) { + Path path = Paths.get("../" + module + "/target"); + File file = path.toFile(); + if (!file.exists()) { + throw new IllegalStateException("The sources JAR location does not exist: " + file.getAbsolutePath()); + } + + File[] files = file + .listFiles(f -> f.getName().matches("^camel-quarkus-support-spring-" + module + "-.*-sources.jar")); + + if (files.length == 1) { + URL url = new URL("jar:file:" + files[0].getAbsolutePath() + "!/"); + JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); + Manifest manifest = jarConnection.getManifest(); + assertNotNull(manifest); + + Attributes attributes = manifest.getMainAttributes(); + assertNotNull(attributes.getValue("Specification-Version")); + assertNotNull(attributes.getValue("Implementation-Version")); + } else if (files.length == 0) { + throw new IllegalStateException( + "Detected no camel-quarkus-support-spring-" + module + " sources JAR in: " + + file.getAbsolutePath()); + } else { + throw new IllegalStateException( + "Detected multiple camel-quarkus-support-spring-" + module + " sources JARs in: " + + file.getAbsolutePath()); + } + } + } } diff --git a/pom.xml b/pom.xml index 113ab49..0abfa4a 100644 --- a/pom.xml +++ b/pom.xml @@ -355,6 +355,11 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>${maven-shade-plugin.version}</version> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/> + </transformers> + </configuration> </plugin> <plugin>