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 2009/02/25 17:43:11 UTC

svn commit: r747855 - in /maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin: DefaultPluginManager.java PluginManagerException.java

Author: jdcasey
Date: Wed Feb 25 16:43:11 2009
New Revision: 747855

URL: http://svn.apache.org/viewvc?rev=747855&view=rev
Log:
[MNG-2690] Improving error messages for NoClassDefFound and ComponentLookupException during Mojo lookup and configuration.

Modified:
    maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java

Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=747855&r1=747854&r2=747855&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Wed Feb 25 16:43:11 2009
@@ -625,8 +625,27 @@
         }
         catch ( ComponentLookupException e )
         {
-            throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getRoleHint() +
-                "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e );
+            Throwable cause = e.getCause();
+            while( cause != null && !(cause instanceof NoClassDefFoundError ) )
+            {
+                cause = cause.getCause();
+            }
+            
+            if ( cause != null && ( cause instanceof NoClassDefFoundError ) )
+            {
+                throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint()
+                                                  + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: "
+                                                  + cause.getMessage(), e );
+            }
+            
+            throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getGoal() +
+                "' (or one of its required components) in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e );
+        }
+        catch ( NoClassDefFoundError e )
+        {
+            throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint()
+                + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: "
+                + e.getMessage(), e );
         }
 
         if ( plugin instanceof ContextEnabled )
@@ -1317,6 +1336,11 @@
                                                     "Unable to retrieve component configurator for plugin configuration",
                                                     e );
         }
+        catch ( NoClassDefFoundError e )
+        {
+            throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
+                                                    "A required class was missing during mojo configuration: " + e.getMessage(), e );
+        }
         catch ( LinkageError e )
         {
             if ( getLogger().isFatalErrorEnabled() )

Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java?rev=747855&r1=747854&r2=747855&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java (original)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java Wed Feb 25 16:43:11 2009
@@ -33,7 +33,7 @@
         super( message );
     }
 
-    public PluginManagerException( String message, Exception e )
+    public PluginManagerException( String message, Throwable e )
     {
         super( message, e );
     }