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/12 18:28:19 UTC

svn commit: r314956 - in /maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear: AbstractEarModule.java AbstractEarMojo.java EarModule.java EarMojo.java GenerateApplicationXmlMojo.java WebModule.java

Author: brett
Date: Wed Oct 12 09:27:15 2005
New Revision: 314956

URL: http://svn.apache.org/viewcvs?rev=314956&view=rev
Log:
clean up ear plugin exception handling

Modified:
    maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
    maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
    maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
    maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
    maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
    maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java

Modified: maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java (original)
+++ maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java Wed Oct 12 09:27:15 2005
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
 
 import java.util.Iterator;
 import java.util.Set;
@@ -71,17 +72,13 @@
     }
 
     public void resolveArtifact( Set artifacts )
-        throws EarPluginException
+        throws MojoFailureException
     {
-        if ( artifact != null )
-        {
-            return;
-        }
-        else
+        if ( artifact == null )
         {
             if ( groupId == null || artifactId == null )
             {
-                throw new EarPluginException(
+                throw new MojoFailureException(
                     "Could not resolve artifact[" + groupId + ":" + artifactId + ":" + getType() + "]" );
             }
 
@@ -98,8 +95,12 @@
             }
 
             // Artifact has not been found
-            throw new EarPluginException( "Artifact[" + groupId + ":" + artifactId + ":" + getType() + "] " +
+            throw new MojoFailureException( "Artifact[" + groupId + ":" + artifactId + ":" + getType() + "] " +
                 "is not a dependency of the project." );
+        }
+        else
+        {
+            return;
         }
     }
 

Modified: maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java Wed Oct 12 09:27:15 2005
@@ -19,6 +19,7 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 
 import java.io.File;
@@ -68,7 +69,7 @@
     private List allModules;
 
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
         getLog().debug( "Resolving ear modules ..." );
 

Modified: maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java (original)
+++ maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java Wed Oct 12 09:27:15 2005
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.util.xml.XMLWriter;
 
 import java.util.Set;
@@ -58,7 +59,7 @@
     /**
      * Appends the <tt>XML</tt> representation of this module.
      *
-     * @param writer  the writer to use
+     * @param writer the writer to use
      * @param version the version of the <tt>application.xml</tt> file
      */
     public void appendModule( XMLWriter writer, String version );
@@ -70,6 +71,6 @@
      * @throws EarPluginException if the artifact could not be resolved
      */
     public void resolveArtifact( Set artifacts )
-        throws EarPluginException;
+        throws EarPluginException, MojoFailureException;
 
 }

Modified: maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java Wed Oct 12 09:27:15 2005
@@ -19,6 +19,7 @@
 import org.apache.maven.archiver.MavenArchiveConfiguration;
 import org.apache.maven.archiver.MavenArchiver;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -103,7 +104,7 @@
 
 
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
         // Initializes ear modules
         super.execute();
@@ -207,7 +208,7 @@
     private void includeCustomManifestFile()
     {
         File customManifestFile = manifestFile;
-        
+
         if ( !customManifestFile.exists() )
         {
             getLog().info( "Could not find manifest file: " + manifestFile + " - Generating one" );

Modified: maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java Wed Oct 12 09:27:15 2005
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
@@ -89,7 +90,7 @@
     private String generatedDescriptorLocation;
 
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
         // Initializes ear modules
         super.execute();
@@ -115,47 +116,42 @@
         }
 
         // Generate deployment descriptor and copy it to the build directory
+        getLog().info( "Generating application.xml" );
         try
         {
-            getLog().info( "Generating application.xml" );
             generateDeploymentDescriptor();
+        }
+        catch ( EarPluginException e )
+        {
+            throw new MojoExecutionException( "Failed to generate application.xml", e );
+        }
+
+        try
+        {
             FileUtils.copyFileToDirectory( new File( generatedDescriptorLocation, "application.xml" ),
                                            new File( getWorkDirectory(), "META-INF" ) );
         }
         catch ( IOException e )
         {
-            throw new MojoExecutionException( "Failed to generate application.xml", e );
+            throw new MojoExecutionException( "Unable to copy application.xml to final destination", e );
         }
     }
 
     /**
      * Generates the deployment descriptor if necessary.
-     *
-     * @throws IOException
      */
     protected void generateDeploymentDescriptor()
-        throws IOException
+        throws EarPluginException
     {
         File outputDir = new File( generatedDescriptorLocation );
         if ( !outputDir.exists() )
         {
-            outputDir.mkdir();
+            outputDir.mkdirs();
         }
 
         File descriptor = new File( outputDir, "application.xml" );
-        if ( !descriptor.exists() )
-        {
-            descriptor.createNewFile();
-        }
 
         ApplicationXmlWriter writer = new ApplicationXmlWriter( version, encoding );
-        try
-        {
-            writer.write( descriptor, getModules(), displayName, description );
-        }
-        catch ( EarPluginException e )
-        {
-            throw new IOException( "Unable to generate application.xml[" + e.getMessage() + "]" );
-        }
+        writer.write( descriptor, getModules(), displayName, description );
     }
 }

Modified: maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java (original)
+++ maven/components/trunk/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java Wed Oct 12 09:27:15 2005
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.util.xml.XMLWriter;
 
 import java.util.Set;
@@ -63,7 +64,7 @@
     }
 
     public void resolveArtifact( Set artifacts )
-        throws EarPluginException
+        throws MojoFailureException
     {
         // Let's resolve the artifact
         super.resolveArtifact( artifacts );