Skip to content

Commit f9d6f95

Browse files
committed
fix: make dependencies reproducible for sbom
1 parent 7a944dd commit f9d6f95

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/SbomPlugin.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,22 @@ class SbomPlugin implements Plugin<Project> {
217217
// components[*].licenses
218218
def comps = (bom instanceof Map && bom.components instanceof List) ? bom.components : []
219219
comps.each { c ->
220-
if (c instanceof Map && c.licenses instanceof List && !(c.licenses as List).isEmpty()) {
220+
if (c instanceof Map && c.licenses instanceof List && !(c.licenses as List).empty) {
221221
def chosen = pickLicense(task, c['bom-ref'] as String, c.licenses as List)
222222
if (chosen != null) {
223223
c.licenses = [chosen]
224224
}
225225
}
226226
}
227227

228+
// dependencies[*].dependsOn is not reproducible, so sort it
229+
def dependencies = (bom instanceof Map && bom.dependencies instanceof List) ? bom.dependencies : []
230+
dependencies.each { d ->
231+
if(d instanceof Map && d.dependsOn instanceof List && !(d.dependsOn as List).empty) {
232+
d.dependsOn = (d.dependsOn as List).sort()
233+
}
234+
}
235+
228236
// force the serialNumber to be reproducible by removing it & recalculating
229237
bom['serialNumber'] = ''
230238
def withOutSerial = JsonOutput.prettyPrint(JsonOutput.toJson(bom))

0 commit comments

Comments
 (0)