maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r320675 - in /maven/components/trunk: maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/ maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/execution/ maven-core/src/main/java/org/apache/maven/...
Date Thu, 13 Oct 2005 06:50:49 GMT
Author: brett
Date: Wed Oct 12 23:50:22 2005
New Revision: 320675

URL: http://svn.apache.org/viewcvs?rev=320675&view=rev
Log:
PR: MNG-122
exception clean up phase 2

Added:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java   (with props)
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java   (with props)
Modified:
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/BuildFailureException.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RuntimeInformation.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
    maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java Wed Oct 12 23:50:22 2005
@@ -32,6 +32,7 @@
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Repository;
 import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -171,6 +172,10 @@
         {
             // TODO: improve handling
             throw new BuildException( "Unable to locate artifact", e );
+        }
+        catch ( InvalidDependencyVersionException e )
+        {
+            throw new BuildException( e.getMessage(), e );
         }
 
         if ( pathId != null && getProject().getReference( pathId ) != null )

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/BuildFailureException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/BuildFailureException.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/BuildFailureException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/BuildFailureException.java Wed Oct 12 23:50:22 2005
@@ -23,7 +23,7 @@
  * @version $Id$
  */
 public class BuildFailureException
-    extends Throwable
+    extends Exception
 {
     public BuildFailureException( String message )
     {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Wed Oct 12 23:50:22 2005
@@ -196,6 +196,10 @@
         {
             return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
         }
+        catch ( BuildFailureException e )
+        {
+            return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
+        }
 
         ReactorManager rm;
         try
@@ -409,7 +413,7 @@
     private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings,
                                   ProfileManager globalProfileManager, boolean isRoot )
         throws ArtifactResolutionException, ProjectBuildingException, ProfileActivationException,
-        MavenExecutionException
+        MavenExecutionException, BuildFailureException
     {
         List projects = new ArrayList( files.size() );
 
@@ -435,17 +439,10 @@
             if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
             {
                 DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
-                try
-                {
-                    if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
-                    {
-                        throw new ProjectBuildingException( project.getId(), "Unable to build project '" +
-                            project.getFile() + "; it requires Maven version " + version.toString() );
-                    }
-                }
-                catch ( IOException e )
+                if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
                 {
-                    throw new MavenExecutionException( "Unable to get Maven application version", e );
+                    throw new BuildFailureException( "Unable to build project '" + project.getFile() +
+                        "; it requires Maven version " + version.toString() );
                 }
             }
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java Wed Oct 12 23:50:22 2005
@@ -18,10 +18,12 @@
 
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.util.IOUtil;
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Properties;
 
 /**
@@ -31,30 +33,41 @@
  * @version $Id$
  */
 public class DefaultRuntimeInformation
-    implements RuntimeInformation
+    implements RuntimeInformation, Initializable
 {
     private ArtifactVersion applicationVersion;
 
     public ArtifactVersion getApplicationVersion()
-        throws IOException
     {
-        if ( applicationVersion == null )
+        return applicationVersion;
+    }
+
+    public void initialize()
+        throws InitializationException
+    {
+        InputStream resourceAsStream = null;
+        try
         {
-            InputStream resourceAsStream = null;
-            try
-            {
-                Properties properties = new Properties();
-                resourceAsStream = getClass().getClassLoader().getResourceAsStream(
-                    "META-INF/maven/org.apache.maven/maven-core/pom.properties" );
-                properties.load( resourceAsStream );
+            Properties properties = new Properties();
+            resourceAsStream = getClass().getClassLoader().getResourceAsStream(
+                "META-INF/maven/org.apache.maven/maven-core/pom.properties" );
+            properties.load( resourceAsStream );
 
-                applicationVersion = new DefaultArtifactVersion( properties.getProperty( "version" ) );
-            }
-            finally
+            String property = properties.getProperty( "version" );
+            if ( property == null )
             {
-                IOUtil.close( resourceAsStream );
+                throw new InitializationException( "maven-core properties did not include the version" );
             }
+
+            applicationVersion = new DefaultArtifactVersion( property );
+        }
+        catch ( IOException e )
+        {
+            throw new InitializationException( "Unable to read properties file from maven-core", e );
+        }
+        finally
+        {
+            IOUtil.close( resourceAsStream );
         }
-        return applicationVersion;
     }
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RuntimeInformation.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RuntimeInformation.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RuntimeInformation.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RuntimeInformation.java Wed Oct 12 23:50:22 2005
@@ -18,8 +18,6 @@
 
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 
-import java.io.IOException;
-
 /**
  * Describes runtime information about the application.
  *
@@ -28,6 +26,5 @@
  */
 public interface RuntimeInformation
 {
-    ArtifactVersion getApplicationVersion()
-        throws IOException;
+    ArtifactVersion getApplicationVersion();
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed Oct 12 23:50:22 2005
@@ -35,9 +35,11 @@
 import org.apache.maven.model.ReportSet;
 import org.apache.maven.monitor.event.EventDispatcher;
 import org.apache.maven.monitor.event.MavenEvents;
+import org.apache.maven.plugin.InvalidPluginException;
 import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.PluginConfigurationException;
 import org.apache.maven.plugin.PluginManager;
 import org.apache.maven.plugin.PluginManagerException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -46,6 +48,7 @@
 import org.apache.maven.plugin.lifecycle.Phase;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusContainerException;
@@ -370,6 +373,13 @@
 
             handleExecutionFailure( rm, project, e, task, buildStartTime );
         }
+        catch ( InvalidDependencyVersionException e )
+        {
+            // TODO: should be dispatchFailure?
+            dispatcher.dispatchError( event, target, e );
+
+            handleExecutionFailure( rm, project, e, task, buildStartTime );
+        }
     }
 
     private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task,
@@ -516,7 +526,7 @@
 
     private void executeGoal( String task, MavenSession session, MavenProject project, MavenExecutionResponse response )
         throws LifecycleExecutionException, ArtifactNotFoundException, MojoExecutionException,
-        ArtifactResolutionException, MojoFailureException
+        ArtifactResolutionException, MojoFailureException, InvalidDependencyVersionException
     {
         if ( getPhaseToLifecycleMap().containsKey( task ) )
         {
@@ -535,7 +545,7 @@
     private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
                                            MavenProject project, MavenExecutionResponse response, Lifecycle lifecycle )
         throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidDependencyVersionException
     {
         List goals = processGoalChain( task, lifecycleMappings, lifecycle );
 
@@ -552,7 +562,7 @@
     private void executeStandaloneGoal( String task, MavenSession session, MavenProject project,
                                         MavenExecutionResponse response )
         throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidDependencyVersionException
     {
         // guaranteed to come from the CLI and not be part of a phase
         MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
@@ -561,7 +571,7 @@
 
     private void executeGoals( List goals, MavenSession session, MavenProject project, MavenExecutionResponse response )
         throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidDependencyVersionException
     {
         for ( Iterator i = goals.iterator(); i.hasNext(); )
         {
@@ -598,8 +608,8 @@
             }
             catch ( PluginManagerException e )
             {
-                throw new LifecycleExecutionException(
-                    "Internal error in the plugin manager executing goal '" + mojoDescriptor.getId(), e );
+                throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" +
+                    mojoDescriptor.getId() + "': " + e.getMessage(), e );
             }
         }
     }
@@ -726,6 +736,11 @@
                 catch ( PluginManagerException e )
                 {
                     throw new LifecycleExecutionException(
+                        "Error getting reports from the plugin '" + reportPlugin.getKey() + "': " + e.getMessage(), e );
+                }
+                catch ( PluginConfigurationException e )
+                {
+                    throw new LifecycleExecutionException(
                         "Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
                 }
             }
@@ -736,7 +751,7 @@
     private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
                                 MavenExecutionResponse response )
         throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidDependencyVersionException
     {
         PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
         getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
@@ -767,7 +782,7 @@
     private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
                                        MavenExecutionResponse response )
         throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidDependencyVersionException
     {
         PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
 
@@ -1015,7 +1030,9 @@
                                   ArtifactRepository localRepository )
         throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException
     {
-        for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
+        Object pluginComponent = null;
+
+        for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext() && pluginComponent == null; )
         {
             Plugin plugin = (Plugin) i.next();
 
@@ -1026,7 +1043,7 @@
                 // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
                 try
                 {
-                    return pluginManager.getPluginComponent( plugin, role, roleHint );
+                    pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint );
                 }
                 catch ( ComponentLookupException e )
                 {
@@ -1035,11 +1052,11 @@
                 catch ( PluginManagerException e )
                 {
                     throw new LifecycleExecutionException(
-                        "Error getting extensions from the plugin '" + plugin.getKey() + "'", e );
+                        "Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
                 }
             }
         }
-        return null;
+        return pluginComponent;
     }
 
     /**
@@ -1070,7 +1087,8 @@
                 }
                 catch ( PluginManagerException e )
                 {
-                    throw new LifecycleExecutionException( "Error looking up available components from a plugin", e );
+                    throw new LifecycleExecutionException( "Error looking up available components from plugin '" +
+                        plugin.getKey() + "': " + e.getMessage(), e );
                 }
 
                 // shudder...
@@ -1140,7 +1158,8 @@
         }
         catch ( PluginManagerException e )
         {
-            throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+            throw new LifecycleExecutionException(
+                "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
         }
         catch ( PluginVersionResolutionException e )
         {
@@ -1150,6 +1169,10 @@
         {
             throw new LifecycleExecutionException( "Error resolving plugin version", e );
         }
+        catch ( InvalidPluginException e )
+        {
+            throw new LifecycleExecutionException( "Error resolving plugin version", e );
+        }
         return pluginDescriptor;
     }
 
@@ -1163,7 +1186,8 @@
         }
         catch ( PluginManagerException e )
         {
-            throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+            throw new LifecycleExecutionException(
+                "Internal error in the plugin manager getting report '" + plugin.getKey() + "': " + e.getMessage(), e );
         }
         catch ( PluginVersionResolutionException e )
         {
@@ -1173,6 +1197,10 @@
         {
             throw new LifecycleExecutionException( "Error resolving plugin version", e );
         }
+        catch ( InvalidPluginException e )
+        {
+            throw new LifecycleExecutionException( "Error resolving plugin version", e );
+        }
         return pluginDescriptor;
     }
 
@@ -1293,15 +1321,7 @@
             // 2. look in the repository via search groups
             if ( pluginDescriptor == null )
             {
-                try
-                {
-                    plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project );
-                }
-                catch ( PluginManagerException e )
-                {
-                    throw new LifecycleExecutionException(
-                        "Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e );
-                }
+                plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project );
             }
             else
             {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Wed Oct 12 23:50:22 2005
@@ -49,6 +49,7 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.project.path.PathTranslator;
 import org.apache.maven.reporting.MavenReport;
@@ -74,7 +75,6 @@
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -136,7 +136,6 @@
     }
 
     public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
-        throws PluginManagerException
     {
         // TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
         // use for the mapping manager in here
@@ -147,8 +146,8 @@
 
     public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
                                           ArtifactRepository localRepository )
-        throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
-        ArtifactNotFoundException, InvalidVersionSpecificationException
+        throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException
     {
         // TODO: this should be possibly outside
         // All version-resolution logic has been moved to DefaultPluginVersionManager.
@@ -164,8 +163,8 @@
 
     private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project,
                                                     ArtifactRepository localRepository )
-        throws PluginVersionResolutionException, PluginManagerException, ArtifactNotFoundException,
-        ArtifactResolutionException, InvalidVersionSpecificationException
+        throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException
     {
         // TODO: this might result in an artifact "RELEASE" being resolved continuously
         // FIXME: need to find out how a plugin gets marked as 'installed'
@@ -239,7 +238,7 @@
      * manager which executes before the plugin is instantiated
      */
     private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
