svn commit: r997423 - in /ofbiz/trunk: common.xml macros.xml tools/src/org/ofbiz/tools/ant/IfTask.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r997423 - in /ofbiz/trunk: common.xml macros.xml tools/src/org/ofbiz/tools/ant/IfTask.java

doogie-3
Author: doogie
Date: Wed Sep 15 17:56:57 2010
New Revision: 997423

URL: http://svn.apache.org/viewvc?rev=997423&view=rev
Log:
<if> no longer accepts conditions directly; instead, all conditions have to be placed underneath a <condition> element.

Modified:
    ofbiz/trunk/common.xml
    ofbiz/trunk/macros.xml
    ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java

Modified: ofbiz/trunk/common.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/common.xml?rev=997423&r1=997422&r2=997423&view=diff
==============================================================================
--- ofbiz/trunk/common.xml (original)
+++ ofbiz/trunk/common.xml Wed Sep 15 17:56:57 2010
@@ -58,7 +58,9 @@ under the License.
     <target name="init"/>
 
     <if>
-        <available file="${src.dir}"/>
+        <condition>
+            <available file="${src.dir}"/>
+        </condition>
         <commands>
             <selector id="src-extra-set">
                 <or>

Modified: ofbiz/trunk/macros.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/macros.xml?rev=997423&r1=997422&r2=997423&view=diff
==============================================================================
--- ofbiz/trunk/macros.xml (original)
+++ ofbiz/trunk/macros.xml Wed Sep 15 17:56:57 2010
@@ -160,11 +160,13 @@ under the License.
   <attribute name="prefix" default=""/>
   <sequential>
    <if>
-    <not>
-     <uptodate
-      srcfile="@{prefix}src/@{dir}/@{file}.jj"
-      targetfile="@{prefix}build/gen-src/javacc/@{dir}/@{file}.java"/>
-    </not>
+    <condition>
+     <not>
+      <uptodate
+       srcfile="@{prefix}src/@{dir}/@{file}.jj"
+       targetfile="@{prefix}build/gen-src/javacc/@{dir}/@{file}.java"/>
+     </not>
+    </condition>
     <commands>
      <delete dir="@{prefix}build/gen-src/javacc/@{dir}"/>
      <mkdir dir="@{prefix}build/gen-src/javacc/@{dir}"/>
@@ -183,11 +185,13 @@ under the License.
   <attribute name="prefix" default=""/>
   <sequential>
    <if>
-    <not>
-     <uptodate
-      srcfile="@{prefix}src/@{dir}/@{file}.jjt"
-      targetfile="@{prefix}build/gen-src/jjtree/@{dir}/@{file}.jj"/>
-    </not>
+    <condition>
+     <not>
+      <uptodate
+       srcfile="@{prefix}src/@{dir}/@{file}.jjt"
+       targetfile="@{prefix}build/gen-src/jjtree/@{dir}/@{file}.jj"/>
+     </not>
+    </condition>
     <commands>
      <delete dir="@{prefix}build/gen-src/jjtree/@{dir}"/>
      <mkdir dir="@{prefix}build/gen-src/jjtree/@{dir}"/>
@@ -197,11 +201,13 @@ under the License.
     </commands>
    </if>
    <if>
-    <not>
-     <uptodate
-      srcfile="@{prefix}build/gen-src/jjtree/@{dir}/@{file}.jj"
-      targetfile="@{prefix}build/gen-src/javacc/@{dir}/@{file}.java"/>
-    </not>
+    <condition>
+     <not>
+      <uptodate
+       srcfile="@{prefix}build/gen-src/jjtree/@{dir}/@{file}.jj"
+       targetfile="@{prefix}build/gen-src/javacc/@{dir}/@{file}.java"/>
+     </not>
+    </condition>
     <commands>
      <delete dir="@{prefix}build/gen-src/javacc/@{dir}"/>
      <mkdir dir="@{prefix}build/gen-src/javacc/@{dir}"/>

Modified: ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java?rev=997423&r1=997422&r2=997423&view=diff
==============================================================================
--- ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java (original)
+++ ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java Wed Sep 15 17:56:57 2010
@@ -18,17 +18,21 @@
  */
 package org.ofbiz.tools.ant;
 
-import java.util.Enumeration;
-
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.ProjectComponent;
 import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.taskdefs.condition.And;
 import org.apache.tools.ant.taskdefs.condition.Condition;
-import org.apache.tools.ant.taskdefs.condition.ConditionBase;
 
-public class IfTask extends ConditionBase {
+public class IfTask extends ProjectComponent {
+    protected Condition condition;
     protected Sequential ifCommands;
     protected Sequential elseCommands;
 
+    public Condition createCondition() {
+        return condition = new And();
+    }
+
     public Object createCommands() {
         return ifCommands = new Sequential();
     }
@@ -38,13 +42,8 @@ public class IfTask extends ConditionBas
     }
 
     public void execute() throws BuildException {
-        Enumeration en = getConditions();
-        if (!en.hasMoreElements()) throw new BuildException("No conditions defined");
-        boolean result = true;
-        while (result && en.hasMoreElements()) {
-            result = ((Condition) en.nextElement()).eval();
-        }
-        if (result) {
+        if (condition == null) throw new BuildException("No condition defined");
+        if (condition.eval()) {
             if (ifCommands != null) ifCommands.execute();
         } else {
             if (elseCommands != null) elseCommands.execute();