maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1788939 - /maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
Date Mon, 27 Mar 2017 14:46:56 GMT
Author: bimargulies
Date: Mon Mar 27 14:46:56 2017
New Revision: 1788939

URL: http://svn.apache.org/viewvc?rev=1788939&view=rev
Log:
[MSHADE-253] NullPointerException if minimizeJar == true && packaging == pom

Modified:
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java?rev=1788939&r1=1788938&r2=1788939&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
(original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
Mon Mar 27 14:46:56 2017
@@ -86,25 +86,28 @@ public class MinijarFilter
     public MinijarFilter( MavenProject project, Log log, List<SimpleFilter> simpleFilters
)
         throws IOException
     {
+      this.log = log;
 
-        this.log = log;
+      File artifactFile = project.getArtifact().getFile();
 
-        Clazzpath cp = new Clazzpath();
+        if ( artifactFile != null )
+        {
+          Clazzpath cp = new Clazzpath();
 
-        ClazzpathUnit artifactUnit =
-            cp.addClazzpathUnit( new FileInputStream( project.getArtifact().getFile() ),
project.toString() );
+          ClazzpathUnit artifactUnit = cp.addClazzpathUnit( new FileInputStream( artifactFile
), project.toString() );
 
-        for ( Artifact dependency : project.getArtifacts() )
-        {
-            addDependencyToClasspath( cp, dependency );
-        }
+            for ( Artifact dependency : project.getArtifacts() )
+            {
+                addDependencyToClasspath( cp, dependency );
+            }
 
-        removable = cp.getClazzes();
-        removePackages( artifactUnit );
-        removable.removeAll( artifactUnit.getClazzes() );
-        removable.removeAll( artifactUnit.getTransitiveDependencies() );
-        removeSpecificallyIncludedClasses( project, simpleFilters == null ? Collections.<SimpleFilter>emptyList()
-                        : simpleFilters );
+            removable = cp.getClazzes();
+            removePackages( artifactUnit );
+            removable.removeAll( artifactUnit.getClazzes() );
+            removable.removeAll( artifactUnit.getTransitiveDependencies() );
+            removeSpecificallyIncludedClasses( project,
+                simpleFilters == null ? Collections.<SimpleFilter>emptyList() : simpleFilters
);
+        }
     }
 
     private ClazzpathUnit addDependencyToClasspath( Clazzpath cp, Artifact dependency )
@@ -214,7 +217,7 @@ public class MinijarFilter
         String className = classFile.replace( '/', '.' ).replaceFirst( "\\.class$", "" );
         Clazz clazz = new Clazz( className );
 
-        if ( removable.contains( clazz ) )
+        if ( removable != null && removable.contains( clazz ) )
         {
             log.debug( "Removing " + className );
             classesRemoved += 1;



Mime
View raw message