-        throws PluginVersionResolutionException, PluginManagerException
+        throws PluginVersionResolutionException
     {
         try
         {
@@ -264,15 +263,11 @@
             throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
                                                         "Unable to build project for plugin", e );
         }
-        catch ( IOException e )
-        {
-            throw new PluginManagerException( "Unable to determine Maven version for comparison", e );
-        }
     }
 
     protected void addPlugin( Plugin plugin, Artifact pluginArtifact, MavenProject project,
                               ArtifactRepository localRepository )
-        throws ArtifactResolutionException, PluginManagerException, ArtifactNotFoundException
+        throws PluginManagerException, InvalidPluginException
     {
         PlexusContainer child;
         try
@@ -284,7 +279,8 @@
         }
         catch ( PlexusContainerException e )
         {
-            throw new PluginManagerException( "Failed to create plugin container for plugin '" + plugin + "'", e );
+            throw new PluginManagerException(
+                "Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e );
         }
 
         // this plugin's descriptor should have been discovered in the child creation, so we should be able to
@@ -305,9 +301,9 @@
 
             addedPlugin.setIntroducedDependencyArtifacts( artifacts );
         }
-        catch ( ProjectBuildingException e )
+        catch ( InvalidDependencyVersionException e )
         {
-            throw new PluginManagerException( "Error getting plugin dependencies", e );
+            throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e );
         }
     }
 
