blob: 32ca574bba2cec803e0c1bfff5c593cb2d26c98c [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project name="OFBiz Main Build" default="build" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:sonar="antlib:org.sonar.ant">
<import file="macros.xml"/>
<property name="site.dir" value="../site"/>
<property name="memory.initial.param" value="-Xms128M"/>
<property name="memory.max.param" value="-Xmx512M"/>
<property name="pos.memory.max.param" value="-Xmx512M"/>
<property name="memory.maxpermsize.param" value="-XX:MaxPermSize=512m"/>
<available file="applications/build.xml" property="applications.present"/>
<available file="specialpurpose/build.xml" property="specialpurpose.present"/>
<!-- ================================================================== -->
<!-- Initialization of all property settings -->
<!-- ================================================================== -->
<target name="ofbiz-init">
<property environment="env"/>
</target>
<target name="ivy-init">
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant">
<classpath>
<pathelement location="framework/base/lib/ivy-2.2.0.jar" />
</classpath>
</taskdef>
</target>
<target name="sonar-init">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath>
<pathelement location="framework/base/lib/sonar-ant-task-1.0.jar" />
</classpath>
</taskdef>
</target>
<!-- ================================================================== -->
<!-- Removes all created files and directories -->
<!-- ================================================================== -->
<target name="refresh"
description="Clean all and rebuild">
<antcall target="clean-all"/>
<antcall target="build"/>
</target>
<target name="clean-all"
description="Clean all DB, Catalina and caches data, logs, and runtime subdirectories and all specific files like .rej, .orig">
<antcall target="clean-data"/>
<antcall target="clean-logs"/>
<antcall target="clean-output"/>
<antcall target="clean-xtra"/>
<antcall target="clean-catalina"/>
<antcall target="clean-cache"/>
<antcall target="clean-tempfiles"/>
<!-- FIXME: clean-downloads introduces some issues: with cobertura (on Windows can't be deleted, not sure why),
but especially with postgresql drivers -->
<!-- antcall target="clean-downloads"/ -->
<antcall target="clean"/>
</target>
<target name="clean-downloads"
description="Clean all downloaded files">
<delete>
<fileset dir="framework/base/lib" includes="cobertura-*.jar"/>
<fileset dir="framework/base/lib" includes="sonar-*.jar"/>
<fileset dir="framework/entity/lib/jdbc" includes="postgresql-*.jar"/>
</delete>
</target>
<target name="clean-data"
description="Clean all DB data (Derby and HSQL) under runtime/data">
<subant target="clean-data">
<filelist dir="." files="framework/build.xml"/>
</subant>
<delete file="runtime/data.zip"/>
<delete file="runtime/test-list-build.xml"/>
</target>
<target name="clean-logs"
description="Clean all logs in runtime/logs">
<subant target="clean-logs">
<filelist dir="." files="framework/build.xml"/>
</subant>
</target>
<target name="clean-output"
description="Clean runtime/output directory">
<subant target="clean-output">
<filelist dir="." files="framework/build.xml"/>
</subant>
</target>
<target name="clean-xtra"
description="Clean all other files like .rej, .orig, etc.">
<delete verbose="on">
<fileset dir="." includes="**/.nbattrs,**/*~,**/.#*,**/.DS_Store,**/*.rej,**/*.orig"/>
</delete>
</target>
<target name="clean-catalina"
description="Clean Catalina data in runtime/catalina/work">
<subant target="clean-catalina">
<filelist dir="." files="framework/build.xml"/>
</subant>
</target>
<target name="clean-cache"
description="Clean the UtilCache file if errors found with old objects in the cache (Java runtime error something like 'local class incompatible')">
<property file="framework/base/config/cache.properties"/>
<echo message="NOTICE: deleting ${cache.file.store}.db"/>
<delete file="${cache.file.store}.db" verbose="true"/>
</target>
<target name="clean-tempfiles"
description="Remove files located in runtime/tempfiles (captcha, etc...)">
<subant target="clean-tempfiles">
<filelist dir="." files="framework/build.xml"/>
</subant>
</target>
<target name="download-selenium"
description="Download the selenium server v1.0.3 20.8 MB download">
<subant target="install-seleniumxml">
<filelist dir="." files="framework/testtools/build.xml"/>
</subant>
</target>
<target name="tests" depends="ofbiz-init">
<subant target="tests">
<filelist dir="." files="framework/build.xml"/>
</subant>
</target>
<target name="clean">
<subant target="clean">
<fileset dir="${basedir}/hot-deploy" casesensitive="no">
<include name="*/build.xml"/>
</fileset>
</subant>
<subant target="clean" failonerror="${specialpurpose.present}"
description="Use failonerror=false in case the specialpurpose directory is not there">
<filelist dir="." files="specialpurpose/build.xml"/>
</subant>
<subant target="clean" failonerror="${applications.present}"
description="Use failonerror=false in case the applications directory is not there">
<filelist dir="." files="applications/build.xml"/>
</subant>
<subant target="clean">
<filelist dir="." files="framework/build.xml"/>
</subant>
<delete file="ofbiz.jar"/>
<echo message="[clean] ========== Done Cleaning =========="/>
</target>
<target name="svninfo"
description="Update the Release-revision info in the footer. Note that you need a valid Internet connection and Subversion connected to the OFBiz repository for that ">
<echo message="Creating svninfo..."/>
<exec executable="svn" dir="." output="runtime/svninfo_tmp.xml">
<arg value="info"/>
<arg value="--xml"/>
</exec>
<xmlproperty file="runtime/svninfo_tmp.xml"/>
<echo message="Rev:${info.entry.commit(revision)}"/>
<basename property="releasePath" file="${info.entry.url}"/>
<echo message=" - Release-revision : ${releasePath}-${info.entry.commit(revision)}" file="runtime/svninfo.ftl"/>
<delete file="runtime/svninfo_tmp.xml"/>
<echo message="Done!"/>
</target>
<target name="clean-svninfo">
<echo message="Resetting svninfo..."/>
<echo message=" " file="runtime/svninfo.ftl"/>
<echo message="Done!"/>
</target>
<!-- ================================================================== -->
<!-- Build Components -->
<!-- ================================================================== -->
<target name="build" depends="ofbiz-init">
<echo message="[build] ========== Start Building (Compile) =========="/>
<subant inheritall="false">
<filelist dir="." files="framework/build.xml"/>
</subant>
<subant inheritall="false" failonerror="${applications.present}">
<filelist dir="." files="applications/build.xml"/>
</subant>
<subant inheritall="false" failonerror="${specialpurpose.present}">
<filelist dir="." files="specialpurpose/build.xml"/>
</subant>
<subant inheritall="false">
<fileset dir="${basedir}/hot-deploy" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</subant>
<antcall target="clean-svninfo"/>
<echo message="[build] ========== Done Building (Compile) =========="/>
</target>
<!-- ================================================================== -->
<!-- Build JavaDocs -->
<!-- ================================================================== -->
<target name="docs" depends="ofbiz-init">
<echo message="[docs] ========== Start Building (JavaDoc) =========="/>
<subant target="docs">
<filelist dir="." files="framework/build.xml"/>
</subant>
<subant target="docs" failonerror="${applications.present}">
<filelist dir="." files="applications/build.xml"/>
</subant>
<subant target="docs" failonerror="${specialpurpose.present}">
<filelist dir="." files="specialpurpose/build.xml"/>
</subant>
<subant target="docs">
<fileset dir="${basedir}/hot-deploy" casesensitive="no">
<include name="*/build.xml"/>
</fileset>
</subant>
<echo message="[docs] ========== Done Building (JavaDocs) =========="/>
</target>
<target name="docs-all" depends="build,ofbiz-init"
description="For committers : Build all javadoc into one tree for easier viewing by the community">
<echo message="[docs-all] ========== Start Building (JavaDoc) =========="/>
<mkdir dir="${site.dir}/javadocs"/>
<default-javadoc packagenames="org.ofbiz.*"
destdir="${site.dir}/javadocs"
maxmemory="256M"
windowtitle="Open for Business - API"
useexternalfile="yes">
<fileset dir="${basedir}" defaultexcludes="yes">
<include name="**/*.java"/>
<exclude name="**/ControlApplet.java"/>
<exclude name="**/ShipmentScaleApplet.java"/>
<exclude name="**/test/"/>
</fileset>
</default-javadoc>
<echo message="[docs-all] ========== Done Building (JavaDocs) =========="/>
</target>
<!-- ================================================================== -->
<!-- Contrib Targets -->
<!-- ================================================================== -->
<target name="copy-contrib">
<copy todir="${basedir}" overwrite="true" verbose="true">
<fileset dir="${basedir}/contrib" excludes="contrib/**,**/*.class"/>
</copy>
</target>
<target name="build-contrib" depends="copy-contrib,refresh"/>
<!-- ================================================================== -->
<!-- WebSite Targets -->
<!-- ================================================================== -->
<target name="build-website"
description="For committers : Update dtds and JavaDoc from OFBiz instance to site">
<antcall target="copy-dtds"/>
<antcall target="docs"/>
<antcall target="copy-apis"/>
</target>
<target name="copy-apis">
<mkdir dir="${site.dir}/api"/>
<mkdir dir="${site.dir}/api/framework"/>
<mkdir dir="${site.dir}/api/applications"/>
<mkdir dir="${site.dir}/api/specialpurpose"/>
<copy todir="${site.dir}/api/framework">
<fileset dir="${basedir}/framework" includes="*/build/javadocs/**"/>
</copy>
<copy todir="${site.dir}/api/applications">
<fileset dir="${basedir}/applications" includes="*/build/javadocs/**"/>
</copy>
<copy todir="${site.dir}/api/specialpurpose">
<fileset dir="${basedir}/specialpurpose" includes="*/build/javadocs/**"/>
</copy>
</target>
<target name="copy-dtds"
description="For committers : Copy all dtds from OFBiz instance to website">
<mkdir dir="${site.dir}/dtds"/>
<copy todir="${site.dir}/dtds" flatten="true" overwrite="true">
<fileset dir="${basedir}" includes="**/*.dtd"/>
<fileset dir="${basedir}" defaultexcludes="yes"> <!-- all but oagis and external in general -->
<include name="**/*.xsd"/>
<exclude name="**/002*.xsd"/>
<exclude name="**/068*.xsd"/>
<exclude name="**/161*.xsd"/>
<exclude name="**/196*.xsd"/>
<exclude name="**/197*.xsd"/>
</fileset>
</copy>
</target>
<!-- ================================================================== -->
<!-- Script Targets -->
<!-- ================================================================== -->
<target name="scriptfix">
<fixcrlf srcdir="${basedir}" eol="lf" eof="remove" includes="**/*.sh"/>
<fixcrlf srcdir="${basedir}" eol="crlf" includes="**/*.bat"/>
</target>
<!-- ================================================================== -->
<!-- Start OFBiz -->
<!-- ================================================================== -->
<target name="run"
description="This will start OFBiz">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${pos.memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
</java>
</target>
<target name="run-pos"
description="Start the POS (Point of sale) system">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="pos"/>
</java>
</target>
<target name="run-install" depends="build"
description="This loads all configured data; meant for generic OFBiz development, testing, demonstration, etc purposes">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
</java>
</target>
<target name="run-install-multitenant" depends="build"
description="This loads all data needed for the multi-tenancy demonstration. Caution: this creates three databases, with each one loaded with all demo data.">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
</java>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="delegator=default#DEMO1"/>
</java>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="delegator=default#DEMO2"/>
</java>
</target>
<target name="run-install-seed" depends="build"
description="This loads ONLY the seed data (not seed-initial, demo, ext* or anything else); meant for use after an update of the code to reload the seed data as it is generally maintained along with the code and needs to be in sync for operation">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="readers=seed"/>
</java>
</target>
<target name="run-install-extseed" depends="build"
description="This loads seed, seed-initial and ext data; meant for manual/generic testing, development, or going into production with a derived system based on stock OFBiz where the ext data basically replaces the demo data">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="readers=seed,seed-initial,ext"/>
</java>
</target>
<target name="run-install-exttest" depends="build"
description="This loads seed, seed-initial, ext and ext-test data; meant for automated testing with a derived system based on stock OFBiz">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="readers=seed,seed-initial,ext,ext-test"/>
</java>
</target>
<target name="run-install-readers" depends="build"
description='This loads data using the command line argument data-readers that takes a comma separated list of readers (seed, seed-initial, demo, ext, ext-test, ext-demo). On Windows XP (at least) you need top wrap the parameters in double-quotes. For instance: ant run-install-readers "-Ddata-readers=seed,seed-initial,ext"'>
<java jar="ofbiz.jar" fork="true" >
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="readers=${data-readers}"/>
</java>
</target>
<target name="run-install-file" depends="build"
description="This loads data using the command line argument 'file' to load data from a given file">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="delegator=default"/>
<arg value="file=${data-file}"/>
</java>
</target>
<!-- =================================
target: run-create-tenant
================================= -->
<target name="run-create-tenant"
depends="create-tenant-on-Derby,create-tenant-on-MySQL,create-tenant-on-Oracle,create-tenant-on-PostgreSQL"
description="Creates a new tenant in your environment, creates the delegator, loads initial data with admin-user and password (needs multitenant=Y in general.properties)">
<tstamp/>
</target>
<!-- description="This creates entity Tenant and TenantDataSource in default, installs data in the delegator and creates the admin-user and password for the tenant"
sub-target of run-create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="get-tenant-data">
<input addproperty="tenantId" message="Enter Id for the tenant: "/>
<input addproperty="tenantName" message="Enter name for tenant: "/>
<input addproperty="data-readers" message="Enter data to install.
Choices are e.g. seed,seed-initial,ext,demo.
Multipe datasets must be separated with a comma: "/>
<input addproperty="db-Platform" message="Select your default database platform, D = Derby,M = MySQL, O = Oracle, P = PostgreSQL"
validargs="D,M,O,P"/>
<echo message="Please make sure that the driver of the platform is installed and that the databases have been created (in function of the entityengine.xml datasource-names)"/>
<input addproperty="db-IP" message="Enter IP address of the database server (you may add a port number)"/>
<input addproperty="db-User" message="Enter userID of database user: "/>
<input addproperty="db-Password" message="Enter password of database user: "/>
<condition property="isDerby">
<equals arg1="${db-Platform}" arg2="D"/>
</condition>
<condition property="isMySQL">
<equals arg1="${db-Platform}" arg2="M"/>
</condition>
<condition property="isOracle">
<equals arg1="${db-Platform}" arg2="O"/>
</condition>
<condition property="isPostgreSQL">
<equals arg1="${db-Platform}" arg2="P"/>
</condition>
<antcall target="tenant-data-entry"/>
</target>
<!-- description="Creates tenant data and instance"
sub-target of run-create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="create-tenant-on-Derby" depends="get-tenant-data" if="isDerby">
<echo message="Installing on Derby"/>
<copy file="${basedir}/framework/resources/templates/AdminNewTenantData-Derby.xml" tofile="runtime/tmp/tmpTenantData.xml">
<filterset>
<filter token="tenantId" value="${tenantId}"/>
<filter token="tenantName" value="${tenantName}"/>
</filterset>
</copy>
<antcall target="run-install-file">
<param name="data-file" value="runtime/tmp/tmpTenantData.xml"/>
</antcall>
<delete file="runtime/tmp/tmpTenantData.xml"/>
<antcall target="load-tenant-data-readers"/>
<antcall target="load-tenant-admin-user-login">
<param name="userLoginId" value="${tenantId}-admin"/>
<param name="delegatorId" value="default#${tenantId}"/>
</antcall>
</target>
<!-- description="Creates tenant data and instance. Don't forget db driver(s) and already created DBs in function of the entityengine.xml datasource-names"
sub-target of run-create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="create-tenant-on-MySQL" depends="get-tenant-data" if="isMySQL">
<echo message="Installing on MySQL"/>
<copy file="${basedir}/framework/resources/templates/AdminNewTenantData-MySQL.xml" tofile="runtime/tmp/tmpTenantData.xml">
<filterset>
<filter token="tenantId" value="${tenantId}"/>
<filter token="tenantName" value="${tenantName}"/>
<filter token="db-IP" value="${db-IP}"/>
<filter token="db-User" value="${db-User}"/>
<filter token="db-Password" value="${db-Password}"/>
</filterset>
</copy>
<antcall target="run-install-file">
<param name="data-file" value="runtime/tmp/tmpTenantData.xml"/>
</antcall>
<delete file="runtime/tmp/tmpTenantData.xml"/>
<antcall target="load-tenant-data-readers"/>
<antcall target="load-tenant-admin-user-login">
<param name="userLoginId" value="${tenantId}-admin"/>
<param name="delegatorId" value="default#${tenantId}"/>
</antcall>
</target>
<!-- description="Creates tenant data and instance. Don't forget db driver(s) and already created DBs in function of the entityengine.xml datasource-names"
sub-target of run-create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="create-tenant-on-Oracle" depends="get-tenant-data" if="isOracle">
<echo message="Installing on Oracle"/>
<copy file="${basedir}/framework/resources/templates/AdminNewTenantData-Oracle.xml" tofile="runtime/tmp/tmpTenantData.xml">
<filterset>
<filter token="tenantId" value="${tenantId}"/>
<filter token="tenantName" value="${tenantName}"/>
<filter token="db-IP" value="${db-IP}"/>
<filter token="db-User" value="${db-User}"/>
<filter token="db-Password" value="${db-Password}"/>
</filterset>
</copy>
<antcall target="run-install-file">
<param name="data-file" value="runtime/tmp/tmpTenantData.xml"/>
</antcall>
<delete file="runtime/tmp/tmpTenantData.xml"/>
<antcall target="load-tenant-data-readers"/>
<antcall target="load-tenant-admin-user-login">
<param name="userLoginId" value="${tenantId}-admin"/>
<param name="delegatorId" value="default#${tenantId}"/>
</antcall>
</target>
<!-- description="Creates tenant data and instance. Don't forget db driver(s) and already created DBs in function of the entityengine.xml datasource-names"
sub-target of run-create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="create-tenant-on-PostgreSQL" depends="get-tenant-data" if="isPostgreSQL">
<echo message="Installing on PostgreSQL"/>
<copy file="${basedir}/framework/resources/templates/AdminNewTenantData-PostgreSQL.xml" tofile="runtime/tmp/tmpTenantData.xml">
<filterset>
<filter token="tenantId" value="${tenantId}"/>
<filter token="tenantName" value="${tenantName}"/>
<filter token="db-IP" value="${db-IP}"/>
<filter token="db-User" value="${db-User}"/>
<filter token="db-Password" value="${db-Password}"/>
</filterset>
</copy>
<antcall target="run-install-file">
<param name="data-file" value="runtime/tmp/tmpTenantData.xml"/>
</antcall>
<delete file="runtime/tmp/tmpTenantData.xml"/>
<antcall target="load-tenant-data-readers"/>
<antcall target="load-tenant-admin-user-login">
<param name="userLoginId" value="${tenantId}-admin"/>
<param name="delegatorId" value="default#${tenantId}"/>
</antcall>
</target>
<!-- description="displays tenant data" sub-target of get-tenant-data, can't used alone => no description, to not clutter "ant -p" -->
<target name="tenant-data-entry">
<echo>------------------------------------</echo>
<echo message="tenantId = ${tenantId}"/>
<echo>tenantName = ${tenantName}</echo>
<echo>db-Platform = ${db-Platform}</echo>
<echo>db-IP = ${db-IP}</echo>
<echo>db-User = ${db-User}</echo>
<echo>db-Password = ${db-Password}</echo>
<echo>------------------------------------</echo>
<echo>database for tenant data will be 'ofbiz_${tenantId}'</echo>
<echo>database for tenant olap data will be 'ofbizolap_${tenantId}</echo>
<echo message="Please make sure that the driver of the platform is installed and that the databases have been created (Check names just above)"/>
<echo>------------------------------------</echo>
<input addproperty="continueYN" message="Continue Y or N" validargs="N,n,Y,y"/>
</target>
<target name="load-tenant-admin-user-login"
description="Creates the admin login for the tenant with admin privileges, and a temporay password equal to 'ofbiz'. Password must be changed on first login">
<echo>------------------------------------</echo>
<echo message="Installing the admin for the tenant"/>
<echo message="Delegator = ${delegatorId}"/>
<echo message="Tenant admin = '${userLoginId}'"/>
<echo message="Password for tenant admin is 'ofbiz' must change on first login"/>
<echo>------------------------------------</echo>
<input addproperty="continueYN" message="Continue Y or N" validargs="N,n,Y,y"/>
<copy file="${basedir}/framework/resources/templates/AdminUserLoginData.xml" tofile="runtime/tmp/tmpUserLogin.xml">
<filterset>
<filter token="userLoginId" value="${userLoginId}"/>
</filterset>
</copy>
<antcall target="run-tenant-install-file">
<param name="data-file" value="runtime/tmp/tmpUserLogin.xml"/>
<param name="delegatorId" value="${delegatorId}"/>
</antcall>
<delete file="runtime/tmp/tmpUserLogin.xml"/>
</target>
<target name="load-tenant-data-readers"
description="Loads data of given data-readers in the tenant database">
<echo>------------------------------------</echo>
<echo message="Loading selected data-readers in tenant databaset"/>
<echo message="Delegator = default#${tenantId}"/>
<echo message="Data-readers = ${data-readers}"/>
<echo>------------------------------------</echo>
<input addproperty="continueYN" message="Continue Y or N" validargs="N,n,Y,y"/>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="readers=${data-readers}"/>
<arg value="delegator=default#${tenantId}"/>
</java>
</target>
<target name="run-tenant-install-file"
description="Loads the data of the tenant using the command line argument 'file' to load data from a given file">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="install"/>
<arg value="file=${data-file}"/>
<arg value="delegator=${delegatorId}"/>
</java>
</target>
<target name="load-admin-user-login"
description="Creates a user login with admin privileges and a temporary password equal to 'ofbiz'; after a succesful login the user will be prompted for a new password. Example command for the userLogin 'admin': ./ant load-admin-user-login -DuserLoginId=admin">
<fail message="userLoginId parameter is required. To add the parameter to the command for user admin: -DuserLoginId=admin">
<condition>
<not><isset property="userLoginId"/></not>
</condition>
</fail>
<copy file="${basedir}/framework/resources/templates/AdminUserLoginData.xml" tofile="runtime/tmp/tmpUserLogin.xml">
<filterset>
<filter token="userLoginId" value="${userLoginId}"/>
</filterset>
</copy>
<antcall target="run-install-file">
<param name="data-file" value="runtime/tmp/tmpUserLogin.xml"/>
</antcall>
<delete file="runtime/tmp/tmpUserLogin.xml"/>
</target>
<target name="create-admin-user-login"
description="Prompts for a user name, then creates a user login with admin privileges and a temporary password equal to 'ofbiz'. After a succesful login the user will be prompted for a new password.">
<input addproperty="userLoginId" message="Enter user name (log in with the temporary password 'ofbiz'):"/>
<antcall target="load-admin-user-login"/>
</target>
<target name="run-debug" depends="build"
description="Starts OFBiz in debugging mode">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<jvmarg value="-Xnoagent"/>
<jvmarg value="-Djava.compiler=NONE"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8091"/>
</java>
</target>
<target name="run-tests" depends="build"
description="Run OFBiz default tests, execute ant run-install before and see results in runtime/logs/test-results/html/all-tests.html.">
<java jar="ofbiz.jar" fork="true" resultproperty="test.result">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="test"/>
<env key="LC_ALL" value="C"/>
</java>
<mkdir dir="runtime/logs/test-results/html"/>
<junitreport todir="runtime/logs/test-results">
<fileset dir="runtime/logs/test-results/">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="runtime/logs/test-results/html"/>
</junitreport>
<fail message="Test run was unsuccessful">
<condition>
<not>
<equals arg1="${test.result}" arg2="0"/>
</not>
</condition>
</fail>
</target>
<target name="run-tests-with-cobertura" depends="download-cobertura, build, run-tests"
description="Same as run-tests but downloads cobertura and performs code coverage. You will need a valid Internet connection to download cobertura"/>
<target name="_check-separated-tests-already-setup">
<available file="runtime/test-list-build.xml" property="_separated-tests-already-setup"/>
</target>
<target name="_setup-separated-test-run" depends="_check-separated-tests-already-setup" unless="_separated-tests-already-setup">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="testlist"/>
<arg file="runtime/test-list-build.xml"/>
<arg value="-ant"/>
<env key="LC_ALL" value="C"/>
</java>
</target>
<target name="run-single-test" depends="download-cobertura, build"
description="Run a single test, syntax eg: ant run-single-test -Dtest.component=service -Dtest.case=service-soap-tests">
<java jar="ofbiz.jar" fork="true" resultproperty="test.result">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="test"/>
<arg value="-component=${test.component}"/>
<arg value="-case=${test.case}"/>
<env key="LC_ALL" value="C"/>
</java>
<delete dir="runtime/logs/test-results/${test.component}-${test.case}"/>
<mkdir dir="runtime/logs/test-results/${test.component}-${test.case}"/>
<move todir="runtime/logs/test-results/${test.component}-${test.case}">
<fileset dir="runtime/logs/test-results" includes="*.xml"/>
</move>
<fail message="Test run was unsuccessful">
<condition>
<not>
<equals arg1="${test.result}" arg2="0"/>
</not>
</condition>
</fail>
</target>
<target name="run-single-test-suite" depends="download-cobertura, build"
description="Run a single test suite, syntax eg: ant run-single-test-suite -Dtest.component=mycomponent -Dtest.suiteName=mytests">
<java jar="ofbiz.jar" fork="true" resultproperty="test.result">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="${memory.maxpermsize.param}"/>
<arg value="test"/>
<arg value="-component=${test.component}"/>
<arg value="-suitename=${test.suiteName}"/>
<env key="LC_ALL" value="C"/>
</java>
<fail message="Test run was unsuccessful">
<condition>
<not>
<equals arg1="${test.result}" arg2="0"/>
</not>
</condition>
</fail>
</target>
<target name="run-test-list" depends="_setup-separated-test-run"
description="Run all configured tests, stopping/starting ofbiz between each test">
<delete dir="runtime/logs/test-results"/>
<ant antfile="runtime/test-list-build.xml" target="all-tests"/>
</target>
<target name="cobertura-report"
description="generates a HTML code coverage report with cobertura, can be found in runtime/logs/cobertura-report">
<delete dir="runtime/logs/cobertura-report"/>
<mkdir dir="runtime/logs/cobertura-report"/>
<taskdef resource="tasks.properties">
<classpath>
<fileset dir="framework/base/lib">
<include name="cobertura-1.9.3.jar" />
<include name="log4j-1.2.15.jar" />
<include name="scripting/asm*.jar" />
</fileset>
</classpath>
</taskdef>
<cobertura-merge datafile="runtime/logs/cobertura.dat">
<fileset dir="runtime/logs">
<include name="cobertura-base.dat"/>
<include name="cobertura-components.dat"/>
</fileset>
</cobertura-merge>
<cobertura-report datafile="runtime/logs/cobertura.dat" destdir="runtime/logs/cobertura-report">
<dirset dir=".">
<include name="*/*/src"/>
</dirset>
<include name="**/*.java"/>
</cobertura-report>
</target>
<target name="cobertura-report-xml"
description="generates a XML file from the cobertura report, this will be use by sonar">
<delete dir="runtime/logs/cobertura-report"/>
<mkdir dir="runtime/logs/cobertura-report"/>
<taskdef resource="tasks.properties">
<classpath>
<fileset dir="framework/base/lib">
<include name="cobertura-1.9.3.jar" />
<include name="log4j-1.2.15.jar" />
<include name="scripting/asm*.jar" />
</fileset>
</classpath>
</taskdef>
<cobertura-merge datafile="runtime/logs/cobertura.dat">
<fileset dir="runtime/logs">
<include name="cobertura-base.dat"/>
<include name="cobertura-components.dat"/>
</fileset>
</cobertura-merge>
<cobertura-report format="xml" datafile="runtime/logs/cobertura.dat" destdir="runtime/logs/cobertura-report">
<dirset dir=".">
<include name="*/*/src"/>
</dirset>
<include name="**/*.java"/>
</cobertura-report>
</target>
<target name="sonar" depends="download-sonar-ant-task, sonar-init, cobertura-report-xml"
description="Sonar code analysis. You need a Sonar instance running to use it. More info on http://www.sonarsource.org/">
<exec executable="svn" dir="." output="runtime/svninfo_tmp.xml">
<arg value="info"/>
<arg value="--xml"/>
</exec>
<xmlproperty file="runtime/svninfo_tmp.xml"/>
<sonar:sonar workDir="runtime/sonar" key="org.apache:ofbiz" version="${info.entry.commit(revision)}">
<sources>
<!--framework-->
<path location="framework/appserver/src" />
<path location="framework/base/src" />
<path location="framework/bi/src" />
<path location="framework/catalina/src" />
<path location="framework/common/src" />
<path location="framework/datafile/src" />
<path location="framework/entity/src" />
<path location="framework/entityext/src" />
<path location="framework/example/src" />
<path location="framework/geronimo/src" />
<path location="framework/guiapp/src" />
<path location="framework/jetty/src" />
<path location="framework/minilang/src" />
<path location="framework/security/src" />
<path location="framework/service/src" />
<path location="framework/sql/src" />
<path location="framework/start/src" />
<path location="framework/testtools/src" />
<path location="framework/webapp/src" />
<path location="framework/webtools/src" />
<path location="framework/widget/src" />
<!--applications-->
<path location="applications/accounting/src" />
<path location="applications/commonext/src" />
<path location="applications/content/src" />
<path location="applications/humanres/src" />
<path location="applications/manufacturing/src" />
<path location="applications/marketing/src" />
<path location="applications/order/src" />
<path location="applications/party/src" />
<path location="applications/product/src" />
<path location="applications/securityext/src" />
<path location="applications/workeffort/src" />
<!--specialpurpose-->
<path location="specialpurpose/assetmaint/src" />
<path location="specialpurpose/ebay/src" />
<path location="specialpurpose/ebaystore/src" />
<path location="specialpurpose/ecommerce/src" />
<path location="specialpurpose/googlebase/src" />
<path location="specialpurpose/googlecheckout/src" />
<path location="specialpurpose/hhfacility/src" />
<path location="specialpurpose/oagis/src" />
<path location="specialpurpose/pos/src" />
</sources>
<property key="sonar.dynamicAnalysis" value="reuseReports" />
<property key="sonar.cobertura.reportPath" value="runtime/logs/cobertura-report/coverage.xml"/>
<property key="sonar.java.source" value="1.6" />
<property key="sonar.java.target" value="1.6" />
</sonar:sonar>
</target>
<!-- ================================================================== -->
<!-- Ivy targets, more info at http://ant.apache.org/ivy/ -->
<!-- ================================================================== -->
<target name="download-cobertura" depends="ivy-init">
<ivy:retrieve pattern="framework/base/lib/[artifact]-[revision].[ext]" conf="cobertura"/>
</target>
<target name="download-PG-JDBC" depends="ivy-init" description="Download postgres jdbc driver">
<ivy:retrieve pattern="framework/entity/lib/jdbc/[artifact]-[revision].[ext]" conf="postgres"/>
</target>
<target name="download-sonar-ant-task" depends="ivy-init">
<ivy:retrieve pattern="framework/base/lib/[artifact]-[revision].[ext]" conf="sonar-ant-task"/>
</target>
<!-- ================================================================== -->
<!-- Create New Component. This target will create basic directory structure for an OFBiz component in hot-deploy directory. -->
<!-- ================================================================== -->
<target name="create-component"
description="Creates the layout of an OFBiz component in the hot-deploy folder.">
<input addproperty="component-name" message="Component name: (e.g. mycomponent) [Mandatory]"/>
<input addproperty="component-resource-name" message="Component resource name: (e.g. MyComponent) [Mandatory]"/>
<input addproperty="webapp-name" message="Webapp name: (e.g. mycomponent) [Mandatory]"/>
<input addproperty="base-permission" message="Base permission: (e.g. MYCOMPONENT) [Mandatory]"/>
<echo>The following hot-deploy component will be created:
Name: ${component-name}
Resource Name: ${component-resource-name}
Webapp Name: ${webapp-name}
Base permission: ${base-permission}
Folder: ${basedir}/hot-deploy/${component-name}
</echo>
<input addproperty="confirm-component-creation" message="Confirm: " defaultvalue="N" validargs="Y,N,y,n"/>
<fail message="Component creation cancelled by the user.">
<condition>
<equals arg1="${confirm-component-creation}" arg2="N" casesensitive="false"/>
</condition>
</fail>
<fail message="Component name is mandatory">
<condition>
<equals arg1="${component-name}" arg2="" casesensitive="false" trim="yes"/>
</condition>
</fail>
<fail message="Resource name is mandatory">
<condition>
<equals arg1="${component-resource-name}" arg2="" casesensitive="false" trim="yes"/>
</condition>
</fail>
<fail message="Webapp name is mandatory">
<condition>
<equals arg1="${webapp-name}" arg2="" casesensitive="false" trim="yes"/>
</condition>
</fail>
<fail message="Base permission is mandatory">
<condition>
<equals arg1="${base-permission}" arg2="" casesensitive="false" trim="yes"/>
</condition>
</fail>
<filterset id="replacePlaceholders">
<filter token="component-name" value="${component-name}"/>
<filter token="component-resource-name" value="${component-resource-name}"/>
<filter token="base-permission" value="${base-permission}"/>
<filter token="webapp-name" value="${webapp-name}"/>
</filterset>
<mkdir dir="${basedir}/hot-deploy/${component-name}"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/config"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/data"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/data/helpdata"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/dtd"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/documents"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/entitydef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/lib"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/patches"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/script"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/servicedef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/src"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/testdef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/error"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF/actions"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/widget/"/>
<copy file="${basedir}/framework/resources/templates/ofbiz-component.xml" tofile="${basedir}/hot-deploy/${component-name}/ofbiz-component.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/build.xml" tofile="${basedir}/hot-deploy/${component-name}/build.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/TypeData.xml" tofile="${basedir}/hot-deploy/${component-name}/data/${component-resource-name}TypeData.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/SecurityData.xml" tofile="${basedir}/hot-deploy/${component-name}/data/${component-resource-name}SecurityData.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/DemoData.xml" tofile="${basedir}/hot-deploy/${component-name}/data/${component-resource-name}DemoData.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/HELP.xml" tofile="${basedir}/hot-deploy/${component-name}/data/helpdata/HELP_${component-resource-name}.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/document.xml" tofile="${basedir}/hot-deploy/${component-name}/documents/${component-resource-name}.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/entitymodel.xml" tofile="${basedir}/hot-deploy/${component-name}/entitydef/entitymodel.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/services.xml" tofile="${basedir}/hot-deploy/${component-name}/servicedef/services.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Tests.xml" tofile="${basedir}/hot-deploy/${component-name}/testdef/${component-resource-name}Tests.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/UiLabels.xml" tofile="${basedir}/hot-deploy/${component-name}/config/${component-resource-name}UiLabels.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/index.jsp" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/index.jsp" encoding="iso-8859-1">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/error.jsp" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/error/error.jsp" encoding="iso-8859-1">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/controller.xml" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF/controller.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/web.xml" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF/web.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/CommonScreens.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/CommonScreens.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Screens.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/${component-resource-name}Screens.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Menus.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/${component-resource-name}Menus.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Forms.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/${component-resource-name}Forms.xml" encoding="utf-8">
<filterset refid="replacePlaceholders"/>
</copy>
<echo>Component successfully created in folder ${basedir}/hot-deploy/${component-name}.
Restart OFBiz and then visit the URL: http://localhost:8080/${webapp-name}
</echo>
</target>
</project>