Skip to content

Commit 6de08e6

Browse files
committed
Introduce property to ensure embedded jar name is artifactId.type
by default, it is used for sapjco3 and sapidoc3 which requires to have jar having the exact naming scheme sapjco3.jar and sapidoc3.jar starting with version 3.1.12 and 3.1.4 respectively. fixes #51224 Signed-off-by: Aurélien Pupier <[email protected]>
1 parent 42918c3 commit 6de08e6

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/PackageConfig.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ interface JarConfig {
160160
@WithDefault("true")
161161
boolean addRunnerSuffix();
162162

163+
/**
164+
* Indicates a list of dependency for which the jar will use artifactId.type filename scheme
165+
* Each dependency needs to be expressed in the following format:
166+
* <p>
167+
* {@code groupId:artifactId[:[classifier][:[type]]]}
168+
* <p>
169+
* With the classifier and type being optional (note that the brackets ({@code []}) denote optionality and are
170+
* not a part of the syntax specification).
171+
* The group ID and artifact ID must be present and non-empty.
172+
* <p>
173+
* If the type is missing, the artifact is assumed to be of type {@code jar}.
174+
* <p>
175+
* This parameter is optional; if absent, jar names will use groupId.artifactId[-version][-classifier].type scheme
176+
*/
177+
@WithDefault("com.sap.conn.jco:sapjco3::jar,com.sap.conn.idoc:sapidoc3::jar")
178+
Optional<Set<GACT>> forceUseArtifactIdOnlyAsName();
179+
163180
/**
164181
* AppCDS archive sub-configuration.
165182
* This configuration only applies to certain JAR types.

core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/FastJarBuilder.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
5757
import io.quarkus.deployment.util.FileUtil;
5858
import io.quarkus.maven.dependency.ArtifactKey;
59+
import io.quarkus.maven.dependency.GACT;
5960
import io.quarkus.maven.dependency.ResolvedDependency;
6061
import io.quarkus.sbom.ApplicationComponent;
6162
import io.quarkus.sbom.ApplicationManifestConfig;
@@ -409,8 +410,20 @@ private static void copyDependency(Set<ArtifactKey> parentFirstArtifacts, Output
409410
if (runtimeArtifacts.containsKey(appDep.getKey())) {
410411
return;
411412
}
413+
Set<GACT> forceUseArtifactIdOnlyAsNameSet = packageConfig.jar().forceUseArtifactIdOnlyAsName()
414+
.orElse(Collections.emptySet());
415+
boolean forceUseArtifactIdOnlyAsName = forceUseArtifactIdOnlyAsNameSet.stream()
416+
.anyMatch(gact -> gact.getGroupId().equals(appDep.getGroupId())
417+
&& gact.getArtifactId().equals(appDep.getArtifactId())
418+
&& gact.getType().equals(appDep.getType())
419+
&& gact.getClassifier().equals(appDep.getClassifier()));
412420
for (Path resolvedDep : appDep.getResolvedPaths()) {
413-
final String fileName = FastJarFormat.getJarFileName(appDep, resolvedDep);
421+
String fileName;
422+
if (forceUseArtifactIdOnlyAsName) {
423+
fileName = appDep.getArtifactId() + "." + appDep.getType();
424+
} else {
425+
fileName = FastJarFormat.getJarFileName(appDep, resolvedDep);
426+
}
414427
final Path targetPath;
415428

416429
if (allowParentFirst && parentFirstArtifacts.contains(appDep.getKey())) {
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
package io.quarkus.maven.it;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.io.File;
36
import java.io.IOException;
47

58
import org.apache.maven.shared.invoker.MavenInvocationException;
69
import org.junit.jupiter.api.Test;
710

811
@DisableForNative
9-
public class FastJarQuarkusIntegrationTestIT extends QuarkusITBase {
12+
class FastJarQuarkusIntegrationTestIT extends QuarkusITBase {
1013

1114
@Test
12-
public void testFastJar() throws MavenInvocationException, IOException {
15+
void testFastJar() throws MavenInvocationException, IOException {
1316
doTest("qit-fast-jar", "fastjar");
1417
}
18+
19+
@Test
20+
void testFastJarWithForceUseArtifactIdOnlyAsName() throws MavenInvocationException, IOException {
21+
File testDir = doTest("qit-fast-jar-forceUseArtifactId", "fastjar",
22+
"-Dquarkus.package.jar.force-use-artifact-id-only-as-name=io.quarkus:quarkus-reactive-routes");
23+
System.out.println(testDir);
24+
File forceNamedFile = new File(testDir, "target/quarkus-app/lib/main/quarkus-reactive-routes.jar");
25+
assertThat(forceNamedFile).exists();
26+
}
1527
}

integration-tests/maven/src/test/java/io/quarkus/maven/it/QuarkusITBase.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
// meant to test that @QuarkusIntegrationTest can properly launch jars
1818
abstract class QuarkusITBase extends MojoTestBase {
1919

20-
void doTest(String projectName, String profile) throws MavenInvocationException, IOException {
20+
File doTest(String projectName, String profile, String additionalBuildParameter)
21+
throws MavenInvocationException, IOException {
2122
File testDir = initProject("projects/reactive-routes", "projects/" + projectName);
2223
RunningInvoker packageInvocation = new RunningInvoker(testDir, false);
2324

2425
MavenProcessInvocationResult packageInvocationResult = packageInvocation
2526
.execute(Arrays.asList("package", "-B",
26-
"-D" + profile), Collections.emptyMap());
27+
"-D" + profile, additionalBuildParameter), Collections.emptyMap());
2728

2829
await().atMost(3, TimeUnit.MINUTES)
2930
.until(() -> packageInvocationResult.getProcess() != null && !packageInvocationResult.getProcess().isAlive());
@@ -39,5 +40,10 @@ void doTest(String projectName, String profile) throws MavenInvocationException,
3940
.until(() -> integrationTestsInvocationResult.getProcess() != null
4041
&& !integrationTestsInvocationResult.getProcess().isAlive());
4142
assertThat(integrationTestsInvocation.log()).containsIgnoringCase("BUILD SUCCESS");
43+
return testDir;
44+
}
45+
46+
File doTest(String projectName, String profile) throws MavenInvocationException, IOException {
47+
return doTest(projectName, profile, "");
4248
}
4349
}

0 commit comments

Comments
 (0)