Skip to content

Commit 20b7eff

Browse files
Run makeBOM after aggregateBOM (#5140)
* Run makeBOM after aggregateBOM * Fix tests
1 parent 033a429 commit 20b7eff

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

cmd/mavenBuild.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ func runMavenBuild(config *mavenBuildOptions, telemetryData *telemetry.CustomDat
109109
}
110110

111111
if config.CreateBOM {
112-
// Separate run for makeBOM goal
113-
if err := runMakeBOMGoal(config, utils); err != nil {
114-
return errors.Wrap(err, "failed to execute makeBOM goal")
115-
}
116-
117112
// Append the makeAggregateBOM goal to the rest of the goals
118113
goals = append(goals, "org.cyclonedx:cyclonedx-maven-plugin:2.7.8:makeAggregateBom")
119114
createBOMConfig := []string{
@@ -143,6 +138,13 @@ func runMavenBuild(config *mavenBuildOptions, telemetryData *telemetry.CustomDat
143138
return errors.Wrapf(err, "failed to execute maven build for goal(s) '%v'", goals)
144139
}
145140

141+
if config.CreateBOM {
142+
// Separate run for makeBOM goal
143+
if err := runMakeBOMGoal(config, utils); err != nil {
144+
return errors.Wrap(err, "failed to execute makeBOM goal")
145+
}
146+
}
147+
146148
log.Entry().Debugf("creating build settings information...")
147149
stepName := "mavenBuild"
148150
dockerImage, err := GetDockerImageValue(stepName)

cmd/mavenBuild_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func TestMavenBuild(t *testing.T) {
5555
assert.Nil(t, err)
5656
if assert.Equal(t, 2, len(mockedUtils.Calls), "Expected two Maven invocations (default + makeAggregateBom)") {
5757
assert.Equal(t, "mvn", mockedUtils.Calls[1].Exec)
58-
assert.Contains(t, mockedUtils.Calls[1].Params, "org.cyclonedx:cyclonedx-maven-plugin:2.7.8:makeAggregateBom")
59-
assert.Contains(t, mockedUtils.Calls[1].Params, "-DoutputName=bom-maven")
58+
assert.Contains(t, mockedUtils.Calls[0].Params, "org.cyclonedx:cyclonedx-maven-plugin:2.7.8:makeAggregateBom")
59+
assert.Contains(t, mockedUtils.Calls[0].Params, "-DoutputName=bom-maven")
6060
}
6161
})
6262

0 commit comments

Comments
 (0)