diff --git a/cmd/mavenBuild.go b/cmd/mavenBuild.go index 45b09e40e1..1b2a340511 100644 --- a/cmd/mavenBuild.go +++ b/cmd/mavenBuild.go @@ -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{ @@ -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) diff --git a/cmd/mavenBuild_test.go b/cmd/mavenBuild_test.go index 3380ecf3cd..ea5e9abdbc 100644 --- a/cmd/mavenBuild_test.go +++ b/cmd/mavenBuild_test.go @@ -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") } })