Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish BOM files to Artifact repository with JAR file, like Maven plugin #388

Open
VinodAnandan opened this issue Jan 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@VinodAnandan
Copy link

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/ )

@vguignot-ingenico
Copy link

vguignot-ingenico commented Mar 7, 2024

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.

@VinodAnandan
Copy link
Author

@vguignot-ingenico Thank you for your response and for sharing this solution, I really appreciate it.

@skhokhlov skhokhlov added the enhancement New feature or request label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants