Skip to content

Commit 1039975

Browse files
authored
Merge pull request #279 from CycloneDX/outputDirectory
add outputDirectory parameter
2 parents 4436ada + 3f5656e commit 1039975

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Default Values
5757
<outputReactorProjects>true</outputReactorProjects>
5858
<outputFormat>all</outputFormat>
5959
<outputName>bom</outputName>
60+
<outputDirectory>${project.build.directory}</outpuDirectory><!-- usually target, if not redefined in pom.xml -->
6061
<verbose>true</verbose><!-- = ${cyclonedx.verbose} -->
6162
</configuration>
6263
</plugin>

src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,21 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo {
9999
private String outputFormat;
100100

101101
/**
102-
* The CycloneDX output file name (without extension) that should be generated (in {@code target/} directory).
102+
* The CycloneDX output file name (without extension) that should be generated (in {@code outputDirectory} directory).
103103
*
104104
* @since 2.2.0
105105
*/
106106
@Parameter(property = "outputName", defaultValue = "bom", required = false)
107107
private String outputName;
108108

109+
/**
110+
* The output directory where to store generated CycloneDX output files.
111+
*
112+
* @since 2.7.5
113+
*/
114+
@Parameter(defaultValue = "${project.build.directory}", required = false)
115+
private File outputDirectory;
116+
109117
/**
110118
* Should the resulting BOM contain a unique serial number?
111119
*
@@ -315,7 +323,7 @@ private void saveBom(Bom bom) throws ParserConfigurationException, IOException,
315323
}
316324

317325
private void saveBomToFile(String bomString, String extension, Parser bomParser) throws IOException, MojoExecutionException {
318-
final File bomFile = new File(project.getBasedir(), "target/" + outputName + "." + extension);
326+
final File bomFile = new File(outputDirectory, outputName + "." + extension);
319327

320328
getLog().info(String.format(MESSAGE_WRITING_BOM, extension.toUpperCase(), bomFile.getAbsolutePath()));
321329
FileUtils.write(bomFile, bomString, StandardCharsets.UTF_8, false);

0 commit comments

Comments
 (0)