geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r474100 - /geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
Date Mon, 13 Nov 2006 00:01:30 GMT
Author: jdillon
Date: Sun Nov 12 16:01:29 2006
New Revision: 474100

URL: http://svn.apache.org/viewvc?view=rev&rev=474100
Log:
Decode GroovyRuntimeExceptions for easier error groking
Add some more debug logs

Modified:
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java

Modified: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java?view=diff&rev=474100&r1=474099&r2=474100
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
(original)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
Sun Nov 12 16:01:29 2006
@@ -34,6 +34,7 @@
 import groovy.lang.GroovyClassLoader;
 import groovy.lang.GroovyObject;
 import groovy.lang.GroovyResourceLoader;
+import groovy.lang.GroovyRuntimeException;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
@@ -173,7 +174,21 @@
         if (debug) {
             log.debug("Invoking run() on: " + obj);
         }
-        obj.invokeMethod("run", new Object[0]);
+        
+        try {
+            obj.invokeMethod("run", new Object[0]);
+        }
+        catch (GroovyRuntimeException e) {
+            if (log.isDebugEnabled()) {
+                // Yes, log error if debug is enabled
+                log.error("Groovy script execution failure", e);
+            }
+            
+            Throwable cause = e.getCause();
+            assert cause != null;
+            
+            throw new MojoExecutionException(cause.getMessage(), cause);
+        }
     }
 
     private Class loadGroovyClass(final CodeSource source) throws Exception {
@@ -254,7 +269,11 @@
 
     private URL resolveGroovyScript(final String classname) throws MalformedURLException
{
         assert classname != null;
-
+        
+        if (log.isDebugEnabled()) {
+            log.debug("Resolving script for class: " + classname);
+        }
+        
         String resource = classname.replace('.', '/');
         if (!resource.startsWith("/")) {
             resource = "/" + resource;
@@ -289,7 +308,11 @@
         else {
             return url;
         }
-
+        
+        if (log.isDebugEnabled()) {
+            log.debug("Unable to resolve script for class: " + classname);
+        }
+        
         // Else not found
         return null;
     }



Mime
View raw message