Skip to content

Commit ae5ddac

Browse files
committed
Update cyclonedx-maven-plugin to 2.9.1 and catch all exceptions for SBOMGenerator.generateIfSupportedAndEnabled
1 parent 5cce16c commit ae5ddac

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
104104
withSample("java-application-with-custom-packaging")
105105
106106
when:
107-
mvnDebug '-DquickBuild', 'package', '-Dpackaging=native-image', 'exec:exec@native'
107+
mvn '-DquickBuild', 'package', '-Dpackaging=native-image', 'exec:exec@native'
108108
109109
then:
110110
buildSucceeded

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/SBOMFunctionalTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class SBOMFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
9797
outputContains "Hello, native!"
9898
}
9999

100-
def deleteTargetDir() {
100+
private def deleteTargetDir() {
101101
file("target").deleteDir()
102102
}
103103

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeCompileNoForkMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ private void generateBaseSBOMIfNeeded() throws MojoExecutionException {
128128
return;
129129
}
130130

131-
var sbomGenerator = new SBOMGenerator(mavenProject, mavenSession, pluginManager, repositorySystem, mainClass, logger);
131+
var sbomGenerator = new SBOMGenerator(mavenProject, mavenSession, pluginManager, repositorySystem, mainClass);
132132
var config = new SBOMGenerator.Config(isOracleGraalVM(logger), getBuildArgs(), NativeImageUtils.getMajorJDKVersion(getVersionInformation(logger)));
133133
try {
134134
sbomGenerator.generateIfSupportedAndEnabled(config);
135-
} catch (MojoExecutionException e) {
135+
} catch (Exception e) {
136136
logger.warn(String.format("Could not generate base SBOM: %s. Fallback to generating an SBOM without knowledge from 'native-build-tools'.",
137137
e.getCause().getMessage()));
138138
}

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/sbom/SBOMGenerator.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.apache.maven.plugin.BuildPluginManager;
4747
import org.apache.maven.plugin.MojoExecutionException;
4848
import org.apache.maven.project.MavenProject;
49-
import org.codehaus.plexus.logging.Logger;
5049
import org.eclipse.aether.RepositorySystem;
5150

5251
import java.io.IOException;
@@ -104,7 +103,6 @@ public final class SBOMGenerator {
104103
private final BuildPluginManager pluginManager;
105104
private final RepositorySystem repositorySystem;
106105
private final String mainClass;
107-
private final Logger logger;
108106

109107
private static final String SBOM_NATIVE_IMAGE_FLAG = "--enable-sbom";
110108
private static final String SBOM_FILE_FORMAT = "json";
@@ -135,7 +133,7 @@ private static final class AddedComponentFields {
135133
private static final class Plugin {
136134
static final String artifactId = "cyclonedx-maven-plugin";
137135
static final String groupId = "org.cyclonedx";
138-
static final String version = "2.8.1";
136+
static final String version = "2.9.1";
139137
static final String goal = "makeAggregateBom";
140138

141139
private static final class Configuration {
@@ -151,14 +149,12 @@ public SBOMGenerator(
151149
MavenSession mavenSession,
152150
BuildPluginManager pluginManager,
153151
RepositorySystem repositorySystem,
154-
String mainClass,
155-
Logger logger) {
152+
String mainClass) {
156153
this.mavenProject = mavenProject;
157154
this.mavenSession = mavenSession;
158155
this.pluginManager = pluginManager;
159156
this.repositorySystem = repositorySystem;
160157
this.mainClass = mainClass;
161-
this.logger = logger;
162158
this.outputDirectory = mavenProject.getBuild().getDirectory();
163159
}
164160

@@ -185,9 +181,6 @@ public void generateIfSupportedAndEnabled(Config config) throws MojoExecutionExc
185181

186182
Path sbomPath = Paths.get(outputDirectory, SBOM_FILENAME);
187183
try {
188-
/* Suppress the output from the plugin. */
189-
int loggingLevel = logger.getThreshold();
190-
logger.setThreshold(Logger.LEVEL_DISABLED);
191184
executeMojo(
192185
plugin(
193186
groupId(Plugin.groupId),
@@ -204,7 +197,6 @@ public void generateIfSupportedAndEnabled(Config config) throws MojoExecutionExc
204197
),
205198
executionEnvironment(mavenProject, mavenSession, pluginManager)
206199
);
207-
logger.setThreshold(loggingLevel);
208200

209201
if (!Files.exists(sbomPath)) {
210202
return;

0 commit comments

Comments
 (0)