Skip to content

Commit

Permalink
[MSHADE-319] Group output into included and excluded artifacts to eas…
Browse files Browse the repository at this point in the history
…ily identify them
  • Loading branch information
rfscholte committed Feb 5, 2020
1 parent 038d807 commit aba5b7c
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,18 +664,25 @@ private void processArtifactSelectors( Set<File> artifacts, Set<String> artifact
Set<File> testArtifacts, Set<File> testSourceArtifacts,
ArtifactSelector artifactSelector )
{

List<String> excludedArtifacts = new ArrayList<>();
List<String> pomArtifacts = new ArrayList<>();
List<String> emptySourceArtifacts = new ArrayList<>();
List<String> emptyTestArtifacts = new ArrayList<>();
List<String> emptyTestSourceArtifacts = new ArrayList<>();

for ( Artifact artifact : project.getArtifacts() )
{
if ( !artifactSelector.isSelected( artifact ) )
{
getLog().info( "Excluding " + artifact.getId() + " from the shaded jar." );
excludedArtifacts.add( artifact.getId() );

continue;
}

if ( "pom".equals( artifact.getType() ) )
{
getLog().info( "Skipping pom dependency " + artifact.getId() + " in the shaded jar." );
pomArtifacts.add( artifact.getId() );
continue;
}

Expand All @@ -695,7 +702,7 @@ private void processArtifactSelectors( Set<File> artifacts, Set<String> artifact
}
else
{
getLog().warn( "Skipping empty source jar " + artifact.getId() + "." );
emptySourceArtifacts.add( artifact.getArtifactId() );
}
}
}
Expand All @@ -711,7 +718,7 @@ private void processArtifactSelectors( Set<File> artifacts, Set<String> artifact
}
else
{
getLog().warn( "Skipping empty test jar " + artifact.getId() + "." );
emptyTestArtifacts.add( artifact.getId() );
}
}
}
Expand All @@ -725,10 +732,31 @@ private void processArtifactSelectors( Set<File> artifacts, Set<String> artifact
}
else
{
getLog().warn( "Skipping empty test source jar " + artifact.getId() + "." );
emptyTestSourceArtifacts.add( artifact.getId() );
}
}
}

for ( String artifactId : excludedArtifacts )
{
getLog().info( "Excluding " + artifactId + " from the shaded jar." );
}
for ( String artifactId : pomArtifacts )
{
getLog().info( "Skipping pom dependency " + artifactId + " in the shaded jar." );
}
for ( String artifactId : emptySourceArtifacts )
{
getLog().warn( "Skipping empty source jar " + artifactId + "." );
}
for ( String artifactId : emptyTestArtifacts )
{
getLog().warn( "Skipping empty test jar " + artifactId + "." );
}
for ( String artifactId : emptyTestArtifacts )
{
getLog().warn( "Skipping empty test source jar " + artifactId + "." );
}
}

private boolean invalidMainArtifact()
Expand Down Expand Up @@ -786,12 +814,10 @@ private void replaceFile( File oldFile, File newFile )
private void copyFiles( File source, File target )
throws IOException
{
try ( InputStream in = new FileInputStream( source ) )
try ( InputStream in = new FileInputStream( source );
OutputStream out = new FileOutputStream( target ) )
{
try ( OutputStream out = new FileOutputStream( target ) )
{
IOUtil.copy( in, out );
}
IOUtil.copy( in, out );
}
}

Expand Down

0 comments on commit aba5b7c

Please sign in to comment.