Configure SBOM should return artifact
This commit is contained in:
committed by
Space Team
parent
1e4f78dcff
commit
02de693a12
@@ -1,5 +1,5 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.PublishArtifact
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.spdx.sbom.gradle.SpdxSbomExtension
|
||||
@@ -14,7 +14,7 @@ import java.util.*
|
||||
fun Project.configureSbom(
|
||||
moduleName: String = this.name,
|
||||
gradleConfigurations: Iterable<String> = setOf("runtimeClasspath"),
|
||||
): Configuration {
|
||||
): PublishArtifact {
|
||||
val project = this
|
||||
apply<SpdxSbomPlugin>()
|
||||
|
||||
@@ -44,12 +44,12 @@ fun Project.configureSbom(
|
||||
isCanBeConsumed = true
|
||||
}
|
||||
val sbomFile = layout.buildDirectory.file("spdx/$moduleName.spdx.json")
|
||||
artifacts.add(sbomCfg.name, sbomFile.get().asFile) {
|
||||
val sbomArtifact = artifacts.add(sbomCfg.name, sbomFile.get().asFile) {
|
||||
type = "sbom"
|
||||
extension = "spdx.json"
|
||||
val capitalizedModuleName =
|
||||
moduleName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||
builtBy("spdxSbomFor$capitalizedModuleName")
|
||||
}
|
||||
return sbomCfg
|
||||
return sbomArtifact
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ ext.configurePublishing = { Project project, configure = { } ->
|
||||
}
|
||||
}
|
||||
|
||||
ext.configureSbom = { Project project, Iterable<String> gradleConfigurations = ["runtimeClasspath"] ->
|
||||
SbomKt.configureSbom(project, gradleConfigurations)
|
||||
ext.configureSbom = { Project project, String moduleName = project.name, Iterable<String> gradleConfigurations = ["runtimeClasspath"] ->
|
||||
SbomKt.configureSbom(project, moduleName, gradleConfigurations)
|
||||
}
|
||||
|
||||
ext.configureFrontendIr = { Project project ->
|
||||
|
||||
@@ -431,7 +431,7 @@ val distJs = distTask<Sync>("distJs") {
|
||||
}
|
||||
|
||||
val compilerZipSbomName = "kotlin-compiler-zip"
|
||||
val compilerZipSbom = configureSbom(
|
||||
val sbom = configureSbom(
|
||||
moduleName = compilerZipSbomName,
|
||||
gradleConfigurations = setOf("runtimeClasspath", libraries.name, librariesStripVersion.name, compilerPlugins.name)
|
||||
)
|
||||
@@ -443,10 +443,11 @@ distTask<Copy>("dist") {
|
||||
dependsOn(distCommon)
|
||||
dependsOn(distMaven)
|
||||
dependsOn(distJs)
|
||||
dependsOn("spdxSbomForKotlin-compiler-zip")
|
||||
|
||||
from(buildNumber)
|
||||
from(distStdlibMinimalForTests)
|
||||
from(compilerZipSbom.artifacts.files) {
|
||||
from(sbom.file) {
|
||||
rename("$compilerZipSbomName.spdx.json", "${project.name}-${project.version}.spdx.json")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user