Author: carlos
Date: Wed May 31 11:21:13 2006
New Revision: 410628

URL: http://svn.apache.org/viewvc?rev=410628&view=rev
Log:
Improve error handling

Modified:
    
maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java

Modified: 
maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java?rev=410628&r1=410627&r2=410628&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
 Wed May 31 11:21:13 2006
@@ -18,13 +18,17 @@
 
 import org.apache.maven.archiver.MavenArchiveConfiguration;
 import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -221,48 +225,78 @@
             
             // create archive
             archiver.createArchive( project, archive );
+        }
+        catch ( ArchiverException e )
+        {
+            throw new MojoExecutionException( "There was a problem creating 
the EJB archive: " + e.getMessage() , e );
+        }
+        catch ( ManifestException e )
+        {
+            throw new MojoExecutionException( "There was a problem creating 
the EJB archive: " + e.getMessage() , e );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "There was a problem creating 
the EJB archive: " + e.getMessage() , e );
+        }
+        catch ( DependencyResolutionRequiredException e )
+        {
+            throw new MojoExecutionException( "There was a problem creating 
the EJB archive: " + e.getMessage() , e );
+        }
 
-            project.getArtifact().setFile( jarFile );
+        project.getArtifact().setFile( jarFile );
 
-            if ( new Boolean( generateClient ).booleanValue() )
-            {
-                getLog().info( "Building ejb client " + jarName + "-client" );
+        if ( Boolean.parseBoolean( generateClient ) )
+        {
+            getLog().info( "Building ejb client " + jarName + "-client" );
 
-                String[] excludes = DEFAULT_EXCLUDES;
-                String[] includes = DEFAULT_INCLUDES;
+            String[] excludes = DEFAULT_EXCLUDES;
+            String[] includes = DEFAULT_INCLUDES;
 
-                if ( clientIncludes != null && !clientIncludes.isEmpty() )
-                {
-                    includes = (String[]) clientIncludes.toArray( 
EMPTY_STRING_ARRAY );
-                }
+            if ( clientIncludes != null && !clientIncludes.isEmpty() )
+            {
+                includes = (String[]) clientIncludes.toArray( 
EMPTY_STRING_ARRAY );
+            }
 
-                if ( clientExcludes != null && !clientExcludes.isEmpty() )
-                {
-                    excludes = (String[]) clientExcludes.toArray( 
EMPTY_STRING_ARRAY );
-                }
+            if ( clientExcludes != null && !clientExcludes.isEmpty() )
+            {
+                excludes = (String[]) clientExcludes.toArray( 
EMPTY_STRING_ARRAY );
+            }
 
-                File clientJarFile = new File( basedir, jarName + 
"-client.jar" );
+            File clientJarFile = new File( basedir, jarName + "-client.jar" );
 
-                MavenArchiver clientArchiver = new MavenArchiver();
+            MavenArchiver clientArchiver = new MavenArchiver();
 
-                clientArchiver.setArchiver( clientJarArchiver );
+            clientArchiver.setArchiver( clientJarArchiver );
 
-                clientArchiver.setOutputFile( clientJarFile );
+            clientArchiver.setOutputFile( clientJarFile );
 
-                clientArchiver.getArchiver().addDirectory(
-                        new File( outputDirectory ), includes, excludes );
+            try
+            {
+                clientArchiver.getArchiver().addDirectory( new File( 
outputDirectory ), includes, excludes );
 
                 // create archive
                 clientArchiver.createArchive( project, archive );
 
-                // TODO: shouldn't need classifer
-                projectHelper.attachArtifact( project, "ejb-client", "client", 
clientJarFile );
             }
-        }
-        catch ( Exception e )
-        {
-            // TODO: improve error handling
-            throw new MojoExecutionException( "Error assembling EJB", e );
+            catch ( ArchiverException e )
+            {
+                throw new MojoExecutionException( "There was a problem 
creating the EJB client archive: " + e.getMessage() , e );
+            }
+            catch ( ManifestException e )
+            {
+                throw new MojoExecutionException( "There was a problem 
creating the EJB client archive: " + e.getMessage() , e );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "There was a problem 
creating the EJB client archive: " + e.getMessage() , e );
+            }
+            catch ( DependencyResolutionRequiredException e )
+            {
+                throw new MojoExecutionException( "There was a problem 
creating the EJB client archive: " + e.getMessage() , e );
+            }
+
+            // TODO: shouldn't need classifer
+            projectHelper.attachArtifact( project, "ejb-client", "client", 
clientJarFile );
         }
     }
 }


Reply via email to