Skip to content

Commit

Permalink
Merge pull request #508 from jwgmeligmeyling/issues/506-507
Browse files Browse the repository at this point in the history
Make sarifOutputDirectory and sarifOutputFilename configurable
  • Loading branch information
hazendaz committed Nov 6, 2022
2 parents f01a7f6 + e148e19 commit 24a8bb2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
@Parameter(defaultValue = "false", property = "spotbugs.sarifFullPath", required = true)
boolean sarifFullPath

/**
* Specifies the directory where the sarif output will be generated.
*
* @since 4.7.2.2
*/
@Parameter(defaultValue = '${project.build.directory}', property = "spotbugs.sarifOutputDirectory", required = true)
File sarifOutputDirectory


/**
* Set the name of the output SARIF file produced
*
* @since 4.7.2.2
*/
@Parameter(property = "spotbugs.sarifOutputFilename", defaultValue = "spotbugsSarif.json", required = true)
String sarifOutputFilename

/**
* Specifies the directory where the xml output will be generated.
*
Expand Down Expand Up @@ -1122,7 +1139,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {

File xmlTempFile = new File("${project.build.directory}/spotbugsTemp.xml")
File sarifTempFile = new File("${project.build.directory}/spotbugsTempSarif.json")
File sarifFinalFile = new File("${project.build.directory}/spotbugsSarif.json")
File sarifFinalFile = new File(sarifOutputDirectory, sarifOutputFilename)

if (xmlOutput || !sarifOutput) {
forceFileCreation(xmlTempFile)
Expand Down Expand Up @@ -1312,6 +1329,8 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
}
}

forceFileCreation(sarifFinalFile)

sarifFinalFile.withWriter {
builder.writeTo(it)
}
Expand Down

0 comments on commit 24a8bb2

Please sign in to comment.