Author: bentmann Date: Wed Apr 2 14:10:40 2008 New Revision: 644068 URL: http://svn.apache.org/viewvc?rev=644068&view=rev Log: [MSHADE-21] NPE when calling mvn shade:shade
o Made the goal fail gracefully with a user-friendly error message Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java?rev=644068&r1=644067&r2=644068&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java (original) +++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Wed Apr 2 14:10:40 2008 @@ -239,6 +239,19 @@ Set artifactIds = new LinkedHashSet(); Set sourceArtifacts = new LinkedHashSet(); + if ( project.getArtifact().getFile() == null ) + { + getLog().error( "The project main artifact does not exist. This could have the following" ); + getLog().error( "reasons:" ); + getLog().error( "- You have invoked the goal directly from the command line. This is not" ); + getLog().error( " supported. Please add the goal to the default lifecycle via an" ); + getLog().error( " <execution> element in your POM and use \"mvn package\" to have it run." ); + getLog().error( "- You have bound the goal to a lifecycle phase before \"package\". Please" ); + getLog().error( " remove this binding from your POM such that the goal will be run in" ); + getLog().error( " the proper phase." ); + throw new MojoExecutionException( "Failed to create shaded artifact.", + new IllegalStateException( "Project main artifact does not exist." ) ); + } artifacts.add( project.getArtifact().getFile() ); if ( createSourcesJar )