Skip to content

Commit 4da6921

Browse files
committed
[MGPG-66] fix handling of excluded files on linux
1 parent fba2c39 commit 4da6921

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.io.File;
2323
import java.io.IOException;
24+
import java.nio.file.Path;
2425
import java.util.ArrayList;
2526
import java.util.List;
2627

@@ -192,7 +193,7 @@ else if ( project.getAttachedArtifacts().isEmpty() )
192193

193194
File file = artifact.getFile();
194195

195-
if ( isExcluded( file.getPath() ) )
196+
if ( isExcluded( artifact ) )
196197
{
197198
getLog().debug( "Skipping generation of signature for excluded " + file );
198199
continue;
@@ -223,19 +224,24 @@ else if ( project.getAttachedArtifacts().isEmpty() )
223224
/**
224225
* Tests whether or not a name matches against at least one exclude pattern.
225226
*
226-
* @param name The name to match. Must not be <code>null</code>.
227+
* @param artifact The artifact to match. Must not be <code>null</code>.
227228
* @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code>
228229
* otherwise.
229230
*/
230-
protected boolean isExcluded( String name )
231+
protected boolean isExcluded( Artifact artifact )
231232
{
233+
final Path projectBasePath = project.getBasedir().toPath();
234+
final Path artifactPath = artifact.getFile().toPath();
235+
final String relativeArtifactPath = projectBasePath.relativize( artifactPath ).toString();
236+
232237
for ( String exclude : excludes )
233238
{
234-
if ( SelectorUtils.matchPath( exclude, name ) )
239+
if ( SelectorUtils.matchPath( exclude, relativeArtifactPath ) )
235240
{
236241
return true;
237242
}
238243
}
244+
239245
return false;
240246
}
241247

0 commit comments

Comments
 (0)