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/13 07:31:10 UTC

svn commit: r320668 [2/3] - in /maven/components/trunk: maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/ maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/ maven-artifact/src/main/java/org/apache/maven/artifact/reso...

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=320668&r1=320667&r2=320668&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 22:30:22 2005
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.maven.BuildFailureException;
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -45,7 +46,6 @@
 import org.apache.maven.plugin.lifecycle.Phase;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.reactor.ReactorException;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusContainerException;
@@ -129,31 +129,20 @@
         {
             if ( goals.isEmpty() )
             {
+                // TODO: delete
                 throw new NoGoalsSpecifiedException( "You must specify at least one goal. Try 'install'" );
             }
 
             List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
 
             // TODO: probably don't want to do all this up front
-            for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
-            {
-                MavenProject project = (MavenProject) i.next();
-
-                for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); )
-                {
-                    Extension extension = (Extension) j.next();
-                    extensionManager.addExtension( extension, project, session.getLocalRepository() );
-                }
-
-                Map handlers = findArtifactTypeHandlers( project, session.getSettings(), session.getLocalRepository() );
-                artifactHandlerManager.addHandlers( handlers );
-            }
+            findExtensions( session );
 
             executeTaskSegments( taskSegments, rm, session, rootProject, dispatcher, response );
 
             if ( ReactorManager.FAIL_AT_END.equals( rm.getFailureBehavior() ) && rm.hasBuildFailures() )
             {
-                response.setException( new ReactorException( "One or more projects failed to build." ) );
+                response.setException( new BuildFailureException( "One or more projects failed to build." ) );
             }
         }
         catch ( MojoExecutionException e )
@@ -168,22 +157,6 @@
         {
             response.setException( e );
         }
-        catch ( PlexusContainerException e )
-        {
-            throw new LifecycleExecutionException( "Unable to initialise extensions", e );
-        }
-        catch ( PluginManagerException e )
-        {
-            throw new LifecycleExecutionException( "Unable to initialise extensions", e );
-        }
-        catch ( PluginVersionResolutionException e )
-        {
-            throw new LifecycleExecutionException( "Unable to initialise extensions", e );
-        }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            throw new LifecycleExecutionException( "Unable to initialise extensions", e );
-        }
         catch ( NoGoalsSpecifiedException e )
         {
             response.setException( e );
@@ -200,6 +173,31 @@
         return response;
     }
 
+    private void findExtensions( MavenSession session )
+        throws ArtifactNotFoundException, ArtifactResolutionException, LifecycleExecutionException
+    {
+        for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
+        {
+            MavenProject project = (MavenProject) i.next();
+
+            for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); )
+            {
+                Extension extension = (Extension) j.next();
+                try
+                {
+                    extensionManager.addExtension( extension, project, session.getLocalRepository() );
+                }
+                catch ( PlexusContainerException e )
+                {
+                    throw new LifecycleExecutionException( "Unable to initialise extensions", e );
+                }
+            }
+
+            Map handlers = findArtifactTypeHandlers( project, session.getSettings(), session.getLocalRepository() );
+            artifactHandlerManager.addHandlers( handlers );
+        }
+    }
+
     private void executeTaskSegments( List taskSegments, ReactorManager rm, MavenSession session,
                                       MavenProject rootProject, EventDispatcher dispatcher,
                                       MavenExecutionResponse response )
@@ -228,7 +226,8 @@
 
                     long buildStartTime = System.currentTimeMillis();
 
-                    dispatcher.dispatchStart( event, rootProject.getId() + " ( " + segment + " )" );
+                    String target = rootProject.getId() + " ( " + segment + " )";
+                    dispatcher.dispatchStart( event, target );
 
                     try
                     {
@@ -237,37 +236,17 @@
                         {
                             String task = (String) goalIterator.next();
 
-                            try
-                            {
-                                executeGoal( task, session, rootProject, response );
-                            }
-                            catch ( MojoExecutionException e )
-                            {
-                                // TODO: should this be removed?
-                                handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
-                            }
-                            catch ( ArtifactResolutionException e )
-                            {
-                                // TODO: should this be removed?
-                                handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
-                            }
-                            catch ( MojoFailureException e )
-                            {
-                                handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
-                            }
-                            catch ( ArtifactNotFoundException e )
-                            {
-                                handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
-                            }
+                            executeGoalAndHandleFailures( task, session, rootProject, response, dispatcher, event, rm,
+                                                          buildStartTime, target );
                         }
 
                         rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime );
 
-                        dispatcher.dispatchEnd( event, rootProject.getId() + " ( " + segment + " )" );
+                        dispatcher.dispatchEnd( event, target );
                     }
                     catch ( LifecycleExecutionException e )
                     {
-                        dispatcher.dispatchError( event, rootProject.getId() + " ( " + segment + " )", e );
+                        dispatcher.dispatchError( event, target, e );
 
                         throw e;
                     }
@@ -313,7 +292,8 @@
 
                         long buildStartTime = System.currentTimeMillis();
 
-                        dispatcher.dispatchStart( event, currentProject.getId() + " ( " + segment + " )" );
+                        String target = currentProject.getId() + " ( " + segment + " )";
+                        dispatcher.dispatchStart( event, target );
 
                         try
                         {
@@ -321,37 +301,17 @@
                             {
                                 String task = (String) goalIterator.next();
 
-                                try
-                                {
-                                    executeGoal( task, session, currentProject, response );
-                                }
-                                catch ( MojoExecutionException e )
-                                {
-                                    // TODO: should this be removed?
-                                    handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
-                                }
-                                catch ( ArtifactResolutionException e )
-                                {
-                                    // TODO: should this be removed?
-                                    handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
-                                }
-                                catch ( MojoFailureException e )
-                                {
-                                    handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
-                                }
-                                catch ( ArtifactNotFoundException e )
-                                {
-                                    handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
-                                }
+                                executeGoalAndHandleFailures( task, session, currentProject, response, dispatcher,
+                                                              event, rm, buildStartTime, target );
                             }
 
                             rm.registerBuildSuccess( currentProject, System.currentTimeMillis() - buildStartTime );
 
-                            dispatcher.dispatchEnd( event, currentProject.getId() + " ( " + segment + " )" );
+                            dispatcher.dispatchEnd( event, target );
                         }
                         catch ( LifecycleExecutionException e )
                         {
-                            dispatcher.dispatchError( event, currentProject.getId() + " ( " + segment + " )", e );
+                            dispatcher.dispatchError( event, target, e );
 
                             throw e;
                         }
