Skip to content

Commit

Permalink
Provide filter by group IDs
Browse files Browse the repository at this point in the history
Provides a new parameter excludeGroupId to exclude all artifacts of
specific group IDs, similar to excludeArtifactId.
  • Loading branch information
synaos-bwi committed Nov 8, 2022
1 parent acd56d3 commit 8e11ad8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ With `makeAggregateBom` goal it is possible to exclude certain Maven Projects (a

* Pass `-DexcludeTestProject=true` to skip any maven project artifactId containing the word "test"
* Pass `-DexcludeArtifactId=comma separated id` to skip based on artifactId
* Pass `-DexcludeGroupId=comma separated id` to skip based on groupId

Goals
-------------------
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo implements Contextu
@Parameter(property = "excludeArtifactId", required = false)
protected String[] excludeArtifactId;

@Parameter(property = "excludeGroupId", required = false)
protected String[] excludeGroupId;

@Parameter(property = "excludeTestProject", defaultValue = "false", required = false)
protected Boolean excludeTestProject;

Expand Down Expand Up @@ -338,6 +341,15 @@ public String[] getExcludeArtifactId() {
return excludeArtifactId;
}

/**
* Returns if excluded GroupId are defined.
*
* @return an array of excluded Group Id
*/
public String[] getExcludeGroupId() {
return excludeGroupId;
}

/**
* Returns if project artifactId with the word test should be excluded in bom.
*
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/cyclonedx/maven/CycloneDxAggregateMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ protected boolean shouldExclude(MavenProject mavenProject) {
if (excludeArtifactId != null && excludeArtifactId.length > 0) {
shouldExclude = Arrays.asList(excludeArtifactId).contains(mavenProject.getArtifactId());
}
if (!shouldExclude && excludeGroupId != null && excludeGroupId.length > 0) {
shouldExclude = Arrays.asList(excludeGroupId).contains(mavenProject.getGroupId());
}
if (excludeTestProject && mavenProject.getArtifactId().contains("test")) {
shouldExclude = true;
}
Expand Down

0 comments on commit 8e11ad8

Please sign in to comment.