Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -0,0 +1,27 @@
package io.quarkus.deployment.sbom;

import java.util.Collection;

import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.sbom.ApplicationManifest;

/**
* Application manifests collected in a build
*/
public final class ApplicationManifestsBuildItem extends SimpleBuildItem {

private final Collection<ApplicationManifest> manifests;

public ApplicationManifestsBuildItem(Collection<ApplicationManifest> manifests) {
this.manifests = manifests;
}

/**
* Application manifests from which SBOMs can be generated.
*
* @return collected application manifests
*/
public Collection<ApplicationManifest> getManifests() {
return manifests;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkus.deployment.sbom;

import java.util.ArrayList;
import java.util.List;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem;
import io.quarkus.sbom.ApplicationManifest;

public class ApplicationManifestsBuildStep {

/**
* Aggregates application manifest configurations and creates application manifests from which
* SBOMs could be generated by SBOM generating build steps.
*
* @param artifactResultBuildItems artifact results
* @return application manifests for SBOM generation
*/
@BuildStep
public ApplicationManifestsBuildItem generate(List<ArtifactResultBuildItem> artifactResultBuildItems) {
final List<ApplicationManifest> manifests = new ArrayList<>(artifactResultBuildItems.size());
for (var artifactResult : artifactResultBuildItems) {
var manifestConfig = artifactResult.getManifestConfig();
if (manifestConfig != null) {
manifests.add(ApplicationManifest.fromConfig(manifestConfig));
}
}
return new ApplicationManifestsBuildItem(List.copyOf(manifests));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package io.quarkus.deployment.runnerjar;

import java.util.Properties;

import org.junit.jupiter.api.BeforeEach;

import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.sbom.ApplicationComponent;

public class ApplicationManifestFastJarTest extends ApplicationManifestTestBase {

@Override
protected TsArtifact composeApplication() {

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

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

var acmeLib = TsArtifact.jar("acme-lib")
.addDependency(acmeCommon);

var otherLib = TsArtifact.jar("other-lib");
otherLib.addDependency(acmeCommon);

var myLib = TsArtifact.jar("my-lib");
myLib.addDependency(acmeCommon);

var myExt = new TsQuarkusExt("my-ext");
myExt.getRuntime().addDependency(myLib);
myExt.getDeployment().addDependency(otherLib);

return TsArtifact.jar("app")
.addManagedDependency(platformDescriptor())
.addManagedDependency(platformProperties())
.addDependency(acmeLib)
.addDependency(otherLib)
.addDependency(myExt);
}

@Override
protected Properties buildSystemProperties() {
var props = new Properties();
props.setProperty("quarkus.package.jar.type", "fast-jar");
return props;
}

@BeforeEach
public void initExpectedComponents() {

expectMavenComponent(artifactCoords("app"), comp -> {
assertDistributionPath(comp, "app/quarkus-application.jar");
assertDependencies(comp,
artifactCoords("acme-lib"),
artifactCoords("other-lib"),
artifactCoords("my-ext"),
artifactCoords("my-ext-deployment"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectMavenComponent(artifactCoords("acme-lib"), comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-lib-1.jar");
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");
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");
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"));
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"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

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

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

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

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

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

expectMavenComponent(artifactCoords("my-ext-deployment"), comp -> {
assertNoDistributionPath(comp);
assertDependencies(comp,
artifactCoords("my-ext"),
artifactCoords("other-lib"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_DEVELOPMENT);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package io.quarkus.deployment.runnerjar;

import java.util.Properties;

import org.junit.jupiter.api.BeforeEach;

import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.sbom.ApplicationComponent;

public class ApplicationManifestMutableJarTest extends ApplicationManifestTestBase {

@Override
protected TsArtifact composeApplication() {

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

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

var acmeLib = TsArtifact.jar("acme-lib")
.addDependency(acmeCommon);

var otherLib = TsArtifact.jar("other-lib");
otherLib.addDependency(acmeCommon);

var myLib = TsArtifact.jar("my-lib");
myLib.addDependency(acmeCommon);

var myExt = new TsQuarkusExt("my-ext");
myExt.getRuntime().addDependency(myLib);
myExt.getDeployment().addDependency(otherLib);

return TsArtifact.jar("app")
.addManagedDependency(platformDescriptor())
.addManagedDependency(platformProperties())
.addDependency(acmeLib)
.addDependency(otherLib)
.addDependency(myExt);
}

@Override
protected Properties buildSystemProperties() {
var props = new Properties();
props.setProperty("quarkus.package.jar.type", "mutable-jar");
return props;
}

@BeforeEach
public void initExpectedComponents() {
expectMavenComponent(artifactCoords("app"), comp -> {
assertDistributionPath(comp, "app/quarkus-application.jar");
assertDependencies(comp,
artifactCoords("acme-lib"),
artifactCoords("other-lib"),
artifactCoords("my-ext"),
artifactCoords("my-ext-deployment"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

expectMavenComponent(artifactCoords("acme-lib"), comp -> {
assertDistributionPath(comp, "lib/main/io.quarkus.bootstrap.test.acme-lib-1.jar");
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");
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");
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"));
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"));
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});

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

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

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

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

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

expectFileComponent("quarkus/build-system.properties", comp -> {
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");
assertDependencyScope(comp, ApplicationComponent.SCOPE_DEVELOPMENT);
assertDependencies(comp,
artifactCoords("my-ext"),
artifactCoords("other-lib"));
});

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

expectFileComponent("lib/deployment/deployment-class-path.dat", comp -> {
assertDependencies(comp);
assertDependencyScope(comp, ApplicationComponent.SCOPE_RUNTIME);
});
}
}
Loading
Loading