Skip to content

Commit 990e7ff

Browse files
committedMay 31, 2024
build: Publish SBOMs
1 parent a2ee9fe commit 990e7ff

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed
 

‎build.gradle

+41-17
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,51 @@ allprojects {
106106
repositories {
107107
mavenLocal()
108108
}
109+
110+
tasks.withType(GenerateModuleMetadata) {
111+
enabled = false
112+
}
113+
114+
tasks.withType(JavaCompile) {
115+
options.encoding = 'UTF-8'
116+
}
109117
}
110118

111-
idea {
112-
project {
113-
jdkName sourceCompatibility
114-
languageLevel sourceCompatibility
119+
profiles {
120+
profile('sbom') {
121+
activation {
122+
property {
123+
key = 'sbom'
124+
value = true
125+
}
126+
}
127+
action {
128+
println 'SBOM generation is turned ON'
129+
130+
gradleProjects {
131+
subprojects {
132+
dirs(['subprojects']) {
133+
cyclonedxBom {
134+
includeConfigs = ['runtimeClasspath']
135+
projectType = 'library'
136+
outputName = "${project.name}-${project.version}-cyclonedx".toString()
137+
destination = file('build/reports/cyclonedx')
138+
includeLicenseText = false
139+
}
115140

116-
ipr {
117-
withXml { provider ->
118-
def node = provider.asNode()
119-
node.component.find { it.'@name' == 'VcsDirectoryMappings' }?.mapping[0].'@vcs' = 'Git'
141+
publishing {
142+
publications {
143+
main(MavenPublication) {
144+
artifact classifier: 'cyclonedx', source: new File(cyclonedxBom.destination.get(), cyclonedxBom.outputName.get() + '.xml')
145+
artifact classifier: 'cyclonedx', source: new File(cyclonedxBom.destination.get(), cyclonedxBom.outputName.get() + '.json')
146+
}
147+
}
148+
}
120149

121-
def compilerConfiguration = node.component.find { it.'@name' == 'CompilerConfiguration' }
122-
compilerConfiguration.remove(compilerConfiguration.annotationProcessing)
123-
compilerConfiguration.append(new XmlParser().parseText("""
124-
<annotationProcessing>
125-
<profile default="true" name="Default" enabled="true">
126-
<processorPath useClasspath="true" />
127-
</profile>
128-
</annotationProcessing>"""))
150+
project.generatePomFileForMainPublication.dependsOn(cyclonedxBom)
151+
}
152+
}
129153
}
130154
}
131155
}
132-
}
156+
}

‎gradle.properties

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ group = org.kordamp.json
2020
sourceCompatibility = 1.8
2121
targetCompatibility = 1.8
2222

23-
previousVersion = 3.0.1
24-
2523
commonsLangVersion = 3.9
2624
commonsBeanutilsVersion = 1.9.3
2725
commonsCollections4Version = 4.4
@@ -36,6 +34,7 @@ xomVersion = 1.3.8
3634
kordampPluginVersion = 0.54.0
3735
kordampBuildVersion = 3.4.0
3836
gitPluginVersion = 3.0.0
37+
cyclonedxPluginVersion = 1.8.2
3938

4039
org.gradle.daemon = true
4140
org.gradle.caching = true

‎settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ buildscript {
3535
}
3636
dependencies {
3737
classpath "org.kordamp.gradle:kordamp-parentbuild:$kordampBuildVersion"
38+
classpath "org.cyclonedx:cyclonedx-gradle-plugin:$cyclonedxPluginVersion"
3839
}
3940
}
4041
apply plugin: 'org.kordamp.gradle.kordamp-parentbuild'
@@ -53,6 +54,7 @@ projects {
5354
}
5455
dirs(['subprojects']) {
5556
id 'java-library'
57+
id 'org.cyclonedx.bom'
5658
}
5759
}
5860
}

0 commit comments

Comments
 (0)