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 support for include and exclude patterns for project dependencies #113

Open
wants to merge 2 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -177,6 +215,10 @@ protected List<ChecksumFile> getFilesToProcess()
Set<Artifact> 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 ) )
Expand Down Expand Up @@ -289,4 +331,6 @@ protected String getShasumSummaryFile()
{
return shasumSummaryFile;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand All @@ -174,7 +213,11 @@ protected List<ChecksumFile> getFilesToProcess()
List<ChecksumFile> files = new LinkedList<>();

Set<Artifact> artifacts = transitive ? project.getArtifacts() : project.getDependencyArtifacts();
for ( Artifact artifact : artifacts )
ArtifactIdFilter artifactIDFilter = new ArtifactIdFilter( artifactIDincludes, artifactIDexcludes );
Set<Artifact> 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 )
Expand Down Expand Up @@ -257,4 +300,5 @@ protected String getShasumSummaryFile()
{
return shasumSummaryFile;
}

}