diff --git a/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ArtifactsMojo.java b/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ArtifactsMojo.java index b815efb..6efdc70 100644 --- a/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ArtifactsMojo.java +++ b/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ArtifactsMojo.java @@ -20,7 +20,9 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; +import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; import java.util.HashSet; import java.util.LinkedList; @@ -145,6 +147,42 @@ public class ArtifactsMojo @Parameter protected String excludeClassifiers; + /** + * Comma-separated list of includes. For all secondary project artifacts matching any of the given includes checksums are generated. + * If not set all secondary project artifacts are considered. + * + * @since 1.11 + */ + @Parameter + protected String groupdIDincludes; + + /** + * Comma-separated list of excludes. For all secondary project artifacts matching any of the given excludes checksums are not generated. + * Takes precedence over {@link #groupdIDincludes}. + * + * @since 1.11 + */ + @Parameter + protected String groupdIDexcludes; + + /** + * Comma-separated list of includes. For all secondary project artifacts matching any of the given includes checksums are generated. + * If not set all secondary project artifacts are considered. + * + * @since 1.11 + */ + @Parameter + protected String artifactIDincludes; + + /** + * Comma-separated list of excludes. For all secondary project artifacts matching any of the given excludes checksums are not generated. + * Takes precedence over {@link #artifactIDincludes}. + * + * @since 1.11 + */ + @Parameter + protected String artifactIDexcludes; + /** * Constructor. */ @@ -177,6 +215,10 @@ protected List getFilesToProcess() Set filteredArtifacts = new HashSet<>(project.getAttachedArtifacts()); ClassifierFilter classifierFilter = new ClassifierFilter( includeClassifiers, excludeClassifiers ); filteredArtifacts = classifierFilter.filter( filteredArtifacts ); + ArtifactIdFilter artifactIDFilter = new ArtifactIdFilter( artifactIDincludes, artifactIDexcludes ); + filteredArtifacts = artifactIDFilter.filter( filteredArtifacts ); + GroupIdFilter groupIdFilter = new GroupIdFilter( groupdIDincludes, groupdIDexcludes ); + filteredArtifacts = groupIdFilter.filter( filteredArtifacts ); for ( Artifact artifact : filteredArtifacts ) { if ( hasValidFile( artifact ) ) @@ -289,4 +331,6 @@ protected String getShasumSummaryFile() { return shasumSummaryFile; } + + } diff --git a/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/DependenciesMojo.java b/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/DependenciesMojo.java index b05fbb4..8e91820 100644 --- a/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/DependenciesMojo.java +++ b/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/DependenciesMojo.java @@ -21,6 +21,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; +import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; import java.util.LinkedList; import java.util.List; @@ -154,6 +156,43 @@ public class DependenciesMojo @Parameter( defaultValue = "false" ) protected boolean transitive; + /** + * Comma-separated list of includes. For all secondary project artifacts matching any of the given includes checksums are generated. + * If not set all secondary project artifacts are considered. + * + * @since 1.11 + */ + @Parameter + protected String groupdIDincludes; + + /** + * Comma-separated list of excludes. For all secondary project artifacts matching any of the given excludes checksums are not generated. + * Takes precedence over {@link #groupdIDincludes}. + * + * @since 1.11 + */ + @Parameter + protected String groupdIDexcludes; + + /** + * Comma-separated list of includes. For all secondary project artifacts matching any of the given includes checksums are generated. + * If not set all secondary project artifacts are considered. + * + * @since 1.11 + */ + @Parameter + protected String artifactIDincludes; + + /** + * Comma-separated list of excludes. For all secondary project artifacts matching any of the given excludes checksums are not generated. + * Takes precedence over {@link #artifactIDincludes}. + * + * @since 1.11 + */ + @Parameter + protected String artifactIDexcludes; + + /** * Constructor. */ @@ -174,7 +213,11 @@ protected List getFilesToProcess() List files = new LinkedList<>(); Set artifacts = transitive ? project.getArtifacts() : project.getDependencyArtifacts(); - for ( Artifact artifact : artifacts ) + ArtifactIdFilter artifactIDFilter = new ArtifactIdFilter( artifactIDincludes, artifactIDexcludes ); + Set filteredArtifacts = artifactIDFilter.filter(artifacts); + GroupIdFilter groupIdFilter = new GroupIdFilter( groupdIDincludes, groupdIDexcludes ); + filteredArtifacts = groupIdFilter.filter( filteredArtifacts ); + for ( Artifact artifact : filteredArtifacts ) { if ( ( scopes == null || scopes.contains( artifact.getScope() ) ) && ( types == null || types.contains( artifact.getType() ) ) && artifact.getFile() != null ) @@ -257,4 +300,5 @@ protected String getShasumSummaryFile() { return shasumSummaryFile; } + }