Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional configuration parameter "includeLicenses". #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Default Values
<includeSystemScope>true</includeSystemScope>
<includeTestScope>false</includeTestScope>
<includeDependencyGraph>true</includeDependencyGraph>
<includeLicenses>true</includeLicenses>
</configuration>
</plugin>
</plugins>
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo {
@Parameter(property = "includeDependencyGraph", defaultValue = "true", required = false)
private Boolean includeDependencyGraph;

@Parameter(property = "includeLicenses", defaultValue = "true", required = false)
private Boolean includeLicenses;

@Parameter(property = "excludeTypes", required = false)
private String[] excludeTypes;

Expand Down Expand Up @@ -357,10 +360,12 @@ private void extractMetadata(MavenProject project, Component component) {
// If we don't already have description information, retrieve it.
component.setDescription(project.getDescription());
}
if (component.getLicenseChoice() == null || component.getLicenseChoice().getLicenses() == null || component.getLicenseChoice().getLicenses().isEmpty()) {
// If we don't already have license information, retrieve it.
if (project.getLicenses() != null) {
component.setLicenseChoice(resolveMavenLicenses(project.getLicenses()));
if (includeLicenses) {
if (component.getLicenseChoice() == null || component.getLicenseChoice().getLicenses() == null || component.getLicenseChoice().getLicenses().isEmpty()) {
// If we don't already have license information, retrieve it.
if (project.getLicenses() != null) {
component.setLicenseChoice(resolveMavenLicenses(project.getLicenses()));
}
}
}
if (CycloneDxSchema.Version.VERSION_10 != schemaVersion()) {
Expand Down Expand Up @@ -681,6 +686,7 @@ protected void logParameters() {
getLog().info("includeRuntimeScope : " + includeRuntimeScope);
getLog().info("includeTestScope : " + includeTestScope);
getLog().info("includeSystemScope : " + includeSystemScope);
getLog().info("includeLicenses : " + includeLicenses);
getLog().info("------------------------------------------------------------------------");
}
}
Expand Down