Skip to content

Commit

Permalink
Run makeBOM after aggregateBOM (#5140)
Browse files Browse the repository at this point in the history
* Run makeBOM after aggregateBOM

* Fix tests
  • Loading branch information
D074360 authored Oct 8, 2024
1 parent 033a429 commit 20b7eff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions cmd/mavenBuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ func runMavenBuild(config *mavenBuildOptions, telemetryData *telemetry.CustomDat
}

if config.CreateBOM {
// Separate run for makeBOM goal
if err := runMakeBOMGoal(config, utils); err != nil {
return errors.Wrap(err, "failed to execute makeBOM goal")
}

// Append the makeAggregateBOM goal to the rest of the goals
goals = append(goals, "org.cyclonedx:cyclonedx-maven-plugin:2.7.8:makeAggregateBom")
createBOMConfig := []string{
Expand Down Expand Up @@ -143,6 +138,13 @@ func runMavenBuild(config *mavenBuildOptions, telemetryData *telemetry.CustomDat
return errors.Wrapf(err, "failed to execute maven build for goal(s) '%v'", goals)
}

if config.CreateBOM {
// Separate run for makeBOM goal
if err := runMakeBOMGoal(config, utils); err != nil {
return errors.Wrap(err, "failed to execute makeBOM goal")
}
}

log.Entry().Debugf("creating build settings information...")
stepName := "mavenBuild"
dockerImage, err := GetDockerImageValue(stepName)
Expand Down
4 changes: 2 additions & 2 deletions cmd/mavenBuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func TestMavenBuild(t *testing.T) {
assert.Nil(t, err)
if assert.Equal(t, 2, len(mockedUtils.Calls), "Expected two Maven invocations (default + makeAggregateBom)") {
assert.Equal(t, "mvn", mockedUtils.Calls[1].Exec)
assert.Contains(t, mockedUtils.Calls[1].Params, "org.cyclonedx:cyclonedx-maven-plugin:2.7.8:makeAggregateBom")
assert.Contains(t, mockedUtils.Calls[1].Params, "-DoutputName=bom-maven")
assert.Contains(t, mockedUtils.Calls[0].Params, "org.cyclonedx:cyclonedx-maven-plugin:2.7.8:makeAggregateBom")
assert.Contains(t, mockedUtils.Calls[0].Params, "-DoutputName=bom-maven")
}
})

Expand Down

0 comments on commit 20b7eff

Please sign in to comment.