diff --git a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseClasspathWriter.java b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseClasspathWriter.java index f39a7319dd..cb92412e78 100644 --- a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseClasspathWriter.java +++ b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseClasspathWriter.java @@ -22,6 +22,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.IOUtil; @@ -61,7 +62,7 @@ public class EclipseClasspathWriter EclipseSourceDir[] sourceDirs, List classpathContainers, ArtifactRepository localRepository, ArtifactResolver artifactResolver, ArtifactFactory artifactFactory, List remoteArtifactRepositories, boolean downloadSources, String outputDirectory ) - throws EclipsePluginException + throws MojoExecutionException { FileWriter w; @@ -72,7 +73,7 @@ public class EclipseClasspathWriter } catch ( IOException ex ) { - throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), + throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$ } @@ -156,7 +157,7 @@ public class EclipseClasspathWriter ArtifactRepository localRepository, ArtifactResolver artifactResolver, ArtifactFactory artifactFactory, List remoteArtifactRepositories, boolean downloadSources ) - throws EclipsePluginException + throws MojoExecutionException { String path; @@ -228,7 +229,7 @@ public class EclipseClasspathWriter private Artifact retrieveSourceArtifact( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, ArtifactResolver artifactResolver, ArtifactFactory artifactFactory ) - throws EclipsePluginException + throws MojoExecutionException { // source artifact: use the "sources" classifier added by the source plugin Artifact sourceArtifact = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), @@ -253,7 +254,7 @@ public class EclipseClasspathWriter } catch ( ArtifactResolutionException e ) { - throw new EclipsePluginException( "Error getting soruce artifact", e ); + throw new MojoExecutionException( "Error getting source artifact", e ); } return sourceArtifact; diff --git a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java index fd82f1e555..dd7d8f0fea 100644 --- a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java +++ b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java @@ -21,6 +21,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolver; 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; @@ -160,9 +161,9 @@ public class EclipsePlugin * @parameter expression="${eclipse.workspace}" */ private File outputDir; - + /** - * The default output directory + * The default output directory * * @parameter expression="${project.build.outputDirectory}" */ @@ -262,9 +263,8 @@ public class EclipsePlugin * @see org.apache.maven.plugin.Mojo#execute() */ public void execute() - throws MojoExecutionException + throws MojoExecutionException, MojoFailureException { - if ( executedProject == null ) { // backwards compat with alpha-2 only @@ -332,7 +332,7 @@ public class EclipsePlugin } public void write() - throws EclipsePluginException + throws MojoExecutionException { File projectBaseDir = executedProject.getFile().getParentFile(); @@ -340,12 +340,14 @@ public class EclipsePlugin List reactorArtifacts = EclipseUtils.resolveReactorArtifacts( project, reactorProjects ); // build a list of UNIQUE source dirs (both src and resources) to be used in classpath and wtpmodules - EclipseSourceDir[] sourceDirs = EclipseUtils.buildDirectoryList( executedProject, outputDir, getLog(), outputDirectory ); + EclipseSourceDir[] sourceDirs = + EclipseUtils.buildDirectoryList( executedProject, outputDir, getLog(), outputDirectory ); // use project since that one has all artifacts resolved. new EclipseClasspathWriter( getLog() ).write( projectBaseDir, outputDir, project, reactorArtifacts, sourceDirs, classpathContainers, localRepository, artifactResolver, - artifactFactory, remoteArtifactRepositories, downloadSources, outputDirectory ); + artifactFactory, remoteArtifactRepositories, downloadSources, + outputDirectory ); new EclipseProjectWriter( getLog() ).write( projectBaseDir, outputDir, project, executedProject, reactorArtifacts, projectnatures, buildcommands ); @@ -360,11 +362,11 @@ public class EclipsePlugin } private void assertNotEmpty( String string, String elementName ) - throws EclipsePluginException + throws MojoFailureException { if ( string == null ) { - throw new EclipsePluginException( + throw new MojoFailureException( Messages.getString( "EclipsePlugin.missingelement", elementName ) ); //$NON-NLS-1$ } } @@ -374,7 +376,8 @@ public class EclipsePlugin this.downloadSources = downloadSources; } - public void setOutputDirectory(String outputDirectory) { + public void setOutputDirectory( String outputDirectory ) + { this.outputDirectory = outputDirectory; } } diff --git a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePluginException.java b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePluginException.java deleted file mode 100644 index 70696b5459..0000000000 --- a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePluginException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.maven.plugin.eclipse; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.maven.plugin.MojoExecutionException; - -/** - * @author Trygve Laugstøl - * @version $Id$ - */ -public class EclipsePluginException - extends MojoExecutionException -{ - public EclipsePluginException( String msg ) - { - super( msg ); - } - - public EclipsePluginException( String msg, Throwable cause ) - { - super( msg, cause ); - } -} diff --git a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseProjectWriter.java b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseProjectWriter.java index 4b89a909d1..f218720aa1 100644 --- a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseProjectWriter.java +++ b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseProjectWriter.java @@ -16,22 +16,24 @@ package org.apache.maven.plugin.eclipse; * limitations under the License. */ -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Resource; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; import org.codehaus.plexus.util.xml.XMLWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + /** * Writes eclipse .project file. + * * @author Trygve Laugstøl * @author Kenney Westerhof * @author Fabrizio Giustina @@ -48,8 +50,8 @@ public class EclipseProjectWriter } protected void write( File projectBaseDir, File basedir, MavenProject project, MavenProject executedProject, - List reactorArtifacts, List projectnatures, List buildCommands ) - throws EclipsePluginException + List reactorArtifacts, List projectnatures, List buildCommands ) + throws MojoExecutionException { FileWriter w; @@ -59,7 +61,8 @@ public class EclipseProjectWriter } catch ( IOException ex ) { - throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$ + throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), + ex ); //$NON-NLS-1$ } XMLWriter writer = new PrettyPrintXMLWriter( w ); diff --git a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSettingsWriter.java b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSettingsWriter.java index 8fb9eb47c3..301991cb44 100644 --- a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSettingsWriter.java +++ b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSettingsWriter.java @@ -16,15 +16,16 @@ package org.apache.maven.plugin.eclipse; * limitations under the License. */ +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.project.MavenProject; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; - /** * @author Trygve Laugstøl * @author Kenney Westerhof @@ -42,22 +43,24 @@ public class EclipseSettingsWriter } protected void write( File projectBaseDir, File outputDir, MavenProject project ) - throws EclipsePluginException + throws MojoExecutionException { // check if it's necessary to create project specific settings Properties coreSettings = new Properties(); - String source = EclipseUtils.getPluginSetting( project, "maven-compiler-plugin", "source", null ); //$NON-NLS-1$ //$NON-NLS-2$ - String target = EclipseUtils.getPluginSetting( project, "maven-compiler-plugin", "target", null ); //$NON-NLS-1$ //$NON-NLS-2$ + String source = EclipseUtils.getPluginSetting( project, "maven-compiler-plugin", "source", + null ); //$NON-NLS-1$ //$NON-NLS-2$ + String target = EclipseUtils.getPluginSetting( project, "maven-compiler-plugin", "target", + null ); //$NON-NLS-1$ //$NON-NLS-2$ - if ( source != null && !source.equals( "1.3" ) ) //$NON-NLS-1$ + if ( source != null && !"1.3".equals( source ) ) //$NON-NLS-1$ { coreSettings.put( "org.eclipse.jdt.core.compiler.source", source ); //$NON-NLS-1$ coreSettings.put( "org.eclipse.jdt.core.compiler.compliance", source ); //$NON-NLS-1$ } - if ( target != null && !target.equals( "1.2" ) ) //$NON-NLS-1$ + if ( target != null && !"1.2".equals( target ) ) //$NON-NLS-1$ { coreSettings.put( "org.eclipse.jdt.core.compiler.codegen.targetPlatform", target ); //$NON-NLS-1$ } @@ -81,11 +84,13 @@ public class EclipseSettingsWriter } catch ( FileNotFoundException e ) { - throw new EclipsePluginException( Messages.getString( "EclipseSettingsWriter.cannotcreatesettings" ), e ); //$NON-NLS-1$ + throw new MojoExecutionException( Messages.getString( "EclipseSettingsWriter.cannotcreatesettings" ), + e ); //$NON-NLS-1$ } catch ( IOException e ) { - throw new EclipsePluginException( Messages.getString( "EclipseSettingsWriter.errorwritingsettings" ), e ); //$NON-NLS-1$ + throw new MojoExecutionException( Messages.getString( "EclipseSettingsWriter.errorwritingsettings" ), + e ); //$NON-NLS-1$ } } else diff --git a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWtpmodulesWriter.java b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWtpmodulesWriter.java index d5c19d12b9..5b3152f63c 100644 --- a/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWtpmodulesWriter.java +++ b/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWtpmodulesWriter.java @@ -16,14 +16,9 @@ package org.apache.maven.plugin.eclipse; * limitations under the License. */ -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.IOUtil; @@ -31,8 +26,15 @@ import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; import org.codehaus.plexus.util.xml.XMLWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + /** * Writes eclipse .wtpmodules file. + * * @author Fabrizio Giustina * @version $Id$ */ @@ -47,8 +49,8 @@ public class EclipseWtpmodulesWriter } protected void write( File basedir, MavenProject project, List referencedReactorArtifacts, - EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository ) - throws EclipsePluginException + EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository ) + throws MojoExecutionException { FileWriter w; @@ -58,7 +60,8 @@ public class EclipseWtpmodulesWriter } catch ( IOException ex ) { - throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$ + throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), + ex ); //$NON-NLS-1$ } XMLWriter writer = new PrettyPrintXMLWriter( w ); @@ -173,7 +176,7 @@ public class EclipseWtpmodulesWriter } private void writeWarSpecificResources( XMLWriter writer, File basedir, MavenProject project, - List referencedReactorArtifacts, ArtifactRepository localRepository ) + List referencedReactorArtifacts, ArtifactRepository localRepository ) { String warSourceDirectory = EclipseUtils.getPluginSetting( project, "maven-war-plugin", //$NON-NLS-1$ @@ -195,7 +198,7 @@ public class EclipseWtpmodulesWriter } private void addDependency( XMLWriter writer, Artifact artifact, List referencedReactorProjects, - ArtifactRepository localRepository ) + ArtifactRepository localRepository ) { String handle; @@ -205,7 +208,8 @@ public class EclipseWtpmodulesWriter // uses // - handle = "module:/resource/" + artifact.getArtifactId() + "/" + artifact.getArtifactId(); //$NON-NLS-1$ //$NON-NLS-2$ + handle = "module:/resource/" + artifact.getArtifactId() + "/" + + artifact.getArtifactId(); //$NON-NLS-1$ //$NON-NLS-2$ } else {