Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
package io.quarkus.deployment.pkg.builditem;

import java.util.List;
import java.util.Optional;

import io.quarkus.builder.item.SimpleBuildItem;

/**
* Indicates that a specific container image should be used to generate the AppCDS file
*/
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public final class JvmStartupOptimizerArchiveContainerImageBuildItem extends SimpleBuildItem {

private final String containerImage;
private final Optional<List<String>> additionalJvmArgs;

@Deprecated(forRemoval = true, since = "3.34")
public JvmStartupOptimizerArchiveContainerImageBuildItem(String containerImage) {
this(containerImage, Optional.empty());
}

public JvmStartupOptimizerArchiveContainerImageBuildItem(String containerImage, Optional<List<String>> additionalJvmArgs) {
this.containerImage = containerImage;
this.additionalJvmArgs = additionalJvmArgs;
}

public String getContainerImage() {
return containerImage;
}

public Optional<List<String>> getAdditionalJvmArgs() {
return additionalJvmArgs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public JarBuildItem build() throws IOException {

if (!rebuild) {
manifestConfig.addComponent(ApplicationComponent.builder()
.setResolvedDependency(applicationArchives.getRootArchive().getResolvedDependency())
.setResolvedDependency(appArtifact)
.setPath(runnerJar));
Predicate<String> ignoredEntriesPredicate = getThinJarIgnoredEntriesPredicate(packageConfig);
try (ArchiveCreator archiveCreator = new ParallelCommonsCompressArchiveCreator(runnerJar,
Expand Down Expand Up @@ -271,6 +271,7 @@ public JarBuildItem build() throws IOException {
runnerJar.toFile().setReadable(true, false);
Path initJar = buildDir.resolve(FastJarFormat.QUARKUS_RUN_JAR);
manifestConfig.setMainComponent(ApplicationComponent.builder()
.setVersion(appArtifact.getVersion())
.setPath(initJar)
.setDependencies(List.of(curateOutcome.getApplicationModel().getAppArtifact())))
.setRunnerPath(initJar);
Expand All @@ -285,7 +286,10 @@ public JarBuildItem build() throws IOException {
List<String> lines = Arrays.stream(out.toString(StandardCharsets.UTF_8).split("\n"))
.filter(s -> !s.startsWith("#")).sorted().collect(Collectors.toList());
Path buildSystemProps = quarkus.resolve(FastJarFormat.BUILD_SYSTEM_PROPERTIES);
manifestConfig.addComponent(ApplicationComponent.builder().setPath(buildSystemProps).setDevelopmentScope());
manifestConfig.addComponent(ApplicationComponent.builder()
.setVersion(appArtifact.getVersion())
.setPath(buildSystemProps)
.setDevelopmentScope());
try (OutputStream fileOutput = Files.newOutputStream(buildSystemProps)) {
fileOutput.write(String.join("\n", lines).getBytes(StandardCharsets.UTF_8));
}
Expand Down Expand Up @@ -323,7 +327,10 @@ public JarBuildItem build() throws IOException {
curateOutcome.getApplicationModel(),
packageConfig.jar().userProvidersDirectory().orElse(null), buildDir.relativize(runnerJar).toString());
Path appmodelDat = deploymentLib.resolve(FastJarFormat.APPMODEL_DAT);
manifestConfig.addComponent(ApplicationComponent.builder().setPath(appmodelDat).setDevelopmentScope());
manifestConfig.addComponent(ApplicationComponent.builder()
.setVersion(appArtifact.getVersion())
.setPath(appmodelDat)
.setDevelopmentScope());
try (OutputStream out = Files.newOutputStream(appmodelDat)) {
ObjectOutputStream obj = new ObjectOutputStream(out);
obj.writeObject(model);
Expand All @@ -334,7 +341,10 @@ public JarBuildItem build() throws IOException {
//as we don't really have a resolved bootstrap CP
//once we have the app model it will all be done in QuarkusClassLoader anyway
Path deploymentCp = deploymentLib.resolve(FastJarFormat.DEPLOYMENT_CLASS_PATH_DAT);
manifestConfig.addComponent(ApplicationComponent.builder().setPath(deploymentCp).setDevelopmentScope());
manifestConfig.addComponent(ApplicationComponent.builder()
.setVersion(appArtifact.getVersion())
.setPath(deploymentCp)
.setDevelopmentScope());
try (OutputStream out = Files.newOutputStream(deploymentCp)) {
ObjectOutputStream obj = new ObjectOutputStream(out);
List<String> paths = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,15 @@ public void build(Optional<JvmStartupOptimizerArchiveRequestedBuildItem> request
archivePath = createAppCDSFromExit(jarResult, outputTarget, javaBinPath, containerImage,
isFastJar);
} else if (archiveType == JvmStartupOptimizerArchiveType.AOT) {
archivePath = createAot(jarResult, outputTarget, javaBinPath, containerImage, isFastJar,
packageConfig.jar().aot().additionalRecordingArgs().orElse(List.of()));
List<String> additionalJvmArguments = new ArrayList<>();
if (packageConfig.jar().aot().additionalRecordingArgs().isPresent()) {
additionalJvmArguments.addAll(packageConfig.jar().aot().additionalRecordingArgs().get());
}
if (jvmStartupOptimizerArchiveContainerImage.isPresent()
&& jvmStartupOptimizerArchiveContainerImage.get().getAdditionalJvmArgs().isPresent()) {
additionalJvmArguments.addAll(jvmStartupOptimizerArchiveContainerImage.get().getAdditionalJvmArgs().get());
}
archivePath = createAot(jarResult, outputTarget, javaBinPath, containerImage, isFastJar, additionalJvmArguments);
} else {
throw new IllegalStateException("Unsupported archive type: " + archiveType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ ArtifactResultBuildItem result(NativeImageBuildItem image,
ApplicationManifestConfig.builder()
.setApplicationModel(curateOutcomeBuildItem.getApplicationModel())
.setMainComponent(ApplicationComponent.builder()
.setVersion(curateOutcomeBuildItem.getApplicationModel().getAppArtifact().getVersion())
.setPath(image.getPath())
.setDependencies(List.of(curateOutcomeBuildItem.getApplicationModel().getAppArtifact())))
.setRunnerPath(image.getPath())
Expand Down Expand Up @@ -184,6 +185,7 @@ ArtifactResultBuildItem nativeSourcesResult(NativeConfig nativeConfig,
ApplicationManifestConfig.builder()
.setApplicationModel(curateOutcomeBuildItem.getApplicationModel())
.setMainComponent(ApplicationComponent.builder()
.setVersion(curateOutcomeBuildItem.getApplicationModel().getAppArtifact().getVersion())
.setPath(nativeImageSourceJarBuildItem.getPath())
.setResolvedDependency(curateOutcomeBuildItem.getApplicationModel().getAppArtifact()))
.setRunnerPath(nativeImageSourceJarBuildItem.getPath())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.sbom.ApplicationComponent;

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

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

var acmeCommon = TsArtifact.jar("acme-common")
var acmeCommon = TsArtifact.jar("acme-common", "3.0")
.addDependency(acmeTransitive);

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

return TsArtifact.jar("app")
return TsArtifact.jar("app", "2.0")
.addManagedDependency(platformDescriptor())
.addManagedDependency(platformProperties())
.addDependency(acmeLib)
Expand All @@ -49,8 +50,9 @@ protected Properties buildSystemProperties() {
@BeforeEach
public void initExpectedComponents() {

expectMavenComponent(artifactCoords("app"), comp -> {
expectMavenComponent(ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "app", "2.0"), comp -> {
assertDistributionPath(comp, "app/quarkus-application.jar");
assertVersion(comp, "2.0");
assertDependencies(comp,
artifactCoords("acme-lib"),
artifactCoords("other-lib"),
Expand All @@ -59,64 +61,77 @@ public void initExpectedComponents() {
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

final ArtifactCoords commonsCoords = ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "acme-common", "3.0");

expectMavenComponent(artifactCoords("acme-lib"), comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-lib-1.jar");
assertDependencies(comp, artifactCoords("acme-common"));
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp, commonsCoords);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectMavenComponent(artifactCoords("acme-common"), comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-common-1.jar");
expectMavenComponent(commonsCoords, comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-common-3.0.jar");
assertVersion(comp, "3.0");
assertDependencies(comp, artifactCoords("acme-transitive"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

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

expectMavenComponent(artifactCoords("other-lib"), comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.other-lib-1.jar");
assertDependencies(comp, artifactCoords("acme-common"));
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp, commonsCoords);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectMavenComponent(artifactCoords("my-lib"), comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.my-lib-1.jar");
assertDependencies(comp, artifactCoords("acme-common"));
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp, commonsCoords);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

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

expectFileComponent("quarkus-run.jar", comp -> {
assertDependencies(comp, artifactCoords("app"));
assertVersion(comp, "2.0");
assertDependencies(comp, ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "app", "2.0"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus/generated-bytecode.jar", comp -> {
assertVersion(comp, "2.0");
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus/quarkus-application.dat", comp -> {
assertVersion(comp, "2.0");
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus-app-dependencies.txt", comp -> {
assertVersion(comp, "2.0");
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectMavenComponent(artifactCoords("my-ext-deployment"), comp -> {
assertNoDistributionPath(comp);
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp,
artifactCoords("my-ext"),
artifactCoords("other-lib"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected Properties buildSystemProperties() {
public void initExpectedComponents() {
expectMavenComponent(artifactCoords("app"), comp -> {
assertDistributionPath(comp, "app/quarkus-application.jar");
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp,
artifactCoords("acme-lib"),
artifactCoords("other-lib"),
Expand All @@ -60,79 +61,93 @@ public void initExpectedComponents() {

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

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

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

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

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

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

expectFileComponent("quarkus-run.jar", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp, artifactCoords("app"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus/generated-bytecode.jar", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus/quarkus-application.dat", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus-app-dependencies.txt", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("quarkus/build-system.properties", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectMavenComponent(artifactCoords("my-ext-deployment"), comp -> {
assertDistributionPath(comp, "lib/deployment/io.quarkus.bootstrap.test.my-ext-deployment-1.jar");
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencyScope(comp, ApplicationComponent.SCOPE_DEVELOPMENT);
assertDependencies(comp,
artifactCoords("my-ext"),
artifactCoords("other-lib"));
});

expectFileComponent("lib/deployment/appmodel.dat", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectFileComponent("lib/deployment/deployment-class-path.dat", comp -> {
assertVersion(comp, TsArtifact.DEFAULT_VERSION);
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ protected static void assertNoDistributionPath(ApplicationComponent comp) {
.as(() -> ApplicationManifestTestBase.getComponentKey(comp) + " is not found in the distribution").isNull();
}

protected static void assertVersion(ApplicationComponent comp, String expectedVersion) {
assertThat(comp.getVersion())
.as(() -> ApplicationManifestTestBase.getComponentKey(comp) + " has version")
.isEqualTo(expectedVersion);
}

protected static void assertDependencies(ApplicationComponent comp, ArtifactCoords... expectedDeps) {
assertThat(toArtifactCoordsList(comp.getDependencies()))
.as(() -> ApplicationManifestTestBase.getComponentKey(comp) + " has dependencies")
Expand Down
Loading
Loading