@@ -374,6 +334,44 @@
         }
     }
 
+    private void executeGoalAndHandleFailures( String task, MavenSession session, MavenProject project,
+                                               MavenExecutionResponse response, EventDispatcher dispatcher,
+                                               String event, ReactorManager rm, long buildStartTime, String target )
+        throws LifecycleExecutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException,
+        ArtifactResolutionException
+    {
+        try
+        {
+            executeGoal( task, session, project, response );
+        }
+        catch ( MojoExecutionException e )
+        {
+            dispatcher.dispatchError( event, target, e );
+
+            handleExecutionFailure( rm, project, e, task, buildStartTime );
+        }
+        catch ( ArtifactResolutionException e )
+        {
+            dispatcher.dispatchError( event, target, e );
+
+            handleExecutionFailure( rm, project, e, task, buildStartTime );
+        }
+        catch ( MojoFailureException e )
+        {
+            // TODO: should be dispatchFailure?
+            dispatcher.dispatchError( event, target, e );
+
+            handleExecutionFailure( rm, project, e, task, buildStartTime );
+        }
+        catch ( ArtifactNotFoundException 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,
                                          long buildStartTime )
         throws MojoExecutionException, MojoFailureException, ArtifactNotFoundException, ArtifactResolutionException
@@ -600,7 +598,8 @@
             }
             catch ( PluginManagerException e )
             {
-                throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+                throw new LifecycleExecutionException(
+                    "Internal error in the plugin manager executing goal '" + mojoDescriptor.getId(), e );
             }
         }
     }
@@ -672,30 +671,19 @@
 
                 List reportSets = reportPlugin.getReportSets();
 
-                try
+                if ( reportSets == null || reportSets.isEmpty() )
                 {
-                    if ( reportSets == null || reportSets.isEmpty() )
-                    {
-                        reports.addAll( getReports( reportPlugin, null, project, session, mojoExecution ) );
-                    }
-                    else
+                    reports.addAll( getReports( reportPlugin, null, project, session, mojoExecution ) );
+                }
+                else
+                {
+                    for ( Iterator j = reportSets.iterator(); j.hasNext(); )
                     {
-                        for ( Iterator j = reportSets.iterator(); j.hasNext(); )
-                        {
-                            ReportSet reportSet = (ReportSet) j.next();
+                        ReportSet reportSet = (ReportSet) j.next();
 
-                            reports.addAll( getReports( reportPlugin, reportSet, project, session, mojoExecution ) );
-                        }
+                        reports.addAll( getReports( reportPlugin, reportSet, project, session, mojoExecution ) );
                     }
                 }
-                catch ( PluginManagerException e )
-                {
-                    throw new LifecycleExecutionException( "Error getting reports", e );
-                }
-                catch ( PluginVersionResolutionException e )
-                {
-                    throw new LifecycleExecutionException( "Error getting reports", e );
-                }
             }
         }
         return reports;
@@ -703,10 +691,9 @@
 
     private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
                              MojoExecution mojoExecution )
-        throws PluginManagerException, PluginVersionResolutionException, ArtifactResolutionException,
-        ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException
     {
-        PluginDescriptor pluginDescriptor = pluginManager.verifyReportPlugin( reportPlugin, project, session );
+        PluginDescriptor pluginDescriptor = verifyReportPlugin( reportPlugin, project, session );
 
         List reports = new ArrayList();
         for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
@@ -725,13 +712,21 @@
 
                 MojoExecution reportExecution = new MojoExecution( mojoDescriptor, id );
 
-                MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session );
+                try
+                {
+                    MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session );
 
-                // Comes back null if it was a plugin, not a report - these are mojos in the reporting plugins that are not reports
-                if ( reportMojo != null )
+                    // Comes back null if it was a plugin, not a report - these are mojos in the reporting plugins that are not reports
+                    if ( reportMojo != null )
+                    {
+                        reports.add( reportMojo );
+                        mojoExecution.addMojoExecution( reportExecution );
+                    }
+                }
+                catch ( PluginManagerException e )
                 {
-                    reports.add( reportMojo );
-                    mojoExecution.addMojoExecution( reportExecution );
+                    throw new LifecycleExecutionException(
+                        "Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
                 }
             }
         }
@@ -796,11 +791,13 @@
                 }
                 catch ( IOException e )
                 {
-                    throw new LifecycleExecutionException( "Unable to read lifecycle mapping file", e );
+                    throw new LifecycleExecutionException( "Unable to read lifecycle mapping file: " + e.getMessage(),
+                                                           e );
                 }
                 catch ( XmlPullParserException e )
                 {
-                    throw new LifecycleExecutionException( "Unable to parse lifecycle mapping file", e );
+                    throw new LifecycleExecutionException( "Unable to parse lifecycle mapping file: " + e.getMessage(),
+                                                           e );
                 }
 
                 if ( lifecycleOverlay == null )
