diff --git a/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java b/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java index eea5dc6..98b600a 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java +++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -192,7 +193,7 @@ else if ( project.getAttachedArtifacts().isEmpty() ) File file = artifact.getFile(); - if ( isExcluded( file.getPath() ) ) + if ( isExcluded( artifact ) ) { getLog().debug( "Skipping generation of signature for excluded " + file ); continue; @@ -223,19 +224,24 @@ else if ( project.getAttachedArtifacts().isEmpty() ) /** * Tests whether or not a name matches against at least one exclude pattern. * - * @param name The name to match. Must not be null. + * @param artifact The artifact to match. Must not be null. * @return true when the name matches against at least one exclude pattern, or false * otherwise. */ - protected boolean isExcluded( String name ) + protected boolean isExcluded( Artifact artifact ) { + final Path projectBasePath = project.getBasedir().toPath(); + final Path artifactPath = artifact.getFile().toPath(); + final String relativeArtifactPath = projectBasePath.relativize( artifactPath ).toString(); + for ( String exclude : excludes ) { - if ( SelectorUtils.matchPath( exclude, name ) ) + if ( SelectorUtils.matchPath( exclude, relativeArtifactPath ) ) { return true; } } + return false; }