Skip to content

Commit cd7ac50

Browse files
committed
Upgrade CycloneDX plugin to 3.1.0 and refactor BOM tasks:
- Updated CycloneDX plugin version from 2.3.1 to 3.1.0 in `build.gradle.kts`. - Replaced `CycloneDxTask` with `CyclonedxDirectTask`. - Added `componentName` and updated output settings for BOM tasks. - Introduced `cyclonedxDirectBom` tasks for subprojects with specific configurations.
1 parent f8e14a5 commit cd7ac50

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

build.gradle.kts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import com.google.cloud.tools.jib.gradle.JibExtension
99
import io.gitlab.arturbosch.detekt.Detekt
1010
import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension
1111
import 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
1314
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
1415
import org.gradle.api.tasks.testing.logging.TestLogEvent
1516
import 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

5354
scmVersion { 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

187188
subprojects {
@@ -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

Comments
 (0)