src/build.xml
author Antonio Moreno <antonio.moreno@openbravo.com>
Thu, 10 Jun 2010 16:29:24 +0200
changeset 7592 85eb92e7e94b
parent 7547 064f42583bf3
child 7595 62566014690e
permissions -rw-r--r--
Fixed issue 12683. Committed previous fix but with two improvements:
now the property is set if it needs to be, and not touched if it doesn't
hopefully all relevant tasks should have the property now
<?xml version="1.0" encoding="UTF-8" ?>
<!--
 *************************************************************************
 * The contents of this file are subject to the Openbravo Public License 
 * Version 1.1 (the "License"), being the Mozilla Public License 
 * version 1.1  with a permitted attribution clause ; you may not use 
 * this file except in compliance with the License. 
 * You may obtain a copy of the License at  
 * http://www.openbravo.com/legal/license.txt 
 * Software distributed under the License is distributed on an 
 * "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or 
 * implied. See the License for the specific language governing rights 
 * and  limitations under the License. 
 * The Original Code is Openbravo ERP. 
 * The Initial Developer of the Original Code is Openbravo SLU 
 * All portions are Copyright (C) 2005-2010 Openbravo SLU 
 * All Rights Reserved. 
 * Contributor(s): Openbravo S.L.U.
 ************************************************************************
-->

<!--
List of methods infside:

init: creates all the folders.
trl.clean: clean the AD_TEXTINTERFACES table
clean: delete all folders.
copy.srcClient: copy the content of the srcClient to the src folder.
sqlc: generates the java from the xsql files.
compileSqlc: compiles all the java generated from the xsqls.
wad: generates all the files from the mda.
postwad: copies the generated files to the base design folder.
postsrc: copies the src files to the base design folder and the 
         xml and jasper files to the translated designs folders
postsrc.modules: it does the same as postsrc but for module files
build.local.context: copies all files to the eclipse base context 
                     (WebContent...).
compile.src: comiles only the src files.
eclipse.compile: generates specified wad files and compiles modified xsql files.
eclipse.compile.complete: generates all wad files and compiles all xsql files
compile: compiles specified WAD window and src and also translates.
compile.complete: compiles all WAD windows and src and also translates.
translate: Translate the modified files.
compile.translate: Translate the specified extensions files.
installWebService: install the web services configuration file.
uninstallWebService: uninstall the web services configuration file.
copy.files: copy the local files to the context.
compile.development: like compile, but also copies the files to the context.
compile.complete.development: like compile.complete, but also copies the files 
                              to the context.
compile.web: re-builds the web folder.
compile.web.development: like compile.web, but also copies the files to the context.
build.war: build a war file in the lib directory.
-->