@@ -866,8 +863,8 @@
 
         if ( desc == null )
         {
-            String message = "Required goal '" + goal + "' not found in plugin '" + pluginDescriptor.getGoalPrefix() +
-                "'";
+            String message =
+                "Required goal '" + goal + "' not found in plugin '" + pluginDescriptor.getGoalPrefix() + "'";
             int index = goal.indexOf( ':' );
             if ( index >= 0 )
             {
@@ -889,8 +886,8 @@
         String mojoIdWithVersion = pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":" +
             pluginDescriptor.getVersion() + ":" + mojoDescriptor.getGoal();
 
-        String mojoIdWithoutVersion = pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":" +
-            mojoDescriptor.getGoal();
+        String mojoIdWithoutVersion =
+            pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":" + mojoDescriptor.getGoal();
 
         for ( Iterator it = lifecycleMappings.values().iterator(); it.hasNext(); )
         {
@@ -972,25 +969,11 @@
         String packaging = project.getPackaging();
         Map mappings = null;
 
-        try
-        {
-            LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging,
-                                                                   session.getSettings(),
-                                                                   session.getLocalRepository() );
-            if ( m != null )
-            {
-                mappings = m.getPhases( lifecycle.getId() );
-            }
-        }
-        catch ( PluginVersionResolutionException e )
-        {
-            throw new LifecycleExecutionException(
-                "Cannot load extension plugin obtaining lifecycle mappings for: \'" + packaging + "\'.", e );
-        }
-        catch ( PluginManagerException e )
+        LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging,
+                                                               session.getSettings(), session.getLocalRepository() );
+        if ( m != null )
         {
-            throw new LifecycleExecutionException(
-                "Cannot load extension plugin obtaining lifecycle mappings for: \'" + packaging + "\'.", e );
+            mappings = m.getPhases( lifecycle.getId() );
         }
 
         Map defaultMappings = lifecycle.getDefaultPhases();
@@ -999,7 +982,7 @@
         {
             try
             {
-                LifecycleMapping m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
+                m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
                 mappings = m.getPhases( lifecycle.getId() );
             }
             catch ( ComponentLookupException e )
@@ -1030,8 +1013,7 @@
 
     private Object findExtension( MavenProject project, String role, String roleHint, Settings settings,
                                   ArtifactRepository localRepository )
-        throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
-        ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException
     {
         for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
         {
@@ -1039,7 +1021,7 @@
 
             if ( plugin.isExtensions() )
             {
-                pluginManager.verifyPlugin( plugin, project, settings, localRepository );
+                verifyPlugin( plugin, project, settings, localRepository );
 
                 // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
                 try
@@ -1050,6 +1032,11 @@
                 {
                     getLogger().debug( "Unable to find the lifecycle component in the extension", e );
                 }
+                catch ( PluginManagerException e )
+                {
+                    throw new LifecycleExecutionException(
+                        "Error getting extensions from the plugin '" + plugin.getKey() + "'", e );
+                }
             }
         }
         return null;
@@ -1060,8 +1047,7 @@
      * lookup directly, or have them passed in
      */
     private Map findArtifactTypeHandlers( MavenProject project, Settings settings, ArtifactRepository localRepository )
-        throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
-        ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException
     {
         Map map = new HashMap();
         for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
@@ -1070,28 +1056,32 @@
 
             if ( plugin.isExtensions() )
             {
-                pluginManager.verifyPlugin( plugin, project, settings, localRepository );
+                verifyPlugin( plugin, project, settings, localRepository );
 
                 // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
                 try
                 {
                     Map components = pluginManager.getPluginComponents( plugin, ArtifactHandler.ROLE );
                     map.putAll( components );
-
-                    // shudder...
-                    for ( Iterator j = map.values().iterator(); j.hasNext(); )
-                    {
-                        ArtifactHandler handler = (ArtifactHandler) j.next();
-                        if ( project.getPackaging().equals( handler.getPackaging() ) )
-                        {
-                            project.getArtifact().setArtifactHandler( handler );
-                        }
-                    }
                 }
                 catch ( ComponentLookupException e )
                 {
                     getLogger().debug( "Unable to find the lifecycle component in the extension", e );
                 }
+                catch ( PluginManagerException e )
+                {
+                    throw new LifecycleExecutionException( "Error looking up available components from a plugin", e );
+                }
+
+                // shudder...
+                for ( Iterator j = map.values().iterator(); j.hasNext(); )
+                {
+                    ArtifactHandler handler = (ArtifactHandler) j.next();
+                    if ( project.getPackaging().equals( handler.getPackaging() ) )
+                    {
+                        project.getArtifact().setArtifactHandler( handler );
+                    }
+                }
             }
         }
         return map;
@@ -1111,7 +1101,7 @@
         PluginDescriptor pluginDescriptor;
         Settings settings = session.getSettings();
 
-        pluginDescriptor = verifyPlugin( plugin, session, project );
+        pluginDescriptor = verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() );
 
         if ( pluginDescriptor.getMojos() != null && !pluginDescriptor.getMojos().isEmpty() )
         {
@@ -1139,14 +1129,14 @@
         }
     }
 
-    private PluginDescriptor verifyPlugin( Plugin plugin, MavenSession session, MavenProject project )
+    private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
+                                           ArtifactRepository localRepository )
         throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
     {
         PluginDescriptor pluginDescriptor;
         try
         {
-            ArtifactRepository localRepository = session.getLocalRepository();
-            pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session.getSettings(), localRepository );
+            pluginDescriptor = pluginManager.verifyPlugin( plugin, project, settings, localRepository );
         }
         catch ( PluginManagerException e )
         {
@@ -1156,6 +1146,33 @@
         {
             throw new LifecycleExecutionException( "Error resolving plugin version", e );
         }
+        catch ( InvalidVersionSpecificationException e )
+        {
+            throw new LifecycleExecutionException( "Error resolving plugin version", e );
+        }
+        return pluginDescriptor;
+    }
+
+    private PluginDescriptor verifyReportPlugin( ReportPlugin plugin, MavenProject project, MavenSession session )
+        throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
+    {
+        PluginDescriptor pluginDescriptor;
+        try
+        {
+            pluginDescriptor = pluginManager.verifyReportPlugin( plugin, project, session );
+        }
+        catch ( PluginManagerException e )
+        {
+            throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+        }
+        catch ( PluginVersionResolutionException e )
+        {
+            throw new LifecycleExecutionException( "Error resolving plugin version", e );
+        }
+        catch ( InvalidVersionSpecificationException e )
+        {
+            throw new LifecycleExecutionException( "Error resolving plugin version", e );
+        }
         return pluginDescriptor;
     }
 
@@ -1302,22 +1319,11 @@
                 {
                     Plugin buildPlugin = (Plugin) i.next();
 
-                    try
+                    PluginDescriptor desc =
+                        verifyPlugin( buildPlugin, project, session.getSettings(), session.getLocalRepository() );
+                    if ( prefix.equals( desc.getGoalPrefix() ) )
                     {
-                        PluginDescriptor desc = pluginManager.verifyPlugin( buildPlugin, project, session.getSettings(),
-                                                                            session.getLocalRepository() );
-                        if ( prefix.equals( desc.getGoalPrefix() ) )
-                        {
-                            plugin = buildPlugin;
-                        }
-                    }
-                    catch ( PluginManagerException e )
-                    {
-                        throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
-                    }
-                    catch ( PluginVersionResolutionException e )
-                    {
-                        throw new LifecycleExecutionException( "Error resolving plugin version", e );
+                        plugin = buildPlugin;
                     }
                 }
             }