@@ -316,8 +312,8 @@
     // ----------------------------------------------------------------------
 
     public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
-        throws ArtifactResolutionException, PluginManagerException, MojoExecutionException, MojoFailureException,
-        ArtifactNotFoundException
+        throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException,
+        InvalidDependencyVersionException, PluginManagerException
     {
         MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
 
@@ -352,16 +348,8 @@
             for ( Iterator i = projects.iterator(); i.hasNext(); )
             {
                 MavenProject p = (MavenProject) i.next();
-                try
-                {
-                    resolveTransitiveDependencies( session, artifactResolver,
-                                                   mojoDescriptor.isDependencyResolutionRequired(), artifactFactory,
-                                                   p );
-                }
-                catch ( ProjectBuildingException e )
-                {
-                    throw new PluginManagerException( e.getMessage(), e );
-                }
+                resolveTransitiveDependencies( session, artifactResolver,
+                                               mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p );
             }
 
             downloadDependencies( project, session, artifactResolver );
@@ -393,10 +381,6 @@
             String msg = "Error configuring plugin for execution of '" + goalName + "'.";
             throw new MojoExecutionException( msg, e );
         }
-        catch ( ComponentLookupException e )
-        {
-            throw new MojoExecutionException( "Error looking up mojo: " + goalName, e );
-        }
 
         // Event monitoring.
         String event = MavenEvents.MOJO_EXECUTION;
