framework/entity/build.xml
<?xml version="1.0"?>
<!--
This file is subject to the terms and conditions defined in the
files 'LICENSE' and 'NOTICE', which are part of this source
code package.
-->
<project name="OFBiz - Entity" default="jar" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<import file="../../common.xml"/>
<!-- ================================================================== -->
<!-- Initialization of all property settings -->
<!-- ================================================================== -->
<property name="desc" value="Entity Component"/>
<property name="name" value="ofbiz-entity"/>
<path id="local.class.path">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${lib.dir}/jdbc" includes="*.jar"/>
<fileset dir="../base/lib" includes="*.jar"/>
<fileset dir="../base/build/lib" includes="*.jar"/>
</path>
<patternset id="src.exc.set">
</patternset>
<target name="jar" depends="classes">
<main-jar/>
<test-jar>
<test-selector>
<filename name="META-INF/services"/>
<filename name="META-INF/services/*"/>
</test-selector>
</test-jar>
</target>
<!-- SCIPIO: ivy confs to resolve (defaults to "*", meaning all)
This should include all the confs manually handled in do-lib-update task override below,
or otherwise all ivy.xml configurations that are not optional. -->
<!--
You can override the default driver - that gets updated in lib/jdbc/ automatically - using:
./ant build -Dlib.entity.jdbc.conf.default=mysql
or by setting the property in the main build or elsewhere. It must be an ivy.xml conf.
For a one-time update you can use lib.entity.jdbc.conf.update instead.
NOTE: If you added an extra (or unsupported) driver to ivy.xml and its jar filename does not start with the
ivy config name, you will have to override lib.entity.jdbc.conf.update.filepat to "[something]-*.jar"
Special setting: lib.entity.jdbc.deploy.current.always: when true, the jdbc driver directly under
framework/entity/lib/jdbc/*.jar is updated even when the ivy libs have not changed; this can help prevent
problems with git updates.
-->
<property name="lib.entity.jdbc.conf.default" value="derby"/>
<property name="lib.entity.jdbc.conf.update" value="${lib.entity.jdbc.conf.default}"/><!-- may be multiple, comma-separated -->
<property name="lib.entity.jdbc.conf.all" value="jdbc,${lib.entity.jdbc.conf.update}"/>
<property name="lib.resolve.build.confs" value="${lib.entity.jdbc.conf.all}"/>
<property name="lib.entity.jdbc.deploy.current.always" value="true"/>
<!-- Special file pattern mapping: lib.entity.jdbc.conf.filepat.map.[conf-name]
If lib.entity.jdbc.conf.filepat.map.[conf-name] does not exist for conf-name, defaults to: [conf-name-*]-*.jar -->
<property name="lib.entity.jdbc.conf.filepat.map.firebird" value="jaybird-*.jar"/>
<property name="lib.entity.jdbc.conf.filepat.map.hsql" value="hsqldb-*.jar"/>
<property name="lib.entity.jdbc.conf.filepat.map.derby" value="derby*.jar"/><!-- removed '-' for extra Derby 15 jars - see ivy.xml -->
<target name="do-lib-update" description="Downloads all jars">
<antcall target="do-lib-update-entity-general"/>
<antcall target="do-lib-update-entity-jdbc"/>
</target>
<target name="do-lib-update-always" description="Lib update callback run even if there was no need to update libs">
<if>
<and>
<equals arg1="${lib.entity.jdbc.deploy.current.always}" arg2="true"/>
<not><equals arg1="${lib.update.needed}" arg2="true"/></not>
</and>
<then>
<!-- 2019-05-27: even if we didn't run lib update, we must honor build(.local).properties -->
<echo message="Configured default JDBC driver (lib.entity.jdbc.conf.default): ${lib.entity.jdbc.conf.default}" level="info"/>
<echo message="Target JDBC driver for update (lib.entity.jdbc.conf.update): ${lib.entity.jdbc.conf.update}" level="info"/>
<!-- FIXME: do-lib-update-always should really not force-redeploy using do-lib-update-entity-jdbc-current here,
but for now this is less likely to cause real issues than trying to write the new code that detects current state -->
<antcall target="do-lib-update-entity-jdbc-current"/>
</then>
</if>
</target>
<target name="do-lib-update-entity-general">
<!-- NOTE: does nothing yet, but may in future... -->
</target>
<target name="do-lib-update-entity-jdbc">
<echo message="Configured default JDBC driver (lib.entity.jdbc.conf.default): ${lib.entity.jdbc.conf.default}" level="info"/>
<echo message="Target JDBC driver for update (lib.entity.jdbc.conf.update): ${lib.entity.jdbc.conf.update}" level="info"/>
<antcall target="do-lib-update-entity-jdbc-unused"/>
<antcall target="do-lib-update-entity-jdbc-current"/>
</target>
<target name="do-lib-update-entity-jdbc-unused">
<if>
<contains string="${lib.resolve.build.confs}" substring="jdbc"/>
<then>
<ivy:retrieve pattern="lib/jdbc/unused/${lib.update.filename.pattern.ivy}" conf="jdbc"/>
</then>
</if>
</target>
<target name="do-lib-update-entity-jdbc-current">
<!-- TODO: want a version of do-lib-update-entity-jdbc-current that skips the delete and ivy:retrieve
if the current state would not change by those actions -->
<for list="${lib.entity.jdbc.conf.update}" delimiter="," param="entity.conf.name.param">
<sequential>
<var name="entity.conf.name" value="@{entity.conf.name.param}"/>
<if>
<not><equals arg1="entity.conf.name" arg2="none"/></not>
<then>
<var name="entity.conf.filepat" unset="true"/><!-- ant-contrib kludge for lack of <varcopy/> -->
<if>
<isset property="lib.entity.jdbc.conf.filepat.map.${entity.conf.name}"/>
<then><propertycopy name="entity.conf.filepat" from="lib.entity.jdbc.conf.filepat.map.${entity.conf.name}"/></then>
<else><property name="entity.conf.filepat" value="${entity.conf.name}-*.jar"/></else>
</if>
<echo message="entity.conf.filepat: ${entity.conf.filepat}" level="verbose"/>
<delete><fileset dir="lib/jdbc"><include name="${entity.conf.filepat}"/></fileset></delete>
<ivy:retrieve pattern="lib/jdbc/${lib.update.filename.pattern.ivy}" conf="${entity.conf.name}"/>
</then>
</if>
</sequential>
</for>
</target>
<!-- SCIPIO: Libraries manually committed to repo, excluded from ivy (or emulated) file cleanout/removal
NOTE: This should be defined implicitly as an include (treated as exclude as needed) -->
<selector id="lib.update.manual.files">
<or>
<!-- Do not delete the JDBC driver directly under lib/jdbc/ -->
<filename name="jdbc/*.jar"/>
</or>
</selector>
</project>