@@ -1364,19 +1370,7 @@
 
         if ( pluginDescriptor == null )
         {
-            try
-            {
-                pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session.getSettings(),
-                                                               session.getLocalRepository() );
-            }
-            catch ( PluginManagerException e )
-            {
-                throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
-            }
-            catch ( PluginVersionResolutionException e )
-            {
-                throw new LifecycleExecutionException( "Error resolving plugin version", e );
-            }
+            pluginDescriptor = verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() );
         }
 
         // this has been simplified from the old code that injected the plugin management stuff, since

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=320668&r1=320667&r2=320668&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 22:30:22 2005
@@ -148,7 +148,7 @@
     public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
                                           ArtifactRepository localRepository )
         throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidVersionSpecificationException
     {
         // TODO: this should be possibly outside
         // All version-resolution logic has been moved to DefaultPluginVersionManager.
@@ -165,7 +165,7 @@
     private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project,
                                                     ArtifactRepository localRepository )
         throws PluginVersionResolutionException, PluginManagerException, ArtifactNotFoundException,
-        ArtifactResolutionException
+        ArtifactResolutionException, InvalidVersionSpecificationException
     {
         // TODO: this might result in an artifact "RELEASE" being resolved continuously
         // FIXME: need to find out how a plugin gets marked as 'installed'
@@ -180,35 +180,31 @@
             remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
 
             checkRequiredMavenVersion( plugin, localRepository, remoteRepositories );
-            
-            Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(),
-                                                                            plugin.getArtifactId(), versionRange );
-            
+
+            Artifact pluginArtifact =
+                artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
+
             pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
 
             artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
 
-            if ( !pluginArtifact.isResolved() )
-            {
-                throw new PluginContainerException( plugin, "Cannot resolve artifact for plugin." );
-            }
-
             PlexusContainer pluginContainer = container.getChildContainer( plugin.getKey() );
-            
+
             File pluginFile = pluginArtifact.getFile();
-            
+
             if ( !pluginCollector.isPluginInstalled( plugin ) || pluginContainer == null )
             {
                 addPlugin( plugin, pluginArtifact, project, localRepository );
             }
             else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() )
             {
-                getLogger().info( "Reloading plugin container for: " + plugin.getKey() + ". The plugin artifact has changed." );
-                
+                getLogger().info(
+                    "Reloading plugin container for: " + plugin.getKey() + ". The plugin artifact has changed." );
+
                 pluginContainer.dispose();
-                
+
                 pluginCollector.flushPluginDescriptor( plugin );
-                
+
                 addPlugin( plugin, pluginArtifact, project, localRepository );
             }
 
@@ -234,12 +230,7 @@
                 throw e;
             }
         }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
-                                                        "Invalid version specification", e );
-        }
-        
+
         return pluginCollector.getPluginDescriptor( plugin );
     }
 
@@ -254,13 +245,13 @@
         {
             Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(),
                                                                        plugin.getVersion() );
-            MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
-                                                                            localRepository, false );
+            MavenProject project =
+                mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository, false );
             // if we don't have the required Maven version, then ignore an update
             if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
             {
-                DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
-                    project.getPrerequisites().getMaven() );
+                DefaultArtifactVersion requiredVersion =
+                    new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
                 if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
                 {
                     throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
@@ -293,7 +284,7 @@
         }
         catch ( PlexusContainerException e )
         {
-            throw new PluginContainerException( plugin, "Failed to create plugin container.", e );
+            throw new PluginManagerException( "Failed to create plugin container for plugin '" + plugin + "'", e );
         }
 
         // this plugin's descriptor should have been discovered in the child creation, so we should be able to
@@ -309,13 +300,14 @@
 
         try
         {
-            Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null,
-                                                                 project );
+            Set artifacts =
+                MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null, project );
+
             addedPlugin.setIntroducedDependencyArtifacts( artifacts );
         }
-        catch ( InvalidVersionSpecificationException e )
+        catch ( ProjectBuildingException e )
         {
-            throw new PluginManagerException( "Unable to get one of the plugins additional dependencies", e );
+            throw new PluginManagerException( "Error getting plugin dependencies", e );
         }
     }
 
@@ -360,8 +352,16 @@
             for ( Iterator i = projects.iterator(); i.hasNext(); )
             {
                 MavenProject p = (MavenProject) i.next();
-                resolveTransitiveDependencies( session, artifactResolver,
-                                               mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p );
+                try
+                {
+                    resolveTransitiveDependencies( session, artifactResolver,
+                                                   mojoDescriptor.isDependencyResolutionRequired(), artifactFactory,
+                                                   p );
+                }
+                catch ( ProjectBuildingException e )
+                {
+                    throw new PluginManagerException( e.getMessage(), e );
+                }
             }
 
             downloadDependencies( project, session, artifactResolver );
@@ -485,7 +485,7 @@
 
     public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
         throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
-        ArtifactNotFoundException
+        ArtifactNotFoundException, InvalidVersionSpecificationException
     {
         String version = reportPlugin.getVersion();
 
@@ -518,7 +518,7 @@
         {
             throw new PluginManagerException( "Cannot find PlexusContainer for plugin: " + pluginKey );
         }
-        
+
         return pluginContainer;
     }
 
@@ -578,8 +578,8 @@
                                                                                           project,
                                                                                           session.getExecutionProperties() );
 
-        PlexusConfiguration extractedMojoConfiguration = extractMojoConfiguration( mergedConfiguration,
-                                                                                   mojoDescriptor );
+        PlexusConfiguration extractedMojoConfiguration =
+            extractMojoConfiguration( mergedConfiguration, mojoDescriptor );
 
         checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator );
 
@@ -671,8 +671,8 @@
 
             if ( artifactFile == null )
             {
-                String resource = "/META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() +
-                    "/pom.xml";
+                String resource =
+                    "/META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml";
 
                 URL resourceUrl = container.getContainerRealm().getResource( resource );
 
@@ -801,7 +801,7 @@
                 }
                 catch ( ExpressionEvaluationException e )
                 {
-                    throw new PluginConfigurationException( goal.getPluginDescriptor(), "Bad expression", e );
+                    throw new PluginConfigurationException( goal.getPluginDescriptor(), e.getMessage(), e );
                 }
 
                 // only mark as invalid if there are no child nodes
@@ -1045,8 +1045,8 @@
             // so that this meethod could entirely be handled by a plexus lookup?
             if ( StringUtils.isNotEmpty( configuratorId ) )
             {
-                configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE,
-                                                                               configuratorId );
+                configurator =
+                    (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId );
             }
             else
             {
@@ -1155,7 +1155,7 @@
 
     private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver, String scope,
                                                 ArtifactFactory artifactFactory, MavenProject project )