@@ -456,7 +440,7 @@
     }
 
     public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
-        throws PluginManagerException, ArtifactNotFoundException
+        throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException
     {
         MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
         PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();
@@ -467,25 +451,12 @@
             dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
         }
 
-        MavenReport reportMojo;
-        try
-        {
-            reportMojo = (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new PluginManagerException( "Error looking up report: ", e );
-        }
-        catch ( PluginConfigurationException e )
-        {
-            throw new PluginManagerException( "Error configuring report: ", e );
-        }
-        return reportMojo;
+        return (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
     }
 
     public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
-        throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
-        ArtifactNotFoundException, InvalidVersionSpecificationException
+        throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException
     {
         String version = reportPlugin.getVersion();
 
@@ -516,7 +487,7 @@
 
         if ( pluginContainer == null )
         {
-            throw new PluginManagerException( "Cannot find PlexusContainer for plugin: " + pluginKey );
+            throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey );
         }
 
         return pluginContainer;
@@ -524,7 +495,7 @@
 
     private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report,
                                     MojoExecution mojoExecution )
-        throws ComponentLookupException, PluginConfigurationException, PluginManagerException, ArtifactNotFoundException
+        throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException
     {
         MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
 
@@ -537,11 +508,20 @@
         // dependencies, and add them to the container.
         ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );
 
-        Mojo plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
-        if ( report && !( plugin instanceof MavenReport ) )
+        Mojo plugin;
+        try
+        {
+            plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
+            if ( report && !( plugin instanceof MavenReport ) )
+            {
+                // TODO: the mojoDescriptor should actually capture this information so we don't get this far
+                return null;
+            }
+        }
+        catch ( ComponentLookupException e )
         {
-            // TODO: the mojoDescriptor should actually capture this information so we don't get this far
-            return null;
+            throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getRoleHint() +
+                "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e );
         }
 
         if ( plugin instanceof ContextEnabled )
@@ -1155,7 +1135,7 @@
 
     private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver, String scope,
                                                 ArtifactFactory artifactFactory, MavenProject project )
-        throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException
+        throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException
     {
         ArtifactFilter filter = new ScopeArtifactFilter( scope );
 
@@ -1197,7 +1177,7 @@
     }
 
     public Object getPluginComponent( Plugin plugin, String role, String roleHint )
