Skip to content

Commit 85c5428

Browse files
authored
Merge pull request #53026 from aloubyansky/app-comp-version
Add versions and PURLs to all the components in SBOMs, including misc files
2 parents cc4e557 + 08b4850 commit 85c5428

File tree

10 files changed

+117
-27
lines changed

10 files changed

+117
-27
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public JarBuildItem build() throws IOException {
213213

214214
if (!rebuild) {
215215
manifestConfig.addComponent(ApplicationComponent.builder()
216-
.setResolvedDependency(applicationArchives.getRootArchive().getResolvedDependency())
216+
.setResolvedDependency(appArtifact)
217217
.setPath(runnerJar));
218218
Predicate<String> ignoredEntriesPredicate = getThinJarIgnoredEntriesPredicate(packageConfig);
219219
try (ArchiveCreator archiveCreator = new ParallelCommonsCompressArchiveCreator(runnerJar,
@@ -271,6 +271,7 @@ public JarBuildItem build() throws IOException {
271271
runnerJar.toFile().setReadable(true, false);
272272
Path initJar = buildDir.resolve(FastJarFormat.QUARKUS_RUN_JAR);
273273
manifestConfig.setMainComponent(ApplicationComponent.builder()
274+
.setVersion(appArtifact.getVersion())
274275
.setPath(initJar)
275276
.setDependencies(List.of(curateOutcome.getApplicationModel().getAppArtifact())))
276277
.setRunnerPath(initJar);
@@ -285,7 +286,10 @@ public JarBuildItem build() throws IOException {
285286
List<String> lines = Arrays.stream(out.toString(StandardCharsets.UTF_8).split("\n"))
286287
.filter(s -> !s.startsWith("#")).sorted().collect(Collectors.toList());
287288
Path buildSystemProps = quarkus.resolve(FastJarFormat.BUILD_SYSTEM_PROPERTIES);
288-
manifestConfig.addComponent(ApplicationComponent.builder().setPath(buildSystemProps).setDevelopmentScope());
289+
manifestConfig.addComponent(ApplicationComponent.builder()
290+
.setVersion(appArtifact.getVersion())
291+
.setPath(buildSystemProps)
292+
.setDevelopmentScope());
289293
try (OutputStream fileOutput = Files.newOutputStream(buildSystemProps)) {
290294
fileOutput.write(String.join("\n", lines).getBytes(StandardCharsets.UTF_8));
291295
}
@@ -323,7 +327,10 @@ public JarBuildItem build() throws IOException {
323327
curateOutcome.getApplicationModel(),
324328
packageConfig.jar().userProvidersDirectory().orElse(null), buildDir.relativize(runnerJar).toString());
325329
Path appmodelDat = deploymentLib.resolve(FastJarFormat.APPMODEL_DAT);
326-
manifestConfig.addComponent(ApplicationComponent.builder().setPath(appmodelDat).setDevelopmentScope());
330+
manifestConfig.addComponent(ApplicationComponent.builder()
331+
.setVersion(appArtifact.getVersion())
332+
.setPath(appmodelDat)
333+
.setDevelopmentScope());
327334
try (OutputStream out = Files.newOutputStream(appmodelDat)) {
328335
ObjectOutputStream obj = new ObjectOutputStream(out);
329336
obj.writeObject(model);
@@ -334,7 +341,10 @@ public JarBuildItem build() throws IOException {
334341
//as we don't really have a resolved bootstrap CP
335342
//once we have the app model it will all be done in QuarkusClassLoader anyway
336343
Path deploymentCp = deploymentLib.resolve(FastJarFormat.DEPLOYMENT_CLASS_PATH_DAT);
337-
manifestConfig.addComponent(ApplicationComponent.builder().setPath(deploymentCp).setDevelopmentScope());
344+
manifestConfig.addComponent(ApplicationComponent.builder()
345+
.setVersion(appArtifact.getVersion())
346+
.setPath(deploymentCp)
347+
.setDevelopmentScope());
338348
try (OutputStream out = Files.newOutputStream(deploymentCp)) {
339349
ObjectOutputStream obj = new ObjectOutputStream(out);
340350
List<String> paths = new ArrayList<>();

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ ArtifactResultBuildItem result(NativeImageBuildItem image,
104104
ApplicationManifestConfig.builder()
105105
.setApplicationModel(curateOutcomeBuildItem.getApplicationModel())
106106
.setMainComponent(ApplicationComponent.builder()
107+
.setVersion(curateOutcomeBuildItem.getApplicationModel().getAppArtifact().getVersion())
107108
.setPath(image.getPath())
108109
.setDependencies(List.of(curateOutcomeBuildItem.getApplicationModel().getAppArtifact())))
109110
.setRunnerPath(image.getPath())
@@ -184,6 +185,7 @@ ArtifactResultBuildItem nativeSourcesResult(NativeConfig nativeConfig,
184185
ApplicationManifestConfig.builder()
185186
.setApplicationModel(curateOutcomeBuildItem.getApplicationModel())
186187
.setMainComponent(ApplicationComponent.builder()
188+
.setVersion(curateOutcomeBuildItem.getApplicationModel().getAppArtifact().getVersion())
187189
.setPath(nativeImageSourceJarBuildItem.getPath())
188190
.setResolvedDependency(curateOutcomeBuildItem.getApplicationModel().getAppArtifact()))
189191
.setRunnerPath(nativeImageSourceJarBuildItem.getPath())

core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ApplicationManifestFastJarTest.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import io.quarkus.bootstrap.resolver.TsArtifact;
88
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
9+
import io.quarkus.maven.dependency.ArtifactCoords;
910
import io.quarkus.sbom.ApplicationComponent;
1011

1112
public class ApplicationManifestFastJarTest extends ApplicationManifestTestBase {
@@ -15,7 +16,7 @@ protected TsArtifact composeApplication() {
1516

1617
var acmeTransitive = TsArtifact.jar("acme-transitive");
1718

18-
var acmeCommon = TsArtifact.jar("acme-common")
19+
var acmeCommon = TsArtifact.jar("acme-common", "3.0")
1920
.addDependency(acmeTransitive);
2021

2122
var acmeLib = TsArtifact.jar("acme-lib")
@@ -31,7 +32,7 @@ protected TsArtifact composeApplication() {
3132
myExt.getRuntime().addDependency(myLib);
3233
myExt.getDeployment().addDependency(otherLib);
3334

34-
return TsArtifact.jar("app")
35+
return TsArtifact.jar("app", "2.0")
3536
.addManagedDependency(platformDescriptor())
3637
.addManagedDependency(platformProperties())
3738
.addDependency(acmeLib)
@@ -49,8 +50,9 @@ protected Properties buildSystemProperties() {
4950
@BeforeEach
5051
public void initExpectedComponents() {
5152

52-
expectMavenComponent(artifactCoords("app"), comp -> {
53+
expectMavenComponent(ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "app", "2.0"), comp -> {
5354
assertDistributionPath(comp, "app/quarkus-application.jar");
55+
assertVersion(comp, "2.0");
5456
assertDependencies(comp,
5557
artifactCoords("acme-lib"),
5658
artifactCoords("other-lib"),
@@ -59,64 +61,77 @@ public void initExpectedComponents() {
5961
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
6062
});
6163

64+
final ArtifactCoords commonsCoords = ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "acme-common", "3.0");
65+
6266
expectMavenComponent(artifactCoords("acme-lib"), comp -> {
6367
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-lib-1.jar");
64-
assertDependencies(comp, artifactCoords("acme-common"));
68+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
69+
assertDependencies(comp, commonsCoords);
6570
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
6671
});
6772

68-
expectMavenComponent(artifactCoords("acme-common"), comp -> {
69-
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-common-1.jar");
73+
expectMavenComponent(commonsCoords, comp -> {
74+
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-common-3.0.jar");
75+
assertVersion(comp, "3.0");
7076
assertDependencies(comp, artifactCoords("acme-transitive"));
7177
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
7278
});
7379

7480
expectMavenComponent(artifactCoords("acme-transitive"), comp -> {
7581
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-transitive-1.jar");
82+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
7683
assertDependencies(comp);
7784
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
7885
});
7986

8087
expectMavenComponent(artifactCoords("other-lib"), comp -> {
8188
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.other-lib-1.jar");
82-
assertDependencies(comp, artifactCoords("acme-common"));
89+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
90+
assertDependencies(comp, commonsCoords);
8391
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
8492
});
8593

8694
expectMavenComponent(artifactCoords("my-lib"), comp -> {
8795
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.my-lib-1.jar");
88-
assertDependencies(comp, artifactCoords("acme-common"));
96+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
97+
assertDependencies(comp, commonsCoords);
8998
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
9099
});
91100

92101
expectMavenComponent(artifactCoords("my-ext"), comp -> {
93102
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.my-ext-1.jar");
103+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
94104
assertDependencies(comp, artifactCoords("my-lib"));
95105
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
96106
});
97107

98108
expectFileComponent("quarkus-run.jar", comp -> {
99-
assertDependencies(comp, artifactCoords("app"));
109+
assertVersion(comp, "2.0");
110+
assertDependencies(comp, ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "app", "2.0"));
100111
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
101112
});
102113

103114
expectFileComponent("quarkus/generated-bytecode.jar", comp -> {
115+
assertVersion(comp, "2.0");
104116
assertDependencies(comp);
105117
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
106118
});
107119

108120
expectFileComponent("quarkus/quarkus-application.dat", comp -> {
121+
assertVersion(comp, "2.0");
109122
assertDependencies(comp);
110123
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
111124
});
112125

113126
expectFileComponent("quarkus-app-dependencies.txt", comp -> {
127+
assertVersion(comp, "2.0");
114128
assertDependencies(comp);
115129
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
116130
});
117131

118132
expectMavenComponent(artifactCoords("my-ext-deployment"), comp -> {
119133
assertNoDistributionPath(comp);
134+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
120135
assertDependencies(comp,
121136
artifactCoords("my-ext"),
122137
artifactCoords("other-lib"));

core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ApplicationManifestMutableJarTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected Properties buildSystemProperties() {
5050
public void initExpectedComponents() {
5151
expectMavenComponent(artifactCoords("app"), comp -> {
5252
assertDistributionPath(comp, "app/quarkus-application.jar");
53+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
5354
assertDependencies(comp,
5455
artifactCoords("acme-lib"),
5556
artifactCoords("other-lib"),
@@ -60,79 +61,93 @@ public void initExpectedComponents() {
6061

6162
expectMavenComponent(artifactCoords("acme-lib"), comp -> {
6263
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-lib-1.jar");
64+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
6365
assertDependencies(comp, artifactCoords("acme-common"));
6466
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
6567
});
6668

6769
expectMavenComponent(artifactCoords("acme-common"), comp -> {
6870
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-common-1.jar");
71+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
6972
assertDependencies(comp, artifactCoords("acme-transitive"));
7073
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
7174
});
7275

7376
expectMavenComponent(artifactCoords("acme-transitive"), comp -> {
7477
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-transitive-1.jar");
78+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
7579
assertDependencies(comp);
7680
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
7781
});
7882

7983
expectMavenComponent(artifactCoords("other-lib"), comp -> {
8084
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.other-lib-1.jar");
85+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
8186
assertDependencies(comp, artifactCoords("acme-common"));
8287
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
8388
});
8489

8590
expectMavenComponent(artifactCoords("my-lib"), comp -> {
8691
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.my-lib-1.jar");
92+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
8793
assertDependencies(comp, artifactCoords("acme-common"));
8894
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
8995
});
9096

9197
expectMavenComponent(artifactCoords("my-ext"), comp -> {
9298
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.my-ext-1.jar");
99+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
93100
assertDependencies(comp, artifactCoords("my-lib"));
94101
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
95102
});
96103

97104
expectFileComponent("quarkus-run.jar", comp -> {
105+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
98106
assertDependencies(comp, artifactCoords("app"));
99107
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
100108
});
101109

102110
expectFileComponent("quarkus/generated-bytecode.jar", comp -> {
111+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
103112
assertDependencies(comp);
104113
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
105114
});
106115

107116
expectFileComponent("quarkus/quarkus-application.dat", comp -> {
117+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
108118
assertDependencies(comp);
109119
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
110120
});
111121

112122
expectFileComponent("quarkus-app-dependencies.txt", comp -> {
123+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
113124
assertDependencies(comp);
114125
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
115126
});
116127

117128
expectFileComponent("quarkus/build-system.properties", comp -> {
129+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
118130
assertDependencies(comp);
119131
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
120132
});
121133

122134
expectMavenComponent(artifactCoords("my-ext-deployment"), comp -> {
123135
assertDistributionPath(comp, "lib/deployment/io.quarkus.bootstrap.test.my-ext-deployment-1.jar");
136+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
124137
assertDependencyScope(comp, ApplicationComponent.SCOPE_DEVELOPMENT);
125138
assertDependencies(comp,
126139
artifactCoords("my-ext"),
127140
artifactCoords("other-lib"));
128141
});
129142

130143
expectFileComponent("lib/deployment/appmodel.dat", comp -> {
144+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
131145
assertDependencies(comp);
132146
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
133147
});
134148

135149
expectFileComponent("lib/deployment/deployment-class-path.dat", comp -> {
150+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
136151
assertDependencies(comp);
137152
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
138153
});

core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ApplicationManifestTestBase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ protected static void assertNoDistributionPath(ApplicationComponent comp) {
7575
.as(() -> ApplicationManifestTestBase.getComponentKey(comp) + " is not found in the distribution").isNull();
7676
}
7777

78+
protected static void assertVersion(ApplicationComponent comp, String expectedVersion) {
79+
assertThat(comp.getVersion())
80+
.as(() -> ApplicationManifestTestBase.getComponentKey(comp) + " has version")
81+
.isEqualTo(expectedVersion);
82+
}
83+
7884
protected static void assertDependencies(ApplicationComponent comp, ArtifactCoords... expectedDeps) {
7985
assertThat(toArtifactCoordsList(comp.getDependencies()))
8086
.as(() -> ApplicationManifestTestBase.getComponentKey(comp) + " has dependencies")

core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ApplicationManifestUberJarTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected Properties buildSystemProperties() {
5050
public void initExpectedComponents() {
5151
expectMavenComponent(artifactCoords("app", "runner"), comp -> {
5252
assertNoDistributionPath(comp);
53+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
5354
assertDependencies(comp,
5455
artifactCoords("acme-lib"),
5556
artifactCoords("other-lib"),
@@ -60,42 +61,49 @@ public void initExpectedComponents() {
6061

6162
expectMavenComponent(artifactCoords("acme-lib"), comp -> {
6263
assertNoDistributionPath(comp);
64+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
6365
assertDependencies(comp, artifactCoords("acme-common"));
6466
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
6567
});
6668

6769
expectMavenComponent(artifactCoords("acme-common"), comp -> {
6870
assertNoDistributionPath(comp);
71+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
6972
assertDependencies(comp, artifactCoords("acme-transitive"));
7073
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
7174
});
7275

7376
expectMavenComponent(artifactCoords("acme-transitive"), comp -> {
7477
assertNoDistributionPath(comp);
78+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
7579
assertDependencies(comp);
7680
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
7781
});
7882

7983
expectMavenComponent(artifactCoords("other-lib"), comp -> {
8084
assertNoDistributionPath(comp);
85+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
8186
assertDependencies(comp, artifactCoords("acme-common"));
8287
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
8388
});
8489

8590
expectMavenComponent(artifactCoords("my-lib"), comp -> {
8691
assertNoDistributionPath(comp);
92+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
8793
assertDependencies(comp, artifactCoords("acme-common"));
8894
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
8995
});
9096

9197
expectMavenComponent(artifactCoords("my-ext"), comp -> {
9298
assertNoDistributionPath(comp);
99+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
93100
assertDependencies(comp, artifactCoords("my-lib"));
94101
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
95102
});
96103

97104
expectMavenComponent(artifactCoords("my-ext-deployment"), comp -> {
98105
assertNoDistributionPath(comp);
106+
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
99107
assertDependencies(comp,
100108
artifactCoords("my-ext"),
101109
artifactCoords("other-lib"));

0 commit comments

Comments
 (0)