@@ -9,7 +9,8 @@ import com.google.cloud.tools.jib.gradle.JibExtension
99import io.gitlab.arturbosch.detekt.Detekt
1010import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension
1111import org.apache.tools.ant.filters.ReplaceTokens
12- import org.cyclonedx.gradle.CycloneDxTask
12+ import org.cyclonedx.gradle.CyclonedxDirectTask
13+ import org.cyclonedx.model.Component.Type.APPLICATION
1314import org.gradle.api.tasks.testing.logging.TestExceptionFormat
1415import org.gradle.api.tasks.testing.logging.TestLogEvent
1516import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -47,7 +48,7 @@ plugins {
4748 id(" io.gitlab.arturbosch.detekt" ) version " 1.23.8"
4849 id(" org.openapi.generator" ) version " 7.13.0" apply false
4950 id(" com.google.cloud.tools.jib" ) version " 3.5.1" apply false
50- id(" org.cyclonedx.bom" ) version " 2. 3.1"
51+ id(" org.cyclonedx.bom" ) version " 3.1.0 "
5152}
5253
5354scmVersion { tag { prefix.set(" " ) } }
@@ -145,13 +146,6 @@ allprojects {
145146 mavenCentral()
146147 }
147148
148- tasks.cyclonedxBom {
149- includeConfigs = listOf (" runtimeClasspath" )
150- outputFormat = " xml" // by default it would also generate json
151- projectType = " application"
152- outputName = " cosmotech-api-bom"
153- }
154-
155149 tasks.withType<HtmlDependencyReportTask >().configureEach { projects = project.allprojects }
156150
157151 configure<SpotlessExtension > {
@@ -182,6 +176,13 @@ allprojects {
182176 }
183177
184178 tasks.withType<JavaCompile >() { options.compilerArgs.add(" -parameters" ) }
179+
180+ tasks.cyclonedxBom {
181+ componentName = " cosmotech-api"
182+ projectType = APPLICATION
183+ jsonOutput.set(file(" build/reports/cosmotech-api-bom.json" ))
184+ xmlOutput.set(file(" build/reports/cosmotech-api-bom.xml" ))
185+ }
185186}
186187
187188subprojects {
@@ -190,6 +191,14 @@ subprojects {
190191 apply (plugin = " org.openapi.generator" )
191192 apply (plugin = " com.google.cloud.tools.jib" )
192193
194+ tasks.cyclonedxDirectBom {
195+ includeConfigs = listOf (" runtimeClasspath" )
196+ projectType = APPLICATION
197+ componentName = project.name
198+ jsonOutput.set(file(" build/reports/sbom/${project.name} -bom.json" ))
199+ xmlOutput.set(file(" build/reports/sbom/${project.name} -bom.xml" ))
200+ }
201+
193202 val projectDirName = projectDir.relativeTo(rootDir).name
194203 val openApiDefinitionFile = file(" ${projectDir} /src/main/openapi/${projectDirName} .yaml" )
195204
@@ -635,7 +644,7 @@ val copySubProjectsDetektReportsTasks =
635644 into(" ${subProject.parent!! .layout.projectDirectory} /build/reports/detekt/$format " )
636645 }
637646 subProject.tasks.getByName(" detekt" ) { finalizedBy(copyTask) }
638- subProject.tasks.withType<CycloneDxTask > { finalizedBy(copyTask) }
647+ subProject.tasks.withType<CyclonedxDirectTask > { finalizedBy(copyTask) }
639648 copyTask
640649 }
641650 }
0 commit comments