You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/07/24 23:02:25 UTC

svn commit: r559209 - /maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java

Author: jdcasey
Date: Tue Jul 24 14:02:25 2007
New Revision: 559209

URL: http://svn.apache.org/viewvc?view=rev&rev=559209
Log:
Fixing error message coming from a plugin phase-binding that cannot be resolved, or is unspecified.

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java?view=diff&rev=559209&r1=559208&r2=559209
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java Tue Jul 24 14:02:25 2007
@@ -265,6 +265,8 @@
                                 mojoBinding.setOrigin( "POM" );
 
                                 String phase = execution.getPhase();
+                                boolean pluginResolved = false;
+
                                 if ( phase == null )
                                 {
                                     if ( pluginDescriptor == null )
@@ -272,6 +274,7 @@
                                         try
                                         {
                                             pluginDescriptor = pluginLoader.loadPlugin( plugin, project );
+                                            pluginResolved = true;
                                         }
                                         catch ( PluginLoaderException e )
                                         {
@@ -310,9 +313,42 @@
 
                                     if ( phase == null )
                                     {
-                                        throw new LifecycleSpecificationException( "No phase specified for goal: "
-                                                        + goal + " in plugin: " + plugin.getKey() + " from POM: "
-                                                        + projectId );
+                                        if ( pluginResolved )
+                                        {
+                                            StringBuffer message = new StringBuffer();
+
+                                            message.append( "\n\nNo lifecycle phase binding can be found for goal: " + goal );
+                                            message.append( ",\nspecified as a part of the execution: " + execution.getId() );
+                                            message.append( "in plugin: " );
+                                            message.append( pluginDescriptor.getPluginLookupKey() );
+                                            message.append( "\n\nThis plugin was resolved successfully." );
+                                            message.append( "\nHowever, the mojo metadata it contains does not specify a default lifecycle phase binding." );
+                                            message.append( "\n\nPlease provide a valid <phase/> specification for execution: " )
+                                                   .append( execution.getId() )
+                                                   .append( " in plugin: " )
+                                                   .append( plugin.getKey() );
+                                            message.append( "\n\n" );
+
+                                            throw new LifecycleSpecificationException( message.toString() );
+                                        }
+                                        else
+                                        {
+                                            StringBuffer message = new StringBuffer();
+
+                                            message.append( "\n\nNo lifecycle phase binding can be found for goal: " + goal );
+                                            message.append( ",\nspecified as a part of the execution: " + execution.getId() );
+                                            message.append( "in plugin: " );
+                                            message.append( pluginDescriptor.getPluginLookupKey() );
+                                            message.append( "\n\nThis plugin could not be resolved, so use of the default lifecycle phase binding " )
+                                                    .append( "\n(if there is one) is impossible." );
+                                            message.append( "\n\nPlease ensure that the plugin: " )
+                                                   .append( plugin.getKey() )
+                                                   .append( " can be resolved by Maven, then try re-running this " )
+                                                   .append( "\nbuild with the -U option, to ensure that all plugin metadata is refreshed." );
+                                            message.append( "\n\n" );
+
+                                            throw new LifecycleSpecificationException( message.toString() );
+                                        }
                                     }
                                 }