<project name="openbravo sources" default="compile" basedir=".">

  <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask">
    <classpath>
      <pathelement location="${base.lib}/build/yuicompressor-2.4.2.jar" />
      <pathelement location="${base.lib}/build/ob-rhino-1.6R7.jar" />
      <pathelement location="${base.lib}/build/YUIAnt.jar" />
    </classpath>
  </taskdef>

  <condition property="minimizeJSandCSSbool">
    <istrue value="${minimizeJSandCSS}" />
  </condition>

  <property name="webTab" value="all" />
  <property name="tab" value="%" />

  <property name="base.translate.structure" value="org/openbravo/erpWindows" />
  <property name="client.web.xml" value="${base.client.src}/web.xml" />
  <property name="extension" value="html" />
  <property name="src" value="." />
  <property name="tr" value="yes" />
  <condition property="translation">
    <not>
      <equals arg1="no" arg2="${tr}" />
    </not>
  </condition>
  <target name="init">
    <mkdir dir="${build}" />
    <mkdir dir="${base.design}/design" />
    <mkdir dir="${build.sqlc}" />
    <mkdir dir="${build.sqlc}/src" />
    <mkdir dir="${build.sqlc}/srcAD" />
    <mkdir dir="${build.AD}" />
    <mkdir dir="${build.AD}/org/openbravo/erpWindows" />
    <mkdir dir="${build.AD}/org/openbravo/erpCommon/ad_actionButton" />
    <mkdir dir="${build.AD}/org/openbravo/erpCommon/ad_callouts" />
    <mkdir dir="${build.AD}/org/openbravo/erpCommon/reference" />
    <mkdir dir="${build.docs}" />
  </target>
  <macrodef name="updatesystemstatus">
     <attribute name="v" default="NOT SET"/>
     <sequential>
       <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="continue" autocommit="true">
         <classpath> <fileset dir="${base.lib}"> <include name="**/*.jar"> </include> </fileset> </classpath>
         <transaction> UPDATE ad_system_info SET system_status='@{v}' ;
                       DELETE FROM ad_error_log where system_status=(select system_status from ad_system_info)
         </transaction>
       </sql>
     </sequential>
  </macrodef>

  <target name="validate.database">
    <taskdef name="validateDatabase" classname="org.openbravo.service.system.SystemValidationTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <validateDatabase userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" type="database" />
  </target>

  <target name="validate.modules">
    <taskdef name="validateModules" classname="org.openbravo.service.system.SystemValidationTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <validateModules userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" type="module" moduleJavaPackage="${module}"/>
  </target>
  
  <target name="load.logoimages">
    <taskdef name="imageloading" classname="org.openbravo.erpCommon.utility.ImageToDatabaseLoader">
      <classpath refid="project.class.path" />
    </taskdef>
    <imageloading userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" basePath="${basedir}/../"
      imagePaths="web/images/CompanyLogo_big.png,web/images/SupportLogo_big.png,web/images/CompanyLogo_small.png,web/skins/Default/Login/initialOpenbravoLogo.png,web/images/CompanyLogo_big.png"
      propertyNames="yourCompanyLoginImage,yourItServiceLoginImage,yourCompanyMenuImage,yourCompanyBigImage,yourCompanyDocumentImage"/>
  </target>

  <target name="trl.clean" if="translation">
    <java classname="org.openbravo.translate.Translate" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="clean '${base.config}/Openbravo.properties'" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
  </target>
  
  <target name="trl.remove.unused" if="translation">
    <java classname="org.openbravo.translate.Translate" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="remove '${base.config}/Openbravo.properties'" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
  </target>

  <target name="clean" depends="trl.clean">
    <property name="complete" value="true" />
    <delete includeEmptyDirs="true" failonerror="false">
      <fileset dir="${base.design}" />
      <fileset dir="${build}" />
      <fileset dir="${build.docs}" />
      <fileset dir="${build.AD}" />
      <fileset dir="${build.sqlc}" />
      <fileset dir="${base.context}">
        <exclude name=".svn" />
        <exclude name="META-INF/MANIFEST.MF" />
        <exclude name="**/.keep" />
      </fileset>
    </delete>
  </target>

  <target name="compile.apply.module" depends="init">
    <mkdir dir="${build.apply.module}" />
    <java classname="org.openbravo.data.Sqlc" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}" failonerror="true">
      <arg line="'${base.config}'/Openbravo.properties .xsql . '${build.sqlc}'/src" />
      <jvmarg value="-Dsqlc.listOfFiles=ComboTableQuery_data.xsql,ActionButton_data.xsql,PInstanceProcess_data.xsql,SessionLogin_data.xsql,ApplyModule_data.xsql,TableSQLQuery_data.xsql,DateTime_data.xsql,ComboTableQuery_data.xsql,PrintJR_data.xsql,DocumentNo_data.xsql,WindowAccess_data.xsql,ComboTable_data.xsql,Tab_data.xsql,WindowTree_data.xsql,ErrorTextParser_data.xsql,Utility_data.xsql,MessageBD_data.xsql,LanguageCombo_data.xsql,Translation_data.xsql,Buscador_data.xsql,WindowTabs_data.xsql,Pinstance_data.xsql,ProcessRequest_data.xsql,Trigger_data.xsql,ProcessRun_data.xsql,Process_data.xsql,OrgTree_data.xsql,Seguridad_data.xsql,DefaultOptions_data.xsql,SystemPreferences_data.xsql,DefaultSessionValues_data.xsql,DefaultValues_data.xsql,Attribute_data.xsql,ClassInfo_data.xsql,"/>
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
    <javac includes="org/openbravo/erpCommon/modules/ApplyModuleTask.java" destdir="${build.apply.module}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on" verbose="false" nowarn="${friendlyWarnings}">
      <src path="${base.src}"/>
      <src path="../build/javasqlc/src"/>
      <src path="../src-gen"/>
      <classpath refid="apply.module.compile.classpath" />
    </javac>
  </target>
  
  <target name="sqlc" depends="copy.srcClient">
    <java classname="org.openbravo.data.Sqlc" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}" failonerror="true">
      <arg line="'${base.config}'/Openbravo.properties .xsql . '${build.sqlc}'/src" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
    <java classname="org.openbravo.data.Sqlc" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}" failonerror="true">
      <arg line="'${base.config}'/Openbravo.properties .xsql '${base.modules}' '${build.sqlc}'/src */src" />
      <jvmarg value="-Dsqlc.queryExecutionStrategy=traditional"/>
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
    <copy file="${base.src}/buildAD.xml" tofile="${build.AD}/build.xml" />
    <copy file="${base.src}/log4j.lcf" tofile="${build.AD}/log4j.lcf" />
    <ant dir="${build.AD}" target="buildAD" inheritAll="true" inheritRefs="true" />
  </target>

  <target name="copy.srcClient">
    <mkdir dir="${base.client.src}" />
    <copy todir="${basedir}" overwrite="true" failonerror="false">
      <fileset dir="${base.client.src}">
        <exclude name="**/web.xml" />
      </fileset>
    </copy>
  </target>

  <target name="clean.src.gen">
    <delete includeEmptyDirs="true" failonerror="false">
      <fileset dir="${base.src.gen}" >
        <exclude name="**/.keep" />
      </fileset>
    </delete>
  </target>

  <target name="export.sample.data" description="Exports Sample Data">
    <taskdef name="exportsampledata" classname="org.openbravo.service.db.ExportReferenceDataTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <echo message="Exporting sample reference data" />
    <exportsampledata userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" clients="SmallBazaar" />
    <exportsampledata userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" clients="Accounting Test" />
  </target>

  <target name="import.sample.data" description="Import Sample Data" depends="generate.entities">
    <taskdef name="importsampledata" classname="org.openbravo.service.db.ImportReferenceDataTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <echo message="Importing sample reference data" />
    <importsampledata userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" />
    <ant dir="${base.db}" target="database.postupdate.${bbdd.rdbms}" inheritAll="true" inheritRefs="true" />
  </target>

  <target name="generate.entities" depends="compile.src.gen,clean.src.gen">
    <taskdef name="workflow" classpathref="project.class.path" classname="org.openbravo.base.gen.GenerateEntitiesTask" />
    <!-- debug="true" will perform the in-memory model initialization before generating entities
	if an error occurs then, then a stacktrace is printed. -->
    <workflow debug="false" srcGenPath="${base.src.gen}" propertiesFile="${base.config}/Openbravo.properties" file="${base.src}/org/openbravo/base/gen/gen_entity.oaw" fork="true" maxmemory="${build.maxmemory}">
      <param name="ob.properties.location" value="${base.config}/Openbravo.properties" />
      <param name="base.src.gen" value="${base.src.gen}" />
      <classpath>
        <path refid="project.class.path" />
      </classpath>
    </workflow>

    <!--
    see issue: https://issues.openbravo.com/view.php?id=9331
    Custom columns in standard tables should support a reference to a table in the module
    if this occurs then possible the following javac has to be enabled instead of the two javacs below
    <javac srcdir="${base.src}:${base.src.gen}" excludes="org/openbravo/base/*,org/openbravo/base/secureApp/**,org/openbravo/erpCommon/**,org/openbravo/erpReports/**,org/openbravo/scheduling/**,org/openbravo/service/web/**,org/openbravo/service/system/**,org/openbravo/service/rest/**,org/openbravo/service/db/**,org/openbravo/authentication/**,org/openbravo/services/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />
    </javac>
    -->
    <javac srcdir="${base.src}:${base.src.gen}" includes="org/openbravo/model/**,org/openbravo/base/structure/**,org/openbravo/dal/**,org/openbravo/service/dataset/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />
    </javac>
    <javac srcdir="${base.src.gen}" excludes="org/openbravo/model/**,org/openbravo/base/structure/**,org/openbravo/dal/**,org/openbravo/service/dataset/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />
    </javac>
  </target>

  <!-- 
		Generates entities only when the application dictionary has changed.
		Difference with the generate.entities is that it does not clean the src-gen directory. The standard
		GenerateEntitiesTask always checks if the AD was changed before regenerating. The check is to compare
		the modified time of the generated sources with the updated time of the Application Dictionary. If there
		is a source older than the last updated time of the Application Dictionary then the sources need to be regenerated.		
	-->
  <target name="generate.entities.quick" depends="compile.src.gen">

    <taskdef name="workflow" classpathref="project.class.path" classname="org.openbravo.base.gen.GenerateEntitiesTask" />
    <!-- debug="true" will perform the in-memory model initialization before generating entities
	if an error occurs then, then a stacktrace is printed. -->
    <workflow debug="false" srcGenPath="${base.src.gen}" propertiesFile="${base.config}/Openbravo.properties" file="${base.src}/org/openbravo/base/gen/gen_entity.oaw" fork="true" maxmemory="${build.maxmemory}">
      <param name="ob.properties.location" value="${base.config}/Openbravo.properties" />
      <param name="base.src.gen" value="${base.src.gen}" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
      <classpath>
        <path refid="project.class.path" />
      </classpath>
    </workflow>

    <!--
      see issue: https://issues.openbravo.com/view.php?id=9331
      Custom columns in standard tables should support a reference to a table in the module
      if this occurs then possible the following javac has to be enabled instead of the two javacs below
    <javac srcdir="${base.src}:${base.src.gen}" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />      
    </javac>
    -->
    <javac srcdir="${base.src}:${base.src.gen}" includes="org/openbravo/model/**,org/openbravo/base/structure/**,org/openbravo/dal/**,org/openbravo/service/dataset/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />      
    </javac>
    <javac srcdir="${base.src.gen}" excludes="org/openbravo/model/**,org/openbravo/base/structure/**,org/openbravo/dal/**,org/openbravo/service/dataset/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />
    </javac>
  </target>

  <target name="run.tests" depends="compileSqlc,generate.entities.quick">
    
    <copy todir="${build}">
      <fileset dir="${base.src.test}" includes="**/*.xml" />
    </copy>
    
    <junit printsummary="yes" haltonfailure="yes">
      <classpath refid="project.class.path" />
      <formatter type="plain" usefile="no"/>
      <test name="org.openbravo.test.AntTaskTests" haltonfailure="no"/>
    </junit>
  </target>

  <target name="run.all.tests" depends="compileSqlc,generate.entities.quick">
    
    <copy todir="${build}">
      <fileset dir="${base.src.test}" includes="**/*.xml" />
    </copy>

    <junit printsummary="yes" haltonfailure="yes">
      <classpath refid="project.class.path" />
      <formatter type="plain" usefile="no"/>
      <test name="org.openbravo.test.AllAntTaskTests" haltonfailure="no" outfile="result">
	    <formatter type="xml" />
	  </test>
    </junit>
  </target>

  <target name="run.quick.tests" depends="compileSqlc,generate.entities.quick">
    
    <copy todir="${build}">
      <fileset dir="${base.src.test}" includes="**/*.xml" />
    </copy>
    
    <junit printsummary="yes" haltonfailure="yes">
      <classpath refid="project.class.path" />
      <formatter type="plain" usefile="no"/>
      <test name="org.openbravo.test.AllQuickAntTaskTests" haltonfailure="no"/>
    </junit>
  </target>

  <target name="run.webservice.tests" depends="compileSqlc,generate.entities.quick">
    
    <copy todir="${build}">
      <fileset dir="${base.src.test}" includes="**/*.xml" />
    </copy>

    <junit printsummary="yes" haltonfailure="yes">
      <classpath refid="project.class.path" />
      <formatter type="plain" usefile="no"/>
      <test name="org.openbravo.test.AllWebserviceTests" haltonfailure="yes"/>
    </junit>
  </target>

  <target name="run.api.test.javascript">
  	<taskdef name="jstest" classname="org.openbravo.test.javascript.JavaScriptAntTest" classpathref="project.class.path" />
	<property name="export" value="no" />
	<jstest apiDetailsPath="${api.test.javascript.details}" jsPath="${base.web}/js" export="${export}" />
  </target>
  
  <target name="compileSqlc" depends="sqlc">
    <javac  srcdir="${basedir}:${build.sqlc}/src:${build.sqlc}/srcAD:${base.src.test}:${base.modules}" excludes="${base.modules}/*/src-wad/**,${base.modules}/*/src-util/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" nowarn="${friendlyWarnings}">
      <classpath refid="project.class.path" />
    </javac>

    <javac srcdir="${build.AD}" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" nowarn="${friendlyWarnings}">
      <classpath refid="project.class.path" />
    </javac>
  	<antcall target="calculate.version"/>
  </target>

	<target name="calculate.version" depends="init">
	  <condition property="revision.from.file">
		<and>
		  <not>
		 	<isset property="hg.id"/>
		  </not>
		  <available file="${basedir}/config/instance.revision"/>
	    </and>
	  </condition>
	  <antcall inheritall="true" target="calculate.instance.version"/>
	</target>
	<target name="calculate.instance.version" depends="calculate.version.from.hg, calculate.version.from.file">
	    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" delimiter="/">
	      <classpath>
	        <fileset dir="${base.lib}">
	          <include name="**/*.jar">
	          </include>
	        </fileset>
	      </classpath>
	      <transaction>
		        UPDATE AD_MODULE 
	      	       SET VERSION_ID='${instance.version}'
                 WHERE AD_MODULE_ID='0'
		      </transaction>
	    </sql>
	</target>
	<target name="calculate.version.from.hg" if="is.hg">
	  <property name="instance.version" value="${hg.id}"/>
	</target>
	<target name="calculate.version.from.file" if="revision.from.file">
		<loadfile property="instance.version" srcfile="${basedir}/config/instance.revision"/>
	</target>

  <target name="compile.src.gen" depends="init">
    <javac srcdir="${basedir}" includes="org/openbravo/base/exception/**,org/openbravo/base/gen/**,org/openbravo/base/expression/**,org/openbravo/base/provider/**,org/openbravo/base/model/**,org/openbravo/base/session/**,org/openbravo/base/validation/**,org/openbravo/base/util/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />
    </javac>
    <copy todir="${build}">
      <fileset dir="${basedir}" includes="**/*.hbm.xml" />
    </copy>
    <copy todir="${build}">
      <fileset dir="${basedir}" includes="**/*.properties" />
    </copy>
    
    <!-- also compile the domaintypes in modules -->
    <javac srcdir="${basedir}/../" includes="modules/*/src/**/model/domaintype/**/*.java" destdir="${build}"  fork="true" deprecation="on" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
      <classpath refid="project.class.path" />
    </javac>
    
    <!-- copy all configuration files in modules to the output path also -->
    <copy todir="${build}" encoding="UTF-8">
      <fileset dir="${base.modules}">
          <include name="*/src/**/*" />
          <exclude name="*/src/**/*.java" />
          <exclude name="*/src/**/*.xsql" />
      </fileset>
      <mapper type="regexp" from="(.*\${file.separator}src)(.*)" to="\2" />
    </copy>
  </target>

  <target name="wadvalidation">
    <taskdef name="WADValidation" classname="org.openbravo.wad.validation.WADValidatorTask">
            <classpath refid="project.class.path" />
          </taskdef>
        
        <WADValidation propertiesFile="${base.config}/Openbravo.properties"
                       modules="${module}"
                       stoponerror="${stopOnWadError}"
                       friendlyWarnings="${friendlyWarnings}"/>
  </target>
  
  <target name="wad" depends="init, wadvalidation">
    <java classname="org.openbravo.wad.Wad" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}" failonerror="true">
      <arg line="'${base.config}' '${tab}' '${build.AD}/org/openbravo/erpWindows' '${build.AD}/org/openbravo/erpCommon' '${build.sqlc}/src' '${webTab}' '${build.AD}/org/openbravo/erpCommon/ad_actionButton' '${base.design}' '${base.translate.structure}' '${client.web.xml}' '..' '${attach.path}' '${web.url}' '${base.src}' '${complete}' '${module}' 'noquick'" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
    <antcall target="postwad" inheritall="true" inheritrefs="true" />
  </target>

  <target name="wad.quick" depends="init, wadvalidation">
    <java classname="org.openbravo.wad.Wad" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}' '${tab}' '${build.AD}/org/openbravo/erpWindows' '${build.AD}/org/openbravo/erpCommon' '${build.sqlc}/src' '${webTab}' '${build.AD}/org/openbravo/erpCommon/ad_actionButton' '${base.design}' '${base.translate.structure}' '${client.web.xml}' '..' '${attach.path}' '${web.url}' '${base.src}' '${complete}' '${module}' 'quick'" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
    <antcall target="postwad" inheritall="true" inheritrefs="true" />
  </target>

  <target name="postsrc" depends="postsrc.modules">

    <copy todir="${build}">
      <fileset dir="${basedir}" includes="**/*.properties" />
    </copy>
    <copy todir="${build}">
      <fileset dir="${basedir}" includes="**/*.xslt" />
    </copy>
    <copy todir="${build}">
      <fileset dir="${basedir}" includes="**/*.hbm.xml" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${basedir}" includes="**/*.xml" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${basedir}" includes="**/*.fo" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${basedir}" includes="**/*.html" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${basedir}" includes="**/*.srpt" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${basedir}" includes="**/*.jrxml" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${basedir}" includes="**/*.jasper" />
    </copy>
    <copy todir="${build}">
      <fileset file="${base.config}/quartz.properties" />
    </copy>
    <antcall target="build.local.context" inheritAll="true" inheritrefs="true" />
  </target>

  <target name="postsrc.modules">
    <copy todir="${base.design}/design">
      <fileset dir="${base.modules}">
        <include name="*/src/**/*.xml" />
        <include name="*/src/**/*.fo" />
        <include name="*/src/**/*.html" />
        <include name="*/src/**/*.srpt" />
        <include name="*/src/**/*.jrxml" />
        <include name="*/src/**/*.jasper" />
      </fileset>
      <mapper type="regexp" from="(.*\${file.separator}src)(.*)" to="\2" />
    </copy>
    <copy todir="${build}">
      <fileset dir="${base.modules}">
        <include name="*/src/**" />
        <exclude name="*/src/**/*.java" />
      </fileset>
      <mapper type="regexp" from="(.*\${file.separator}src)(.*)" to="\2" />
    </copy>
  </target>

  <!-- FIXME: These tasks is only for development and testing purposes, remove it afterwards-->
  <target name="sqlcmod" depends="copy.srcClient">
    <java classname="org.openbravo.data.Sqlc" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}" failonerror="true">
      <arg line="'${base.config}'/Openbravo.properties .xsql '${base.modules}' '${build.sqlc}'/src */src" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
  </target>

  <target name="compileSqlcmod" depends="sqlcmod">
    <javac srcdir="${build.sqlc}/src:${base.modules}" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </javac>
  </target>
  <target name="postsrcmod">
    <copy todir="${base.design}/design">
      <fileset dir="${base.modules}" includes="*/src/**/*.html" />
      <mapper type="regexp" from="(.*\${file.separator}src)(.*)" to="\2" />
    </copy>
  </target>

  <!-- end of auxiliar tasks-->

  <target name="build.local.context">
    <copy todir="${base.context}" encoding="UTF-8">
      <fileset file="${basedir}/index.html" />
    </copy>
    <copy todir="${base.context}/WEB-INF" encoding="UTF-8">
      <fileset file="${build.sqlc}/src/web.xml" />
      <fileset dir="${base.config}">
        <exclude name="**/eclipse/**" />
        <exclude name="**/setup-properties**" />
        <exclude name="*.template" />
        <exclude name="checksums"/>
      </fileset>
    </copy>
    <copy todir="${base.context}/WEB-INF" encoding="UTF-8">
      <fileset dir="${base.modules}">
        <include name="*/config/**" />
        <exclude name="*.template" />
      </fileset>
      <mapper type="regexp" from="(.*\${file.separator}config)(.*)" to="\2" />
    </copy>
    <copy todir="${base.context}/WEB-INF/lib" encoding="UTF-8">
      <fileset dir="${base.lib}/runtime">
        <exclude name="openbravo-wad.jar" />
        <exclude name="openbravo-trl.jar" />
        <exclude name="servlet-api.jar" />
        <exclude name="*.war" />
      </fileset>
      <fileset dir="${base.db}/lib">
        <include name="*" />
      </fileset>
    </copy>

    <copy todir="${base.context}/WEB-INF/lib" encoding="UTF-8">
      <fileset dir="${base.modules}">
        <include name="*/lib/runtime/**" />
      </fileset>
      <mapper type="regexp" from="(.*\${file.separator}lib\${file.separator}runtime)(.*)" to="\2" />
    </copy>
    <antcall target="build.web.folder" inheritAll="true" inheritrefs="true" />
  </target>

  <target name="build.web.folder">
    <copy todir="${base.context}/web" encoding="UTF-8">
      <fileset dir="${base.web}">
        <include name="*/**" />
        <exclude name="skins/**" />
      </fileset>
    </copy>
    
    <taskdef name="CheckSumCondition" classname="org.openbravo.utils.CheckSumCondition">
        <classpath refid="project.class.path" />
      </taskdef>
    
    <CheckSumCondition obDir="${basedir}/.."
                       type="md5.skins"
                       property="changes.in.md5.skins"/>
    <condition property="do.skins">
      <or>
        <istrue value="${changes.in.md5.skins}" />
        <not>
          <istrue value="${smart.mode}"/>
        </not>
      </or>
    </condition>
    
    <antcall target="build.web.folder.skins"  inheritAll="true" inheritrefs="true" />
    
    <condition property="generateSpritesBool">
        <istrue value="${generateSprites}" />
    </condition>
    <antcall target="generate.sprites" inheritAll="true" inheritrefs="true" />
    <antcall target="minimizeJSandCSS" inheritAll="true" inheritrefs="true" />
  </target>
    

  <target name="build.web.folder.skins" if="do.skins">

    <delete includeEmptyDirs="true" dir="${base.context}/web/skins" quiet="yes" />
    <mkdir dir="${base.context}/web" />
    <mkdir dir="${base.context}/web/skins" />
    <mkdir dir="${base.context}/web/skins/ltr" />
    <copy todir="${base.context}/web/skins/ltr" encoding="UTF-8">
      <fileset dir="${base.web}/skins" />
    </copy>
    <mkdir dir="${base.context}/web/skins/rtl" />
    <copy todir="${base.context}/web/skins/rtl" encoding="UTF-8">
      <fileset dir="${base.web}/skins" />
    </copy>

    <copy todir="${base.context}/web" encoding="UTF-8">
      <fileset dir="${base.modules}">
        <include name="*/web/*/**" />
        <exclude name="*/web/*/skins/**" />
      </fileset>
      <mapper type="regexp" from="(.*)(\${file.separator}web)(.*)" to="\3" />
    </copy>

    <copy todir="${base.context}/web/skins/ltr" encoding="UTF-8">
      <fileset dir="${base.modules}">
        <include name="*/web/*/skins/**" />
      </fileset>
      <mapper type="regexp" from="(.*)(\${file.separator}web)(.*\${file.separator})(skins\${file.separator})(.*)" to="\3\5" />
    </copy>

    <copy todir="${base.context}/web/skins/rtl" encoding="UTF-8">
      <fileset dir="${base.modules}">
        <include name="*/web/*/skins/**" />
      </fileset>
      <mapper type="regexp" from="(.*)(\${file.separator}web)(.*\${file.separator})(skins\${file.separator})(.*)" to="\3\5" />
    </copy>

    <java classname="org.openbravo.translate.RTLSkin" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="${base.context}/web/skins/rtl ${base.context}/web/skins/ltr" />
      <classpath refid="project.class.path" />
    </java>
    
  </target>

  <target name="generate.sprites" description="Performs CSS sprite processing" if="generateSpritesBool">
    <property name="skins.location" location="${base.context}/web/skins/" />
    <taskdef name="smartsprites" classname="org.carrot2.labs.smartsprites.ant.SmartSpritesTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <smartsprites rootdir="${skins.location}" documentrootdir="${skins.location}" outputdir="${skins.location}" cssfilesuffix="-sprite" csspropertyindent="  " loglevel="WARN" spritepngdepth="DIRECT" spritepngie6="false" />
    <move todir="${skins.location}">
      <fileset dir="${skins.location}">
        <include name="*/*-sprite.css" />
        <include name="*/*/*-sprite.css" />
      </fileset>
      <mapper type="glob" from="*-sprite.css" to="*.css" />
    </move>
  </target>

  <target name="minimizeJSandCSS" description="minimize JS and CSS files" if="minimizeJSandCSSbool">
    <yuicompress linebreak="300" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${base.context}/web" charset="UTF-8">
      <fileset dir="${base.web}">
        <include name="**/*.js" />
        <include name="**/*.css" />
        <!-- The following scripts break in minification process -->
        <exclude name="**/js/dojo/src/docs.js" />
        <exclude name="**/js/dojo/src/hostenv_jsc.js" />
        <exclude name="**/js/jscalendar/lang/calendar-al.js" />
        <exclude name="**/js/jscalendar/lang/calendar-he-utf8.js" />
        <exclude name="**/js/jscalendar/lang/calendar-hr.js" />
        <exclude name="**/js/xinha/lang/**" />
        <exclude name="**/js/xinha/plugins/**" />
        <!-- dojotoolkit files are already compressd -->
        <exclude name="**/dojotoolkit/**" />
        <!-- from old dojo, only compress main file -->
        <exclude name="**/dojo/**" />
        <include name="js/dojo/dojo.js" />
      </fileset>
    </yuicompress>
  </target>

  <target name="postwad">
    <copy todir="${base.design}/design">
      <fileset dir="${build.AD}" includes="**/*.xml" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${build.AD}" includes="**/*.fo" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${build.AD}" includes="**/*.html" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${build.AD}" includes="**/*.srpt" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${build.AD}" includes="**/*.jrxml" />
    </copy>
    <copy todir="${base.design}/design">
      <fileset dir="${build.AD}" includes="**/*.jasper" />
    </copy>
  </target>


  <target name="eclipse.compile.complete" depends="clean,generate.entities,wad,sqlc,postsrc,translate, trl.remove.unused">
    <antcall target="update.build.timestamp" />
  </target>

  <target name="eclipse.compile" depends="wad,sqlc, postsrc, translate">
  </target>

  <target name="compile.src" depends="compileSqlc, postsrc, copy.files">
  </target>

  <target name="compile.complete" depends="clean,generate.entities,wad,compileSqlc,postsrc,translate, trl.remove.unused">
    <antcall target="update.build.timestamp" />
  </target>


  <target name="smartbuild.new.wad" if="new.wad">
    <antcall inheritall="true" inheritrefs="true" target="wad" />
    <taskdef name="updateWADmd5" classname="org.openbravo.utils.WADCheckSumTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <updateWADmd5 obDir="${basedir}/.." />
  </target>

  <target name="smartbuild.no.new.wad" unless="new.wad">
    <antcall inheritall="true" inheritrefs="true" target="wad.quick" />
  </target>

  <target name="smartbuild">
    <antcall inheritall="true" inheritrefs="true" target="smartbuild.new.wad" />
    <antcall inheritall="true" inheritrefs="true" target="smartbuild.no.new.wad" />
    <antcall inheritall="true" inheritrefs="true" target="compileSqlc" />
    <antcall inheritall="true" inheritrefs="true" target="postsrc" />
    <antcall inheritall="true" inheritrefs="true" target="translate" />
    <antcall inheritall="true" inheritrefs="true" target="update.build.timestamp" />
  </target>

  <target name="translate" if="translation">
    <antcall inheritall="true" inheritrefs="true" target="compile.translate">
      <param name="extension" value="html" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="compile.translate">
      <param name="extension" value="fo" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="compile.translate">
      <param name="extension" value="srpt" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="compile.translate">
      <param name="extension" value="jrxml" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="translate.modules" />
  </target>

  <target name="compile" depends="wad,compileSqlc, postsrc, translate">
  </target>

  <target name="translate.modules" if="translation">
    <antcall inheritall="true" inheritrefs="true" target="compile.translate.modules">
      <param name="extension" value="html" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="compile.translate.modules">
      <param name="extension" value="fo" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="compile.translate.modules">
      <param name="extension" value="srpt" />
    </antcall>
    <antcall inheritall="true" inheritrefs="true" target="compile.translate.modules">
      <param name="extension" value="jrxml" />
    </antcall>
  </target>

  <target name="compile.translate.modules">
    <java classname="org.openbravo.translate.Translate" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}/Openbravo.properties' ${extension} '${base.modules}' '*/src'" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
  </target>

  <target name="installWebService" depends="init" if="wsdd">
    <taskdef name="wsAdmin" classname="org.openbravo.erpCommon.utility.WebServiceAdmin">
      <classpath refid="project.class.path" />
    </taskdef>
    <wsAdmin axisServlet="${context.url}/servlet/AxisServlet"
             baseDir="${source.path}"
             action="deploy"/>
  </target>

  <target name="uninstallWebService" depends="init">
    <taskdef name="wsAdmin" classname="org.openbravo.erpCommon.utility.WebServiceAdmin">
      <classpath refid="project.class.path" />
    </taskdef>
    <wsAdmin axisServlet="${context.url}/servlet/AxisServlet"
             baseDir="${source.path}"
             action="undeploy"/>
  </target>

  <target name="compile.translate">
    <java classname="org.openbravo.translate.Translate" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}/Openbravo.properties' ${extension} '${basedir}'" />
      <classpath refid="project.class.path" />
      <syspropertyset>
         <propertyref name="java.security.egd" />
      </syspropertyset>
    </java>
  </target>

  <target name="copy.files" if="mode.class">
    <mkdir dir="${jakarta.base}/webapps/${context.name}" />
    <copy todir="${jakarta.base}/webapps/${context.name}" encoding="UTF-8">
      <fileset dir="${base.context}" />
    </copy>
    <mkdir dir="${jakarta.base}/webapps/${context.name}/WEB-INF/classes" />
    <copy todir="${jakarta.base}/webapps/${context.name}/WEB-INF/classes" encoding="UTF-8">
      <fileset dir="${build}" />
    </copy>
    <mkdir dir="${jakarta.base}/webapps/${context.name}/WEB-INF/lib" />
      <copy todir="${jakarta.base}/webapps/${context.name}/WEB-INF/lib" file="${build.core.lib}/openbravo-core.jar" encoding="UTF-8">
    </copy>
  </target>

  <target name="compile.development" depends="generate.entities, compile, copy.files">
  </target>

  <target name="compile.complete.development" depends="compile.complete, copy.files">
    <updatesystemstatus v="RB51"/>
  </target>

  <target name="compile.web" depends="build.web.folder">
  </target>

  <target name="compile.web.development" depends="build.web.folder, copy.files">
  </target>

  <target name="build.war">
    <delete failonerror="false" file="${base.lib}/${context.name}.war" />
    <war compress="true" destfile="${base.lib}/${context.name}.war" encoding="UTF-8" webxml="${base.context}/WEB-INF/web.xml">
      <zipfileset dir="${base.context}">
        <exclude name="**/WEB-INF/web.xml" />
        <exclude name="**/WEB-INF/lib/servlet-api.jar" />
      </zipfileset>
      <classes dir="${build}" />
    </war>
    <updatesystemstatus v="RB51"/>
  </target>

  <target name="generate-wsdd">
    <delete failonerror="false">
      <fileset dir="${base.src}/org/openbravo/services/webservice" includes="**/*" />
    </delete>

    <mkdir dir="${build}" />
     <axis-wsdl2java output="${base.src}" verbose="false" url="http://centralrepository.openbravo.com/openbravo/services/WebService2?wsdl" serverside="true" debug="false">
      <mapping namespace="http://centralrepository.openbravo.com/openbravo/services/WebService2" package="org.openbravo.services.webservice" />
      <mapping namespace="/services/WebService2" package="org.openbravo.services.webservice" />
    </axis-wsdl2java>
  </target>

  <target name="update.build.timestamp" unless="timestamp">
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" delimiter="/">
      <classpath>
        <fileset dir="${base.lib}">
          <include name="**/*.jar">
          </include>
        </fileset>
      </classpath>
      <transaction>
	        UPDATE AD_SYSTEM_INFO SET LAST_BUILD=NOW()
	      </transaction>
    </sql>
  </target>

</project>