You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/10/05 09:03:00 UTC

svn commit: r295007 - in /maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly: AbstractUnpackingMojo.java AssemblyMojo.java UnpackMojo.java

Author: brett
Date: Wed Oct  5 00:02:55 2005
New Revision: 295007

URL: http://svn.apache.org/viewcvs?rev=295007&view=rev
Log:
cleanup error handling on assembly plugin

Modified:
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java

Modified: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java?rev=295007&r1=295006&r2=295007&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java Wed Oct  5 00:02:55 2005
@@ -18,6 +18,7 @@
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
@@ -36,7 +37,7 @@
 public abstract class AbstractUnpackingMojo
     extends AbstractMojo
 {
-    static protected final String[] EMPTY_STRING_ARRAY = {};
+    protected static final String[] EMPTY_STRING_ARRAY = {};
 
     /**
      * The output directory of the assembled distribution file.
@@ -89,7 +90,7 @@
      */
 
     protected void unpack( File file, File location )
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
         String archiveExt = FileUtils.getExtension( file.getAbsolutePath() ).toLowerCase();
 
@@ -103,7 +104,7 @@
         }
         catch ( NoSuchArchiverException e )
         {
-            throw new MojoExecutionException( "Unknown archive file: " + file );
+            throw new MojoFailureException( "Unable to obtain unarchiver for extension '" + archiveExt + "'" );
         }
 
         try
@@ -114,13 +115,13 @@
 
             unArchiver.extract();
         }
-        catch ( IOException ioe )
+        catch ( IOException e )
         {
-            throw new MojoExecutionException( "Error unpacking file: " + file + "to: " + location );
+            throw new MojoExecutionException( "Error unpacking file: " + file + "to: " + location, e );
         }
         catch ( ArchiverException e )
         {
-            throw new MojoExecutionException( "Error unpacking file: " + file + "to: " + location );
+            throw new MojoExecutionException( "Error unpacking file: " + file + "to: " + location, e );
         }
     }
 

Modified: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java?rev=295007&r1=295006&r2=295007&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java Wed Oct  5 00:02:55 2005
@@ -150,7 +150,7 @@
             }
             catch ( NoSuchArchiverException e )
             {
-                throw new MojoExecutionException( e.getMessage() );
+                throw new MojoFailureException( "Unable to obtain archiver for extension '" + format + "'" );
             }
             catch ( ArchiverException e )
             {
@@ -166,7 +166,7 @@
     }
 
     protected File createArchive( Archiver archiver, Assembly assembly, String filename )
-        throws ArchiverException, IOException, MojoExecutionException
+        throws ArchiverException, IOException, MojoExecutionException, MojoFailureException
     {
         File destFile;
         processDependencySets( archiver, assembly.getDependencySets(), assembly.isIncludeBaseDirectory() );
@@ -200,7 +200,7 @@
             InputStream resourceAsStream = getClass().getResourceAsStream( "/assemblies/" + descriptorId + ".xml" );
             if ( resourceAsStream == null )
             {
-                throw new MojoExecutionException( "Descriptor with ID '" + descriptorId + "' not found" );
+                throw new MojoFailureException( "Descriptor with ID '" + descriptorId + "' not found" );
             }
             r = new InputStreamReader( resourceAsStream );
         }
@@ -238,7 +238,7 @@
      * @param includeBaseDirectory
      */
     protected void processDependencySets( Archiver archiver, List dependencySets, boolean includeBaseDirectory )
-        throws ArchiverException, IOException, MojoExecutionException
+        throws ArchiverException, IOException, MojoExecutionException, MojoFailureException
     {
         for ( Iterator i = dependencySets.iterator(); i.hasNext(); )
         {

Modified: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java?rev=295007&r1=295006&r2=295007&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java Wed Oct  5 00:02:55 2005
@@ -1,11 +1,5 @@
 package org.apache.maven.plugin.assembly;
 
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.io.File;
-import java.util.Iterator;
-
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
  *
@@ -22,6 +16,12 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.util.Iterator;
 
 /**
  * Unpack project dependencies.  Currently supports dependencies of type jar and zip.
@@ -39,28 +39,8 @@
      * @throws MojoExecutionException
      */
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
-        try
-        {
-            doExecute();
-        }
-        catch ( Exception e )
-        {
-            // TODO: don't catch exception
-            throw new MojoExecutionException( "Error unpacking", e );
-        }
-    }
-
-    /**
-     * Unpacks the project dependencies.
-     *
-     * @throws Exception
-     */
-    private void doExecute()
-        throws Exception
-    {
-
         for ( Iterator j = dependencies.iterator(); j.hasNext(); )
         {
             Artifact artifact = (Artifact) j.next();
@@ -86,4 +66,5 @@
             }
         }
     }
+
 }