Skip to content

Commit

Permalink
[MGPG-66] fix handling of excluded files on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Syquel committed Mar 15, 2021
1 parent fba2c39 commit 4da6921
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <code>null</code>.
* @param artifact The artifact to match. Must not be <code>null</code>.
* @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code>
* 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;
}

Expand Down

0 comments on commit 4da6921

Please sign in to comment.