geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r462759 - /geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
Date Wed, 11 Oct 2006 10:36:15 GMT
Author: jdillon
Date: Wed Oct 11 03:36:09 2006
New Revision: 462759

URL: http://svn.apache.org/viewvc?view=rev&rev=462759
Log:
Improve debugging and error handling of scriptpath

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=462759&r1=462758&r2=462759
==============================================================================
--- 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
Wed Oct 11 03:36:09 2006
@@ -122,12 +122,28 @@
     //
 
     protected void doExecute() throws Exception {
+        boolean debug = log.isDebugEnabled();
+
         source.validate();
 
         ClassLoader parent = getClass().getClassLoader();
         URL[] urls = getClasspath();
         URLClassLoader cl = new URLClassLoader(urls, parent);
 
+        // Validate and dump the scriptpath
+        if (scriptpath != null) {
+            log.debug("Scriptpath:");
+            for (int i=0; i < scriptpath.length; i++) {
+                if (scriptpath[i] == null) {
+                    throw new MojoExecutionException("Null element found in scriptpath at
index: " + i);
+                }
+
+                if (debug) {
+                    log.debug("    " + scriptpath[i]);
+                }
+            }
+        }
+
         //
         // TODO: Investigate using GroovyScript instead of this...
         //
@@ -145,15 +161,11 @@
 
                 if (scriptpath != null) {
                     for (int i=0; i<scriptpath.length; i++) {
-                        if (scriptpath[i] == null) {
-                            // Can not throw MojoExecutionException, so just spit out a warning
-                            log.warn("Ignoring null element in scriptpath");
-                        }
-                        else {
-                            File file = new File(scriptpath[i], resource);
-                            if (file.exists()) {
-                                return file.toURL();
-                            }
+                        assert scriptpath[i] != null;
+
+                        File file = new File(scriptpath[i], resource);
+                        if (file.exists()) {
+                            return file.toURL();
                         }
                     }
                 }
@@ -175,7 +187,9 @@
             else {
                 url = source.getUrl();
             }
-            log.debug("Loading source from: " + url);
+            if (debug) {
+                log.debug("Loading source from: " + url);
+            }
             
             InputStream input = url.openConnection().getInputStream();
             groovyClass = loader.parseClass(input);
@@ -213,6 +227,9 @@
         groovyObject.setProperty("pom", delegate);
 
         // Execute the script
+        if (debug) {
+            log.debug("Invoking object.run() on: " + groovyObject);
+        }
         groovyObject.invokeMethod("run", new Object[0]);
     }
 
@@ -234,9 +251,12 @@
         }
 
         URL[] urls = (URL[])list.toArray(new URL[list.size()]);
+
+        // Dump the classpath
         if (log.isDebugEnabled()) {
+            log.debug("Classpath:");
             for (int i=0; i < urls.length; i++) {
-                log.debug("URL[" + i + "]: " + urls[i]);
+                log.debug("    " + urls[i]);
             }
         }
 



Mime
View raw message