cyclonedx-gradle-plugin
cyclonedx-gradle-plugin copied to clipboard
Publish BOM files to Artifact repository with JAR file, like Maven plugin
We should publish the Bill of Materials (BOM) files to the Artifact repository along with the Java Archive (JAR) file, similar to how it's done with the Maven plugin." ( e.g: https://repo1.maven.org/maven2/org/cyclonedx/cyclonedx-maven-plugin/2.7.11/ )
Here is a solution until it'll we added inside the plugin. Place this part of code inside your root build.gradle.kts file:
allprojects {
apply(plugin = "org.cyclonedx.bom")
tasks.cyclonedxBom {
setOutputName("bom")
setOutputFormat("json")
setIncludeBomSerialNumber(true)
setIncludeLicenseText(true)
setComponentVersion("2.0.0")
}
afterEvaluate {
val bomTask = tasks.cyclonedxBom.get()
val bomFile = File(bomTask.outputs.files.singleFile, "${bomTask.outputName.get()}.${bomTask.outputFormat.get()}")
val mavenPublish = extensions.findByName(PublishingExtension.NAME) as? PublishingExtension
mavenPublish?.publications?.filterIsInstance<MavenPublication>()?.forEach { it.artifact(bomFile) { classifier = "bom" } }
tasks.matching { it.group == PublishingExtension.NAME }.configureEach { dependsOn(bomTask) }
}
}
Hope it helps.
@vguignot-ingenico Thank you for your response and for sharing this solution, I really appreciate it.