-        throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException
     {
         ArtifactFilter filter = new ScopeArtifactFilter( scope );
 
@@ -1165,18 +1165,10 @@
 
         // TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
         // check this with yourkit as a hot spot.
-        try
-        {
-            // Don't recreate if already created - for effeciency, and because clover plugin adds to it
-            if ( project.getDependencyArtifacts() == null )
-            {
-                project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
-            }
-        }
-        catch ( InvalidVersionSpecificationException e )
+        // Don't recreate if already created - for effeciency, and because clover plugin adds to it
+        if ( project.getDependencyArtifacts() == null )
         {
-            // TODO: should that exception be derived from ArtifactResolutionException instead?
-            throw new ArtifactResolutionException( e.getMessage(), artifact );
+            project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
         }
         ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
                                                                                 artifact, context.getLocalRepository(),

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java?rev=320668&r1=320667&r2=320668&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java Wed Oct 12 22:30:22 2005
@@ -1,7 +1,5 @@
 package org.apache.maven.plugin;
 
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
-
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
  *
@@ -18,6 +16,25 @@
  * limitations under the License.
  */
 
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.usability.diagnostics.DiagnosisUtils;
+import org.apache.maven.usability.plugin.Expression;
+import org.apache.maven.usability.plugin.ExpressionDocumentationException;
+import org.apache.maven.usability.plugin.ExpressionDocumenter;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
@@ -26,8 +43,12 @@
     extends Exception
 {
     private final PluginDescriptor pluginDescriptor;
+
     private String originalMessage;
 
+    private static final List UNMODIFIABLE_EXPRESSIONS = Arrays.asList(
+        new String[]{"localRepository", "reactorProjects", "settings", "project", "session", "plugin", "basedir"} );
+
     public PluginConfigurationException( PluginDescriptor pluginDescriptor, String message )
     {
         super( "Error configuring: " + pluginDescriptor.getPluginLookupKey() + ". Reason: " + message );
@@ -47,14 +68,217 @@
         this.pluginDescriptor = pluginDescriptor;
         this.originalMessage = message;
     }
-    
+
     public PluginDescriptor getPluginDescriptor()
     {
         return pluginDescriptor;
     }
-    
+
     public String getOriginalMessage()
     {
         return originalMessage;
+    }
+
+    protected static void addParameterUsageInfo( String expression, StringBuffer messageBuffer )
+    {
+        StringBuffer expressionMessageBuffer = new StringBuffer();
+
+        Matcher exprMatcher = Pattern.compile( "\\$\\{(.+)\\}" ).matcher( expression );
+
+        boolean unmodifiableElementsFound = false;
+        boolean activeElementsFound = false;
+
+        int elementCount = 0;
+
+        while ( exprMatcher.find() )
+        {
+            elementCount++;
+
+            activeElementsFound = true;
+
+            String subExpression = exprMatcher.group( 1 );
+
+            StringTokenizer expressionParts = new StringTokenizer( subExpression, "." );
+
+            String firstPart = expressionParts.nextToken();
+
+            Map expressions = null;
+            try
+            {
+                expressions = ExpressionDocumenter.load();
+            }
+            catch ( ExpressionDocumentationException e )
+            {
+                expressionMessageBuffer.append( "\n\nERROR!! Failed to load expression documentation!" );
+
+                StringWriter sWriter = new StringWriter();
+                PrintWriter pWriter = new PrintWriter( sWriter );
+
+                e.printStackTrace( pWriter );
+
+                expressionMessageBuffer.append( "\n\nException:\n\n" ).append( sWriter.toString() );
+            }
+
+            if ( expressions != null )
+            {
+                Expression expr = (Expression) expressions.get( subExpression );
+
+                if ( expr != null )
+                {
+                    if ( !expr.isEditable() )
+                    {
+                        unmodifiableElementsFound = true;
+                    }
+                    else
+                    {
+                        addParameterConfigDocumentation( firstPart, exprMatcher.group( 0 ), subExpression,
+                                                         expressionMessageBuffer, expressions );
+                    }
+                }
+                else if ( UNMODIFIABLE_EXPRESSIONS.contains( subExpression ) )
+                {
+                    unmodifiableElementsFound = true;
+                }
+                else
+                {
+                    expressionMessageBuffer.append( "on the command line, specify: \'-D" ).append( subExpression )
+                        .append( "=VALUE\'" );
+                }
+            }
+        }
+
+        if ( activeElementsFound )
+        {
+            messageBuffer.append( expressionMessageBuffer );
+        }
+        else
+        {
+            messageBuffer.append(
+                "    (found static expression: \'" + expression + "\' which may act as a default value).\n" );
+        }
+
+        if ( unmodifiableElementsFound )
+        {
+            if ( elementCount > 1 )
+            {
+                messageBuffer.append( "    " );
+            }
+
+            messageBuffer
+                .append( "NOTE: One or more purely derived expression elements were detected in \'" + expression +
+                    "\'.\n    If you continue to get this error after any other expression elements are specified correctly," +
+                    "\n    please report this issue to the Maven development team.\n" );
+        }
+    }
+
+    private static void addParameterConfigDocumentation( String firstPart, String wholeExpression, String subExpression,
+                                                         StringBuffer expressionMessageBuffer, Map expressionDoco )
+    {
+        Expression expr = (Expression) expressionDoco.get( subExpression );
+
+        if ( expr != null )
+        {
+            expressionMessageBuffer.append( "check that the following section of " );
+            if ( "project".equals( firstPart ) )
+            {
+                expressionMessageBuffer.append( "the pom.xml " );
+            }
+            else if ( "settings".equals( firstPart ) )
+            {
+                expressionMessageBuffer.append( "your ~/.m2/settings.xml file " );
+            }
+
+            expressionMessageBuffer.append( "is present and correct:\n\n" );
+
+            String message = expr.getConfiguration();
+
+            if ( message == null )
+            {
+                message = expr.getDescription();
+            }
+
+            expressionMessageBuffer.append( message );
+
+            Properties cliConfig = expr.getCliOptions();
+
+            if ( cliConfig != null && !cliConfig.isEmpty() )
+            {
+                expressionMessageBuffer.append( "\n\n-OR-\n\nUse the following command-line switches:\n" );
+
+                prettyPrintCommandLineSwitches( cliConfig, '.', expressionMessageBuffer );
+            }
+        }
+        else
+        {
+            expressionMessageBuffer.append( "ensure that the expression: \'" + wholeExpression + "\' is satisfied" );
+        }
+    }
+
+    private static void prettyPrintCommandLineSwitches( Properties switches, char filler,
+                                                        StringBuffer expressionMessageBuffer )
+    {
+        int maxKeyLen = 0;
+
+        for ( Iterator it = switches.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            String key = (String) entry.getKey();
+
+            int keyLen = key.length();
+            if ( keyLen > maxKeyLen )
+            {
+                maxKeyLen = keyLen;
+            }
+        }
+
+        final int minFillerCount = 4;
+
+        for ( Iterator it = switches.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            String key = (String) entry.getKey();
+
+            int keyLen = key.length();
+
+            int fillerCount = maxKeyLen - keyLen + minFillerCount;
+
+            expressionMessageBuffer.append( '\n' ).append( key ).append( ' ' );
+
+            for ( int i = 0; i < fillerCount; i++ )
+            {
+                expressionMessageBuffer.append( filler );
+            }
+
+            expressionMessageBuffer.append( ' ' ).append( entry.getValue() );
+        }
+
+        expressionMessageBuffer.append( '\n' );
+    }
+
+    public String buildConfigurationDiagnosticMessage( ComponentConfigurationException cce )
+    {
+        StringBuffer message = new StringBuffer();
+
+        PluginDescriptor descriptor = getPluginDescriptor();
+
+        PlexusConfiguration failedConfiguration = cce.getFailedConfiguration();
+
+        message.append( "Failed to configure plugin parameters for: " + descriptor.getId() + "\n\n" );
+
+        if ( failedConfiguration != null )
+        {
+            String value = failedConfiguration.getValue( null );
+            addParameterUsageInfo( value, message );
+        }
+
+        message.append( "Reason: " ).append( cce.getMessage() ).append( "\n" );
+
+        Throwable root = DiagnosisUtils.getRootCause( cce );
+
+        message.append( "Root Cause: " ).append( root.getMessage() ).append( "\n\n" );
+
+        return message.toString();
     }
 }

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=320668&r1=320667&r2=320668&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 22:30:22 2005
@@ -19,6 +19,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.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.ReportPlugin;
@@ -54,11 +55,11 @@
     PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
                                    ArtifactRepository localRepository )
         throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
