ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r917166 - in /ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront: GroovyFrontScriptMetaClass.java GroovyFrontTarget.java
Date Sun, 28 Feb 2010 10:55:14 GMT
Author: hibou
Date: Sun Feb 28 10:55:13 2010
New Revision: 917166

URL: http://svn.apache.org/viewvc?rev=917166&view=rev
Log:
handle empty targets

Modified:
    ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontScriptMetaClass.java
    ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontTarget.java

Modified: ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontScriptMetaClass.java
URL: http://svn.apache.org/viewvc/ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontScriptMetaClass.java?rev=917166&r1=917165&r2=917166&view=diff
==============================================================================
--- ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontScriptMetaClass.java
(original)
+++ ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontScriptMetaClass.java
Sun Feb 28 10:55:13 2010
@@ -142,13 +142,17 @@
     }
 
     private void defineTarget(Object[] args) {
-        if (args.length != 2 || !(args[0] instanceof Map) || !(args[1] instanceof Closure))
{
+        if (args.length < 1 || args.length > 2 || !(args[0] instanceof Map)
+                || (args.length == 2 && !(args[1] instanceof Closure))) {
             throw new BuildException("A target is ill formed. Expecting map, closure but
was: " + Arrays.toString(args));
         }
         Map/* <String, String> */map = (Map/* <String, String> */) args[0];
-        Closure closure = (Closure) args[1];
-        closure.setDelegate(groovyFrontBuilder);
-        closure.setResolveStrategy(Closure.DELEGATE_FIRST);
+        Closure closure = null;
+        if (args.length > 1) {
+            closure = (Closure) args[1];
+            closure.setDelegate(groovyFrontBuilder);
+            closure.setResolveStrategy(Closure.DELEGATE_FIRST);
+        }
         String name = (String) map.get("name");
         String description = (String) map.get("description");
         String depends = (String) map.get("depends");

Modified: ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontTarget.java
URL: http://svn.apache.org/viewvc/ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontTarget.java?rev=917166&r1=917165&r2=917166&view=diff
==============================================================================
--- ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontTarget.java
(original)
+++ ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontTarget.java
Sun Feb 28 10:55:13 2010
@@ -40,6 +40,9 @@
 
     public void execute() throws BuildException {
         groovyFrontBuilder.getAntXmlContext().setCurrentTarget(this);
+        if (closure == null) {
+            return;
+        }
         final Closure c = closure;
         // if (testIfCondition() && testUnlessCondition()) {
         new GroovyRunner() {



Mime
View raw message