mirror of https://github.com/apache/maven.git
clean up ear plugin exception handling
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@314956 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
608c1ebb93
commit
70ff436ddf
|
@ -17,6 +17,7 @@ package org.apache.maven.plugin.ear;
|
|||
*/
|
||||
|
||||
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 abstract class AbstractEarModule
|
|||
}
|
||||
|
||||
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,9 +95,13 @@ public abstract class AbstractEarModule
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.plugin.ear;
|
|||
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 @@ public abstract class AbstractEarMojo
|
|||
private List allModules;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
getLog().debug( "Resolving ear modules ..." );
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.plugin.ear;
|
|||
*/
|
||||
|
||||
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 @@ public interface EarModule
|
|||
/**
|
||||
* 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 @@ public interface EarModule
|
|||
* @throws EarPluginException if the artifact could not be resolved
|
||||
*/
|
||||
public void resolveArtifact( Set artifacts )
|
||||
throws EarPluginException;
|
||||
throws EarPluginException, MojoFailureException;
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.plugin.ear;
|
|||
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 class EarMojo
|
|||
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
// Initializes ear modules
|
||||
super.execute();
|
||||
|
@ -207,7 +208,7 @@ public class EarMojo
|
|||
private void includeCustomManifestFile()
|
||||
{
|
||||
File customManifestFile = manifestFile;
|
||||
|
||||
|
||||
if ( !customManifestFile.exists() )
|
||||
{
|
||||
getLog().info( "Could not find manifest file: " + manifestFile + " - Generating one" );
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.plugin.ear;
|
|||
*/
|
||||
|
||||
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 @@ public class GenerateApplicationXmlMojo
|
|||
private String generatedDescriptorLocation;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
// Initializes ear modules
|
||||
super.execute();
|
||||
|
@ -115,47 +116,42 @@ public class GenerateApplicationXmlMojo
|
|||
}
|
||||
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.plugin.ear;
|
|||
*/
|
||||
|
||||
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 class WebModule
|
|||
}
|
||||
|
||||
public void resolveArtifact( Set artifacts )
|
||||
throws EarPluginException
|
||||
throws MojoFailureException
|
||||
{
|
||||
// Let's resolve the artifact
|
||||
super.resolveArtifact( artifacts );
|
||||
|
|
Loading…
Reference in New Issue