-        throws ComponentLookupException, PluginManagerException
+        throws PluginManagerException, ComponentLookupException
     {
         PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );
 

Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java?rev=320675&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java Wed Oct 12 23:50:22 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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.
+ */
+
+/**
+ * Thrown when a plugin is not internally consistent.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class InvalidPluginException
+    extends Exception
+{
+    public InvalidPluginException( String message, Exception e )
+    {
+        super( message, e );
+    }
+}

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Wed Oct 12 23:50:22 2005
@@ -26,6 +26,7 @@
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -41,28 +42,27 @@
     String ROLE = PluginManager.class.getName();
 
     void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
-        throws MojoExecutionException, PluginManagerException, ArtifactResolutionException, MojoFailureException,
-        ArtifactNotFoundException;
+        throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException,
+        InvalidDependencyVersionException, PluginManagerException;
 
     MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
-        throws PluginManagerException, ArtifactNotFoundException;
+        throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException;
 
     PluginDescriptor getPluginDescriptorForPrefix( String prefix );
 
-    Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
-        throws PluginManagerException;
+    Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project );
 
     PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
                                    ArtifactRepository localRepository )
-        throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
-        ArtifactNotFoundException, InvalidVersionSpecificationException;
+        throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException;
 
     PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
-        throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
-        ArtifactNotFoundException, InvalidVersionSpecificationException;
+        throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException;
 
     Object getPluginComponent( Plugin plugin, String role, String roleHint )
-        throws ComponentLookupException, PluginManagerException;
+        throws PluginManagerException, ComponentLookupException;
 
     Map getPluginComponents( Plugin plugin, String role )
         throws ComponentLookupException, PluginManagerException;

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java Wed Oct 12 23:50:22 2005
@@ -696,11 +696,6 @@
             throw new PluginVersionResolutionException( groupId, artifactId,
                                                         "Unable to build resolve plugin project information", e );
         }
-        catch ( IOException e )
-        {
-            throw new PluginVersionResolutionException( groupId, artifactId,
-                                                        "Unable to determine Maven version for comparison", e );
-        }
 
         return version;
     }

Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java Wed Oct 12 23:50:22 2005
@@ -23,6 +23,7 @@
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.InvalidPluginException;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.PluginManager;
@@ -276,15 +277,7 @@
 
             if ( descriptor == null )
             {
-                try
-                {
-                    forLookup = pluginManager.getPluginDefinitionForPrefix( pi.prefix, session, project );
-                }
-                catch ( PluginManagerException e )
-                {
-                    throw new MojoExecutionException(
-                        "Cannot resolve plugin-prefix: \'" + pi.prefix + "\' from plugin mappings metadata.", e );
-                }
+                forLookup = pluginManager.getPluginDefinitionForPrefix( pi.prefix, session, project );
             }
         }
         else if ( pi.groupId != null && pi.artifactId != null )
@@ -332,6 +325,11 @@
                     "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
             }
             catch ( InvalidVersionSpecificationException e )
+            {
+                throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId +
+                    "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
+            }
+            catch ( InvalidPluginException e )
             {
                 throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId +
                     "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Wed Oct 12 23:50:22 2005
@@ -51,6 +51,7 @@
 import org.apache.maven.profiles.ProfilesConversionUtils;
 import org.apache.maven.profiles.ProfilesRoot;
 import org.apache.maven.profiles.activation.ProfileActivationException;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
 import org.apache.maven.project.injection.ModelDefaultsInjector;
 import org.apache.maven.project.injection.ProfileInjector;
@@ -191,7 +192,16 @@
 
         ensureMetadataSourceIsInitialized();
 
-        project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
+        try
+        {
+            project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
+        }
+        catch ( InvalidDependencyVersionException e )
+        {
+            throw new ProjectBuildingException( projectId,
+                                                "Unable to build project due to an invalid dependency version: " +
+                                                    e.getMessage(), e );
+        }
 
         if ( transferListener != null )
         {

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Wed Oct 12 23:50:22 2005
@@ -45,6 +45,7 @@
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.project.artifact.ActiveProjectArtifact;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.project.overlay.BuildOverlay;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
@@ -1405,7 +1406,7 @@
      */
     public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope,
                                 ArtifactFilter dependencyFilter )
-        throws ProjectBuildingException
+        throws InvalidDependencyVersionException
     {
         return MavenMetadataSource.createArtifacts( artifactFactory, getDependencies(), inheritedScope,
                                                     dependencyFilter, this );

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java?rev=320675&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java Wed Oct 12 23:50:22 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.project.artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * Thrown if a dependency has an invalid version.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class InvalidDependencyVersionException
+    extends Exception
+{
+    public InvalidDependencyVersionException( String message, Exception cause )
+    {
+        super( message, cause );
+    }
+}

Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=320675&r1=320674&r2=320675&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Wed Oct 12 23:50:22 2005
@@ -17,7 +17,6 @@
  */
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -206,6 +205,10 @@
         {
             throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
         }
+        catch ( InvalidDependencyVersionException e )
+        {
+            throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
+        }
     }
 
     private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
@@ -259,7 +262,7 @@
      */
     public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope,
                                        ArtifactFilter dependencyFilter, MavenProject project )
-        throws ProjectBuildingException
+        throws InvalidDependencyVersionException
     {
         Set projectArtifacts = new HashSet( dependencies.size() );
 
@@ -283,10 +286,7 @@
             }
             catch ( InvalidVersionSpecificationException e )
             {
-                String projectId = project != null ? ArtifactUtils.versionlessKey( project.getGroupId(),
-                                                                                   project.getArtifactId() )
-                    : "unknown";
-                throw new ProjectBuildingException( projectId, "Unable to parse version '" + d.getVersion() +
+                throw new InvalidDependencyVersionException( "Unable to parse version '" + d.getVersion() +
                     "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e );
             }
             Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),



Mime
View raw message