You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2009/11/13 00:12:07 UTC

svn commit: r835630 - in /ofbiz/trunk: .gitignore build.xml common.xml tools/ tools/src/ tools/src/org/ tools/src/org/ofbiz/ tools/src/org/ofbiz/tools/ tools/src/org/ofbiz/tools/ant/ tools/src/org/ofbiz/tools/ant/IfTask.java

Author: doogie
Date: Thu Nov 12 23:12:07 2009
New Revision: 835630

URL: http://svn.apache.org/viewvc?rev=835630&view=rev
Log:
Add <if> support in build.xml.

Added:
    ofbiz/trunk/tools/
    ofbiz/trunk/tools/src/
    ofbiz/trunk/tools/src/org/
    ofbiz/trunk/tools/src/org/ofbiz/
    ofbiz/trunk/tools/src/org/ofbiz/tools/
    ofbiz/trunk/tools/src/org/ofbiz/tools/ant/
    ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java
Modified:
    ofbiz/trunk/.gitignore
    ofbiz/trunk/build.xml
    ofbiz/trunk/common.xml

Modified: ofbiz/trunk/.gitignore
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.gitignore?rev=835630&r1=835629&r2=835630&view=diff
==============================================================================
--- ofbiz/trunk/.gitignore (original)
+++ ofbiz/trunk/.gitignore Thu Nov 12 23:12:07 2009
@@ -1,3 +1,4 @@
+tools/build
 applications/accounting/build/
 applications/content/build/
 applications/humanres/build/

Modified: ofbiz/trunk/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/build.xml?rev=835630&r1=835629&r2=835630&view=diff
==============================================================================
--- ofbiz/trunk/build.xml (original)
+++ ofbiz/trunk/build.xml Thu Nov 12 23:12:07 2009
@@ -33,6 +33,10 @@
 
     <target name="ofbiz-init">
         <property environment="env"/>
+        <mkdir dir="tools/build/classes"/>
+        <javac srcdir="tools/src" debug="on" deprecation="off" destdir="tools/build/classes" compiler="javac1.5" target="1.5" source="1.5"/>
+        <mkdir dir="tools/build/lib"/>
+        <jar jarfile="tools/build/lib/ofbiz-tools.jar" basedir="tools/build/classes"/>
     </target>
 
     <!-- ================================================================== -->
@@ -55,6 +59,7 @@
         <antcall target="clean-cache"/>
         <antcall target="clean-tempfiles"/>
         <antcall target="clean"/>
+        <antcall target="clean-tools"/>
     </target>
 
     <target name="clean-data"
@@ -115,7 +120,7 @@
         </subant>
     </target>
   
-    <target name="tests">
+    <target name="tests" depends="ofbiz-init">
         <subant target="tests">
             <filelist dir="." files="framework/build.xml"/>
         </subant>
@@ -143,6 +148,10 @@
         <echo message="[clean] ========== Done Cleaning =========="/>
     </target>
 
+    <target name="clean-tools">
+        <delete dir="tools/build"/>
+    </target>
+
     <target name="svninfo">
         <echo message="Creating svninfo..."/>
         <exec executable="svn" dir="." output="runtime/svninfo_tmp.xml">
@@ -167,7 +176,7 @@
     <!-- Build Components                                                   -->
     <!-- ================================================================== -->
 
-    <target name="build">
+    <target name="build" depends="ofbiz-init">
         <echo message="[build] ========== Start Building (Compile) =========="/>
 
         <subant inheritall="false">
@@ -194,7 +203,7 @@
     <!-- Build JavaDocs                                                     -->
     <!-- ================================================================== -->
 
-    <target name="docs">
+    <target name="docs" depends="ofbiz-init">
         <echo message="[docs] ========== Start Building (JavaDoc) =========="/>
 
         <subant target="docs">
@@ -215,7 +224,7 @@
         <echo message="[docs] ========== Done Building (JavaDocs) =========="/>
     </target>
 
-  <target name="docs-all" depends="build"
+  <target name="docs-all" depends="build,ofbiz-init"
         description="Build all javadoc into one tree for easier viewing by the community">
 
         <echo message="[docs-all] ========== Start Building (JavaDoc) =========="/>

Modified: ofbiz/trunk/common.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/common.xml?rev=835630&r1=835629&r2=835630&view=diff
==============================================================================
--- ofbiz/trunk/common.xml (original)
+++ ofbiz/trunk/common.xml Thu Nov 12 23:12:07 2009
@@ -42,6 +42,7 @@
     <target name="prepare">
         <mkdir dir="${build.dir}/classes"/>
         <mkdir dir="${build.dir}/lib"/>
+        <taskdef name="if" classname="org.ofbiz.tools.ant.IfTask" classpath="${ofbiz.home.dir}/tools/build/classes"/>
     </target>
 
     <target name="prepare-docs">

Added: 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=835630&view=auto
==============================================================================
--- ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java (added)
+++ ofbiz/trunk/tools/src/org/ofbiz/tools/ant/IfTask.java Thu Nov 12 23:12:07 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ofbiz.tools.ant;
+
+import java.util.Enumeration;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.taskdefs.condition.ConditionBase;
+
+public class IfTask extends ConditionBase {
+    protected Sequential ifCommands;
+    protected Sequential elseCommands;
+
+    public Object createCommands() {
+        return ifCommands = new Sequential();
+    }
+
+    public Object createElse() {
+        return elseCommands = new Sequential();
+    }
+
+    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 (ifCommands != null) ifCommands.execute();
+        } else {
+            if (elseCommands != null) elseCommands.execute();
+        }
+    }
+}