Skip to content

Commit

Permalink
#47 - Added configurable license text support
Browse files Browse the repository at this point in the history
  • Loading branch information
stevespringett committed Feb 7, 2020
1 parent 2c8f58d commit 53f95ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Maven Usage
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
</plugin>
</plugins>
```
Expand All @@ -35,7 +35,7 @@ Default Values
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
<executions>
<execution>
<phase>verify</phase>
Expand All @@ -52,6 +52,7 @@ Default Values
<includeRuntimeScope>true</includeRuntimeScope>
<includeSystemScope>true</includeSystemScope>
<includeTestScope>false</includeTestScope>
<includeLicenseText>true</includeLicenseText>
<includeDependencyGraph>true</includeDependencyGraph>
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<dependency>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-core-java</artifactId>
<version>2.6.4</version>
<version>2.6.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo {
@Parameter(property = "includeDependencyGraph", defaultValue = "true", required = false)
private Boolean includeDependencyGraph;

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

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

Expand Down Expand Up @@ -234,6 +237,16 @@ public Boolean getIncludeDependencyGraph() {
return includeDependencyGraph;
}

/**
* Returns if license text should be included in bom.
*
* @return true if license text should be included, otherwise false
*/
public Boolean getIncludeLicenseText() {
return includeLicenseText;
}


/**
* Returns if excluded types are defined.
*
Expand Down Expand Up @@ -448,7 +461,7 @@ private LicenseChoice resolveMavenLicenses(final List<org.apache.maven.model.Lic
for (org.apache.maven.model.License artifactLicense : projectLicenses) {
boolean resolved = false;
if (artifactLicense.getName() != null) {
final LicenseChoice resolvedByName = LicenseResolver.resolve(artifactLicense.getName());
final LicenseChoice resolvedByName = LicenseResolver.resolve(artifactLicense.getName(), includeLicenseText);
if (resolvedByName != null) {
if (resolvedByName.getLicenses() != null && !resolvedByName.getLicenses().isEmpty()) {
resolved = true;
Expand All @@ -460,7 +473,7 @@ private LicenseChoice resolveMavenLicenses(final List<org.apache.maven.model.Lic
}
}
if (artifactLicense.getUrl() != null && !resolved) {
final LicenseChoice resolvedByUrl = LicenseResolver.resolve(artifactLicense.getUrl());
final LicenseChoice resolvedByUrl = LicenseResolver.resolve(artifactLicense.getUrl(), includeLicenseText);
if (resolvedByUrl != null) {
if (resolvedByUrl.getLicenses() != null && !resolvedByUrl.getLicenses().isEmpty()) {
resolved = true;
Expand Down Expand Up @@ -701,6 +714,8 @@ protected void logParameters() {
getLog().info("includeRuntimeScope : " + includeRuntimeScope);
getLog().info("includeTestScope : " + includeTestScope);
getLog().info("includeSystemScope : " + includeSystemScope);
getLog().info("includeLicenseText : " + includeLicenseText);
getLog().info("includeDependencyGraph : " + includeDependencyGraph);
getLog().info("------------------------------------------------------------------------");
}
}
Expand Down

0 comments on commit 53f95ce

Please sign in to comment.