You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Stephane Nicoll <st...@gmail.com> on 2006/06/05 11:12:05 UTC
Re: svn commit: r410628 - /maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
What's the purpose of these multiple catch statements if they just
deliver the same message? I think it would make sense to deliver a
message strongly linked to the exception's type being catched.
WDYT?
s/
On 5/31/06, carlos@apache.org <ca...@apache.org> wrote:
> 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 );
> }
> }
> }
>
>
>
--
.::You're welcome ::.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r410628 - /maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
Posted by Carlos Sanchez <ca...@apache.org>.
Yep, that'd be better. Still this is better than the previous one ;)
On 6/5/06, Stephane Nicoll <st...@gmail.com> wrote:
> What's the purpose of these multiple catch statements if they just
> deliver the same message? I think it would make sense to deliver a
> message strongly linked to the exception's type being catched.
>
> WDYT?
>
> s/
>
>
>
> On 5/31/06, carlos@apache.org <ca...@apache.org> wrote:
> > 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 );
> > }
> > }
> > }
> >
> >
> >
>
>
> --
> .::You're welcome ::.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
--
I could give you my word as a Spaniard.
No good. I've known too many Spaniards.
-- The Princess Bride
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org