-        ArtifactNotFoundException;
+        ArtifactNotFoundException, InvalidVersionSpecificationException;
 
     PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
         throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
-        ArtifactNotFoundException;
+        ArtifactNotFoundException, InvalidVersionSpecificationException;
 
     Object getPluginComponent( Plugin plugin, String role, String roleHint )
         throws ComponentLookupException, PluginManagerException;

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java?rev=320668&r1=320667&r2=320668&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java Wed Oct 12 22:30:22 2005
@@ -17,7 +17,10 @@
  */
 
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.codehaus.plexus.util.StringUtils;
 
+import java.util.Iterator;
 import java.util.List;
 
 public class PluginParameterException
@@ -30,7 +33,8 @@
 
     public PluginParameterException( MojoDescriptor mojo, List parameters )
     {
-        super( mojo.getPluginDescriptor(), "Invalid or missing parameters: " + parameters + " for mojo: " + mojo.getRoleHint() );
+        super( mojo.getPluginDescriptor(),
+               "Invalid or missing parameters: " + parameters + " for mojo: " + mojo.getRoleHint() );
 
         this.mojo = mojo;
 
@@ -39,7 +43,8 @@
 
     public PluginParameterException( MojoDescriptor mojo, List parameters, Throwable cause )
     {
-        super( mojo.getPluginDescriptor(), "Invalid or missing parameters: " + parameters + " for mojo: " + mojo.getRoleHint(), cause );
+        super( mojo.getPluginDescriptor(),
+               "Invalid or missing parameters: " + parameters + " for mojo: " + mojo.getRoleHint(), cause );
 
         this.mojo = mojo;
 
@@ -56,4 +61,63 @@
         return parameters;
     }
 
+    private static void decomposeParameterIntoUserInstructions( MojoDescriptor mojo, Parameter param,
+                                                                StringBuffer messageBuffer )
+    {
+        String expression = param.getExpression();
+
+        if ( param.isEditable() )
+        {
+            messageBuffer.append( "inside the definition for plugin: \'" + mojo.getPluginDescriptor().getArtifactId() +
+                "\'specify the following:\n\n<configuration>\n  ...\n  <" + param.getName() + ">VALUE</" +
+                param.getName() + ">\n</configuration>" );
+
+            String alias = param.getAlias();
+            if ( StringUtils.isNotEmpty( alias ) )
+            {
+                messageBuffer.append(
+                    "\n\n-OR-\n\n<configuration>\n  ...\n  <" + alias + ">VALUE</" + alias + ">\n</configuration>\n" );
+            }
+        }
+
+        if ( StringUtils.isEmpty( expression ) )
+        {
+            messageBuffer.append( "." );
+        }
+        else
+        {
+            if ( param.isEditable() )
+            {
+                messageBuffer.append( "\n\n-OR-\n\n" );
+            }
+
+            addParameterUsageInfo( expression, messageBuffer );
+        }
+    }
+
+    public String buildDiagnosticMessage()
+    {
+        StringBuffer messageBuffer = new StringBuffer();
+
+        List params = getParameters();
+        MojoDescriptor mojo = getMojoDescriptor();
+
+        messageBuffer.append( "One or more required plugin parameters are invalid/missing for \'" )
+            .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ":" ).append( mojo.getGoal() )
+            .append( "\'\n" );
+
+        int idx = 0;
+        for ( Iterator it = params.iterator(); it.hasNext(); idx++ )
+        {
+            Parameter param = (Parameter) it.next();
+
+            messageBuffer.append( "\n[" ).append( idx ).append( "] " );
+
+            decomposeParameterIntoUserInstructions( mojo, param, messageBuffer );
+
+            messageBuffer.append( "\n" );
+        }
+
+        return messageBuffer.toString();
+    }
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java?rev=320668&r1=320667&r2=320668&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java Wed Oct 12 22:30:22 2005
@@ -19,7 +19,6 @@
 public class PluginVersionResolutionException
     extends Exception
 {
-
     private final String groupId;
 
     private final String artifactId;

Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/MavenExecutionException.java (from r314825, maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/ReactorException.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/MavenExecutionException.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/MavenExecutionException.java&p1=maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/ReactorException.java&r1=314825&r2=320668&rev=320668&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/ReactorException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/MavenExecutionException.java Wed Oct 12 22:30:22 2005
@@ -20,24 +20,24 @@
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
  */
-public class ReactorException
+public class MavenExecutionException
     extends Exception
 {
-    public ReactorException()
+    public MavenExecutionException()
     {
     }
 
-    public ReactorException( String message )
+    public MavenExecutionException( String message )
     {
         super( message );
     }
 
-    public ReactorException( Throwable cause )
+    public MavenExecutionException( Throwable cause )
     {
         super( cause );
     }
 
-    public ReactorException( String message, Throwable cause )
+    public MavenExecutionException( String message, Throwable cause )
     {
         super( message, cause );
     }

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/reactor/MavenExecutionException.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.2

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

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

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java?rev=320668&r1=320667&r2=320668&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java Wed Oct 12 22:30:22 2005
@@ -18,50 +18,13 @@
 
 import org.apache.maven.plugin.PluginConfigurationException;
 import org.apache.maven.plugin.PluginParameterException;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.plugin.descriptor.Parameter;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.usability.diagnostics.DiagnosisUtils;
 import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
-import org.apache.maven.usability.plugin.Expression;
-import org.apache.maven.usability.plugin.ExpressionDocumentationException;
-import org.apache.maven.usability.plugin.ExpressionDocumenter;
 import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 public class PluginConfigurationDiagnoser
     implements ErrorDiagnoser
 {
-
-    private static final List UNMODIFIABLE_EXPRESSIONS;
-
-    static
-    {
-        List exprs = new ArrayList();
-
-        exprs.add( "localRepository" );
-        exprs.add( "reactorProjects" );
-        exprs.add( "settings" );
-        exprs.add( "project" );
-        exprs.add( "session" );
-        exprs.add( "plugin" );
-        exprs.add( "basedir" );
-
-        UNMODIFIABLE_EXPRESSIONS = exprs;
-    }
-
     public boolean canDiagnose( Throwable error )
     {
         return DiagnosisUtils.containsInCausality( error, PluginConfigurationException.class );
@@ -69,287 +32,25 @@
 
     public String diagnose( Throwable error )
     {
-        PluginConfigurationException pce = (PluginConfigurationException) DiagnosisUtils
-            .getFromCausality( error, PluginConfigurationException.class );
+        PluginConfigurationException pce =
+            (PluginConfigurationException) DiagnosisUtils.getFromCausality( error, PluginConfigurationException.class );
 
         if ( pce instanceof PluginParameterException )
         {
             PluginParameterException exception = (PluginParameterException) pce;
 
-            return buildParameterDiagnosticMessage( exception );
+            return exception.buildDiagnosticMessage();
         }
         else if ( DiagnosisUtils.containsInCausality( pce, ComponentConfigurationException.class ) )
         {
-            ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils
-                .getFromCausality( pce, ComponentConfigurationException.class );
-            
-            return buildConfigurationDiagnosticMessage( pce, cce );
-        }
-        else
-        {
-            return pce.getMessage();
-        }
-    }
+            ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils.getFromCausality(
+                pce, ComponentConfigurationException.class );
 
-    private String buildConfigurationDiagnosticMessage( PluginConfigurationException pce, ComponentConfigurationException cce )
-    {
-        StringBuffer message = new StringBuffer();
-        
-        PluginDescriptor descriptor = pce.getPluginDescriptor();
-
-        PlexusConfiguration failedConfiguration = cce.getFailedConfiguration();
-        
-        message.append( "Failed to configure plugin parameters for: " + descriptor.getId() + "\n\n" );
-        
-        if ( failedConfiguration != null )
-        {
-            String value = failedConfiguration.getValue( null );
-            addParameterUsageInfo( value, message );
-        }
-        
-        message.append( "Reason: " ).append( cce.getMessage() ).append( "\n" );
-        
-        Throwable root = DiagnosisUtils.getRootCause( cce );
-        
-        message.append( "Root Cause: " ).append( root.getMessage() ).append( "\n\n" );
-
-        return message.toString();
-    }
-
-    private String buildParameterDiagnosticMessage( PluginParameterException exception )
-    {
-        StringBuffer messageBuffer = new StringBuffer();
-
-        List params = exception.getParameters();
-        MojoDescriptor mojo = exception.getMojoDescriptor();
-
-        messageBuffer.append( "One or more required plugin parameters are invalid/missing for \'" )
-            .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ":" ).append( mojo.getGoal() )
-            .append( "\'\n" );
-
-        int idx = 0;
-        for ( Iterator it = params.iterator(); it.hasNext(); )
-        {
-            Parameter param = (Parameter) it.next();
-
-            messageBuffer.append( "\n[" ).append( idx++ ).append( "] " );
-
-            decomposeParameterIntoUserInstructions( mojo, param, messageBuffer );
-
-            messageBuffer.append( "\n" );
-        }
-
-        return messageBuffer.toString();
-    }
-
-    private void decomposeParameterIntoUserInstructions( MojoDescriptor mojo, Parameter param,
-                                                        StringBuffer messageBuffer )
-    {
-        String expression = param.getExpression();
-
-        if ( param.isEditable() )
-        {
-            messageBuffer.append( "inside the definition for plugin: \'" + mojo.getPluginDescriptor().getArtifactId()
-                + "\'specify the following:\n\n<configuration>\n  ...\n  <" + param.getName() + ">VALUE</"
-                + param.getName() + ">\n</configuration>" );
-
-            String alias = param.getAlias();
-            if ( StringUtils.isNotEmpty( alias ) )
-            {
-                messageBuffer.append( "\n\n-OR-\n\n<configuration>\n  ...\n  <" + alias + ">VALUE</" + alias
-                    + ">\n</configuration>\n" );
-            }
-        }
-
-        if ( StringUtils.isEmpty( expression ) )
-        {
-            messageBuffer.append( "." );
+            return pce.buildConfigurationDiagnosticMessage( cce );
         }
         else
         {
-            if ( param.isEditable() )
-            {
-                messageBuffer.append( "\n\n-OR-\n\n" );
-            }
-            
-            addParameterUsageInfo( expression, messageBuffer );
-        }
-    }
-
-    private void addParameterUsageInfo( String expression, StringBuffer messageBuffer )
-    {
-        StringBuffer expressionMessageBuffer = new StringBuffer();
-        
-        Matcher exprMatcher = Pattern.compile( "\\$\\{(.+)\\}" ).matcher( expression );
-
-        boolean unmodifiableElementsFound = false;
-        boolean activeElementsFound = false;
-
-        int elementCount = 0;
-
-        while ( exprMatcher.find() )
-        {
-            elementCount++;
-
-            activeElementsFound = true;
-
-            String subExpression = exprMatcher.group( 1 );
-
-            StringTokenizer expressionParts = new StringTokenizer( subExpression, "." );
-
-            String firstPart = expressionParts.nextToken();
-
-            try
-            {
-                Map expressions = ExpressionDocumenter.load();
-                Expression expr = (Expression) expressions.get( subExpression );
-
-                if ( expr != null )
-                {
-                    if ( !expr.isEditable() )
-                    {
-                        unmodifiableElementsFound = true;
-                    }
-                    else
-                    {
-                        addParameterConfigDocumentation( firstPart, exprMatcher.group( 0 ), subExpression,
-                                                         expressionMessageBuffer );
-                    }
-                }
-                else if ( UNMODIFIABLE_EXPRESSIONS.contains( subExpression ) )
-                {
-                    unmodifiableElementsFound = true;
-                }
-                else
-                {
-                    expressionMessageBuffer.append( "on the command line, specify: \'-D" ).append( subExpression )
-                        .append( "=VALUE\'" );
-                }
-            }
-            catch ( ExpressionDocumentationException e )
-            {
-                expressionMessageBuffer.append( "\n\nERROR!! Failed to load expression documentation!" );
-
-                StringWriter sWriter = new StringWriter();
-                PrintWriter pWriter = new PrintWriter( sWriter );
-
-                e.printStackTrace( pWriter );
-
-                expressionMessageBuffer.append( "\n\nException:\n\n" ).append( sWriter.toString() );
-            }
-        }
-
-        if ( activeElementsFound )
-        {
-            messageBuffer.append( expressionMessageBuffer );
-        }
-        else
-        {
-            messageBuffer.append( "    (found static expression: \'" + expression
-                + "\' which may act as a default value).\n" );
-        }
-
-        if ( unmodifiableElementsFound )
-        {
-            if ( elementCount > 1 )
-            {
-                messageBuffer.append( "    " );
-            }
-
-            messageBuffer
-                .append( "NOTE: One or more purely derived expression elements were detected in \'"
-                    + expression
-                    + "\'.\n    If you continue to get this error after any other expression elements are specified correctly,"
-                    + "\n    please report this issue to the Maven development team.\n" );
-        }
-    }
-
-    private void addParameterConfigDocumentation( String firstPart, String wholeExpression, String subExpression,
-                                                 StringBuffer expressionMessageBuffer )
-        throws ExpressionDocumentationException
-    {
-        Map expressionDoco = ExpressionDocumenter.load();
-
-        Expression expr = (Expression) expressionDoco.get( subExpression );
-
-        if ( expr != null )
-        {
-            expressionMessageBuffer.append( "check that the following section of " );
-            if ( "project".equals( firstPart ) )
-            {
-                expressionMessageBuffer.append( "the pom.xml " );
-            }
-            else if ( "settings".equals( firstPart ) )
-            {
-                expressionMessageBuffer.append( "your ~/.m2/settings.xml file " );
-            }
-
-            expressionMessageBuffer.append( "is present and correct:\n\n" );
-
-            String message = expr.getConfiguration();
-
-            if ( message == null )
-            {
-                message = expr.getDescription();
-            }
-
-            expressionMessageBuffer.append( message );
-
-            Properties cliConfig = expr.getCliOptions();
-
-            if ( cliConfig != null && !cliConfig.isEmpty() )
-            {
-                expressionMessageBuffer.append( "\n\n-OR-\n\nUse the following command-line switches:\n" );
-
-                prettyPrintCommandLineSwitches( cliConfig, '.', expressionMessageBuffer );
-            }
-        }
-        else
-        {
-            expressionMessageBuffer.append( "ensure that the expression: \'" + wholeExpression + "\' is satisfied" );
-        }
-    }
-
-    private void prettyPrintCommandLineSwitches( Properties switches, char filler, StringBuffer expressionMessageBuffer )
-    {
-        int maxKeyLen = 0;
-
-        for ( Iterator it = switches.entrySet().iterator(); it.hasNext(); )
-        {
-            Map.Entry entry = (Map.Entry) it.next();
-
-            String key = (String) entry.getKey();
-
-            int keyLen = key.length();
-            if ( keyLen > maxKeyLen )
-            {
-                maxKeyLen = keyLen;
-            }
-        }
-
-        final int minFillerCount = 4;
-
-        for ( Iterator it = switches.entrySet().iterator(); it.hasNext(); )
-        {
-            Map.Entry entry = (Map.Entry) it.next();
-
-            String key = (String) entry.getKey();
-
-            int keyLen = key.length();
-
-            int fillerCount = maxKeyLen - keyLen + minFillerCount;
-
-            expressionMessageBuffer.append( '\n' ).append( key ).append( ' ' );
-
-            for ( int i = 0; i < fillerCount; i++ )
-            {
-                expressionMessageBuffer.append( filler );
-            }
-
-            expressionMessageBuffer.append( ' ' ).append( entry.getValue() );
+            return pce.getMessage();
         }
-
-        expressionMessageBuffer.append( '\n' );
     }
-
 }

Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=320668&r1=320667&r2=320668&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Wed Oct 12 22:30:22 2005
@@ -131,16 +131,6 @@
       <implementation>org.apache.maven.usability.PluginConfigurationDiagnoser</implementation>
     </component>
     <!--
-     |
-     |PluginContainerDiagnoser
-     |
-     -->
-    <component>
-      <role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
-      <role-hint>PluginContainerDiagnoser</role-hint>
-      <implementation>org.apache.maven.usability.PluginContainerDiagnoser</implementation>
-    </component>
-    <!--
     |
     |ArtifactNotFoundDiagnoser
     |

Propchange: maven/components/trunk/maven-plugins/maven-antlr-plugin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Oct 12 22:30:22 2005
@@ -1,2 +1,3 @@
 release.properties
 target
+*.iml

Propchange: maven/components/trunk/maven-plugins/maven-antrun-plugin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Oct 12 22:30:22 2005
@@ -1,2 +1,3 @@
 release.properties
 target
+*.iml

Propchange: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Oct 12 22:30:22 2005
@@ -1,2 +1,3 @@
 release.properties
 target
+*.iml