From 6f5ffccfd25ae3fde0ce1f1f1e59faf7380a74ae Mon Sep 17 00:00:00 2001 From: Leif Lislegard Date: Thu, 10 Feb 2022 17:37:04 +0100 Subject: [PATCH] Added metadata filtering of tool used for SBOM production The SBOM format has a section for identifying tool used to produce the file - this was previously left empty. --- build.gradle | 17 ++++++++++++++++- .../filter/cyclonedx-gradle-plugin.properties | 7 +++++++ .../org/cyclonedx/gradle/CycloneDxTask.java | 4 ++-- src/main/resources/plugin.properties | 7 ------- 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 src/main/filter/cyclonedx-gradle-plugin.properties delete mode 100644 src/main/resources/plugin.properties diff --git a/build.gradle b/build.gradle index c86483c8..16918447 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ - plugins { id 'java-gradle-plugin' id 'com.gradle.plugin-publish' version '0.12.0' @@ -35,6 +34,22 @@ tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } +def pluginProperties = [ + 'vendor': 'CycloneDX', + 'name': 'CycloneDX Gradle plugin', + 'version': project.version, + 'groupId': project.group, + 'artifactId': project.name, +] as Properties + +def filterPluginProperties = tasks.register('filterPluginProperties', Copy) { + destinationDir = file("$buildDir/resources/filter") + inputs.properties pluginProperties + from('src/main/filter') + expand(pluginProperties) +} +sourceSets.main.resources.srcDirs filterPluginProperties + pluginBundle { website = 'https://cyclonedx.org' vcsUrl = 'https://github.com/CycloneDX/cyclonedx-gradle-plugin.git' diff --git a/src/main/filter/cyclonedx-gradle-plugin.properties b/src/main/filter/cyclonedx-gradle-plugin.properties new file mode 100644 index 00000000..6fd52927 --- /dev/null +++ b/src/main/filter/cyclonedx-gradle-plugin.properties @@ -0,0 +1,7 @@ +# Automatically populated by Gradle build - do not modify +vendor=${vendor} +name=${name} +version=${version} +groupId=${groupId} +artifactId=${artifactId} +timestamp=${System.currentTimeMillis()} diff --git a/src/main/java/org/cyclonedx/gradle/CycloneDxTask.java b/src/main/java/org/cyclonedx/gradle/CycloneDxTask.java index 356df907..7d0350e9 100644 --- a/src/main/java/org/cyclonedx/gradle/CycloneDxTask.java +++ b/src/main/java/org/cyclonedx/gradle/CycloneDxTask.java @@ -280,9 +280,9 @@ protected Metadata createMetadata() { private Properties readPluginProperties() { final Properties props = new Properties(); try { - props.load(this.getClass().getClassLoader().getResourceAsStream("plugin.properties")); + props.load(this.getClass().getClassLoader().getResourceAsStream("cyclonedx-gradle-plugin.properties")); } catch (NullPointerException | IOException e) { - getLogger().warn("Unable to load plugin.properties", e); + getLogger().warn("cyclonedx-gradle-plugin.properties", e); } return props; } diff --git a/src/main/resources/plugin.properties b/src/main/resources/plugin.properties deleted file mode 100644 index 1e2dfc39..00000000 --- a/src/main/resources/plugin.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Automatically populated by Maven build - do not modify -vendor=${project.organization.name} -name=${project.name} -groupId=${project.groupId} -artifactId=${project.artifactId} -version=${project.version} -timestamp=${timestamp}