src/build.xml
author Martin Taal <martin.taal@openbravo.com>
Fri, 14 Nov 2008 13:57:26 +0000
changeset 1964 364ce5f140e3
parent 1929 ad0353d93b0f
child 2004 edb2f8c77d4c
permissions -rw-r--r--
Renamed again
<?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 SL 
 * All portions are Copyright (C) 2005-2008 Openbravo SL 
 * All Rights Reserved. 
 * Contributor(s): Openbravo S.L.
 ************************************************************************
-->

<!--
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=".">
  <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="package" value=""/>
  <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>

	<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" />
		</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}" />
		</delete>
	</target>

  <target name="sqlc" depends="copy.srcClient">
    <java classname="org.openbravo.data.Sqlc" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}'/Openbravo.properties .xsql . '${build.sqlc}'/src"/>
      <classpath refid="project.class.path"/>
    </java>
    <java classname="org.openbravo.data.Sqlc" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}'/Openbravo.properties .xsql '${base.modules}' '${build.sqlc}'/src */src"/>
      <classpath refid="project.class.path"/>
    </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}" />
		</delete>
	</target>
  
	<!-- <target name="generate.entities" depends="compile.src.gen,clean.src.gen">
      <taskdef name="workflow" classpathref="project.class.path" classname="org.openarchitectureware.workflow.ant.WorkflowAntTask"/>
   	<workflow file="${base.src}/org/openbravo/base/gen/gen_entity.oaw">
          <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> 
</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="true" propertiesFile="${base.config}/Openbravo.properties" file="${base.src}/org/openbravo/base/gen/gen_entity.oaw">
     <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>
 </target>



  <target name="compileSqlc" depends="sqlc">
    <javac srcdir="${build.sqlc}/src:${basedir}:${build.sqlc}/srcAD/org/openbravo/erpCommon/reference:${base.src.gen}:${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"/>
    </javac>
    <javac srcdir="${build.sqlc}/srcAD" 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="${build.AD}" 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="compile.src.gen" depends="init">
		<javac srcdir="${base.src}/org/openbravo/base/exception:${base.src}/org/openbravo/base/gen:${base.src}/org/openbravo/base/expression:${base.src}/org/openbravo/base/provider:${base.src}/org/openbravo/base/model:${base.src}/org/openbravo/base/session::${base.src}/org/openbravo/base/validation:${base.src}/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>
	</target>

  <target name="wad" depends="init">
    <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}'"/>
      <classpath refid="project.class.path"/>
    </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>	
    <java classname="org.openbravo.translate.CommandLine_CopyFiles" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}/Openbravo.properties' '${base.design}/design' '${base.design}' '.xml' 'true' 'false'"/>
      <classpath refid="project.class.path"/>
    </java>
    <java classname="org.openbravo.translate.CommandLine_CopyFiles" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
      <arg line="'${base.config}/Openbravo.properties' '${base.design}/design' '${base.design}' 'jasper' 'true' 'false'"/>
      <classpath refid="project.class.path"/>
    </java>
    <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="(.*/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}">
     <arg line="'${base.config}'/Openbravo.properties .xsql '${base.modules}' '${build.sqlc}'/src */src"/>
     <classpath refid="project.class.path"/>
   </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"/>
    </javac>
  </target>
 <target name="postsrcmod">
   <copy todir="${base.design}/design" >
     <fileset dir="${base.modules}" includes="*/src/**/*.html"/>
     <mapper type="regexp" from="(.*/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="**/setup-tool/**"/>
        <exclude name="*.template"/>
      </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="(.*/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="(.*/lib/runtime)(.*)" to="\2"/>
  	</copy>
    <antcall target="build.web.folder" inheritAll="true" inheritrefs="true" />
  </target>

  <target name="build.web.folder">
  	<delete includeEmptyDirs="true" dir="${base.context}/web/skins" quiet="yes" />
    <mkdir dir="${base.context}/web"/>

    <copy todir="${base.context}/web" encoding="UTF-8">
      <fileset dir="${base.web}">
      	<include name="*/**"/>
        <exclude name="skins/**"/>
      </fileset>
    </copy>
    
  	<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="(.*)(/web)(.*)" to="\1\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="(.*)(/web)(.*)" to="\1\3"/>
    </copy>
  	
    <copy todir="${base.context}/web/skins/rtl"  encoding="UTF-8">
     <fileset dir="${base.modules}">
       <include name="*/web/**/skins/**"/>
     </fileset>
     <mapper type="regexp" from="(.*)(/web)(.*)" to="\1\3"/>
    </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 ${base.web}/skins"/>
      <classpath refid="project.class.path"/>
    </java>
    <condition property="generateSpritesBool">
      <istrue value="${generateSprites}" />
    </condition>
    <antcall target="generate.sprites" inheritAll="true" inheritrefs="true" />
  </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="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">
  </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">
  </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} '${base.design}' '${package}' '*/src'"/>
      <classpath refid="project.class.path"/>
    </java>
  </target>

  <target name="installWebService" depends="init" if="wsdd">
    <java classname="org.apache.axis.client.AdminClient" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}">
      <arg line="-l${context.url}/servlet/AxisServlet ${src}/deploy.wsdd"/>
      <classpath refid="project.class.path"/>
    </java>
  </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} '${base.design}' ${package}" />
			<classpath refid="project.class.path" />
		</java>
	</target>


	<target name="uninstallWebService" depends="init">
		<java classname="org.apache.axis.client.AdminClient" fork="yes" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}">
			<arg line="-l${context.url}/servlet/AxisServlet ${src}/undeploy.wsdd" />
			<classpath refid="project.class.path" />
		</java>
	</target>

	<target name="copy.files">
		<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>
	</target>

	<target name="compile.development" depends="generate.entities, compile, copy.files">
		<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.complete.development" depends="compile.complete, copy.files">
		<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.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>
	</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://65.202.45.105/openbravo/services/WebService?wsdl" serverside="true"
             debug="false">
             <mapping namespace="http://65.202.45.105/openbravo/services/WebService"
               package="org.openbravo.services.webservice"/>
             <mapping namespace="/services/WebService"
                   package="org.openbravo.services.webservice"/>
           </axis-wsdl2java>
   </target>


</project>