blob: 59295d1fccaa1ac68a757e2244c539b62ce5ecb5 [file] [log] [blame]
<?xml version="1.0"?>
<!--/*******************************************************************************
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Ant naming conventions:
* - regardless of the actual OS platform,'/' is the directory separator
* (Ant will convert as appropriate).
* - multi-word properties use periods '.'
* - properties ending in .jar define jarfile names only (no path)
* - properties ending in .lib are fully qualified jars (path and filename)
* - properties ending in .dir are directory paths
* - properties ending in .path are path refid names (classpath fragments)
* - multi-word targets use hyphens '-'
* - targets beginning with test- are reserved for high level test targets,
* and are used in test results parsing
* - targets typically use the form <action>-<object>-<type> (ie. package-bundle-zip)
* - multi-word macros use underscores '_'
* - multi-word macro attributes are concatenated
* e.g. 'runpathref'
* - multi-word tasks (taskdef) names are concatenated
* e.g. 'validateconnection'
* - OS environment variables are in ALLCAPS and have 'env' as a prefix
* e.g. ${env.XXX}.
* - Ant properties are lower case.
*
* Contributors:
* egwin - initial API and implementation
* egwin - update to adopt calling standards
#******************************************************************************/-->
<project name="org.eclipse.persistence.dbws.builder" default="build" basedir=".">
<!-- Test to make certain that build is run from component dir -->
<available file="../${ant.project.name}" type="dir" property="dbwsbldr.is.local"/>
<fail unless="dbwsbldr.is.local" message="Not running from '${ant.project.name}' directory"/>
<dirname property="dbwsbldr.build.location_temp" file="${ant.file.org.eclipse.persistence.dbws.builder}"/>
<pathconvert targetos="unix" property="dbwsbldr.build.location">
<path>
<pathelement location="${dbwsbldr.build.location_temp}"/>
</path>
</pathconvert>
<echo message="dbwsbldr.build.location = '${dbwsbldr.build.location}'"/>
<condition property="dbwsbldr.2.base.dir" value="../.." else="..">
<contains string="${dbwsbldr.build.location}" substring="utils/${ant.project.name}"/>
</condition>
<echo message="dbwsbldr.2.base.dir = '${dbwsbldr.2.base.dir}'"/>
<property name="dbwsbldr.2.common.plugins.dir" value="${dbwsbldr.2.base.dir}/plugins"/>
<property name="dbwsbldr.2.plugins.dir" value="${dbwsbldr.build.location}/../plugins"/>
<property name="dbwsbldr.2.buildsys.dir" value="${dbwsbldr.2.base.dir}/buildsystem"/>
<!-- OS environment variables have 'env' as a prefix -->
<property environment="env"/>
<!-- local property overrides -->
<condition property="custom.properties.message" value="Loading ${user.home}/build.properties..."
else="Custom properties file '${user.home}/build.properties' not found to load.">
<available file="${user.home}/build.properties"/>
</condition>
<echo message="${custom.properties.message}"/>
<property file="${user.home}/build.properties"/>
<property file="${dbwsbldr.build.location}/antbuild.properties"/>
<!-- Defaults, set var in ${user.home}/build.properties if different version required -->
<property name="bndtool.prefix" value="bnd"/>
<property name="bndtool.separator" value="-"/>
<property name="bndtool.criteria" value="[0.0.350,0.1.0)"/>
<!-- Dependency variables -->
<property name="ddlparser.prefix" value="org.eclipse.persistence.oracleddlparser"/>
<property name="ddlparser.criteria" value="[1.0.0,2.0.0)"/>
<!-- Primary Targets: "jar" separate for dev use -->
<target name="build" depends="clean, compile, jar" description="build ${ant.project.name} component"/>
<target name="jar" depends="bnd-package, package" description="package ${ant.project.name} component"/>
<!-- clean -->
<target name="clean" description="Clean all generated content">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${classes.dir}"/>
<fileset dir="${dbwsbldr.2.common.plugins.dir}" includes="${ant.project.name}_*.jar, ${ant.project.name}.source_*.jar"/>
</delete>
</target>
<!-- initialize varables and paths needed for compile -->
<!-- the number of properties needed now is too great for lazy loading without a target -->
<target name="init">
<property name="custom.tasks.lib" value="${dbwsbldr.2.buildsys.dir}/ant_customizations.jar"/>
<available file="${custom.tasks.lib}" property="ant_customizations.exist"/>
<fail unless="ant_customizations.exist" message="Cannot find custom tasks library: '${custom.tasks.lib}'"/>
<property name="custom.echo.task.class" value="org.eclipse.persistence.buildtools.ant.taskdefs.Say"/>
<property name="custom.selectbundle.task.class" value="org.eclipse.persistence.buildtools.ant.taskdefs.SelectBundle"/>
<taskdef name="say" classname="${custom.echo.task.class}" classpath="${custom.tasks.lib}"/>
<taskdef name="selectbundle" classname="${custom.selectbundle.task.class}" classpath="${custom.tasks.lib}"/>
<!-- This HAS to be defined after allowing user redefinitions (which will cause the condition not to set anything) -->
<!-- This tests to make sure the extensions dir exists, if not sets to a existant dummy location -->
<condition property="extensions.depend.dir" value="${dbwsbldr.2.base.dir}/../extension.lib.external"
else="${dbwsbldr.build.location}">
<available file="${dbwsbldr.2.base.dir}/../extension.lib.external" type="dir"/>
</condition>
<echo message="extensions.depend.dir = '${extensions.depend.dir}'"/>
<!-- versioning -->
<!-- These variables are set in autobuild.xml. A manual build gets defaults -->
<tstamp>
<format property="build.date" pattern="yyyyMMdd"/>
<format property="build.time" pattern="HHmm"/>
</tstamp>
<property name="build.type" value="SNAPSHOT"/>
<property name="svn.revision" value="NA"/>
<property name="version.qualifier" value="qualifier"/>
<property name="version.string" value="${release.version}.${version.qualifier}"/>
<property name="release.designation" value="EclipseLink ${release.version} Build"/>
<property name="specification.title" value="EclipseLink DBWS Builder"/>
<property name="specification.vendor" value="Eclipse.org - EclipseLink Project"/>
<property name="implementation.vendor" value="${specification.vendor}"/>
<!-- dependency properties -->
<property name="core.lib" value="${dbwsbldr.2.common.plugins.dir}/org.eclipse.persistence.core_${version.string}.jar"/>
<property name="dbws.lib" value="${dbwsbldr.2.common.plugins.dir}/org.eclipse.persistence.dbws_${version.string}.jar"/>
<property name="moxy.lib" value="${dbwsbldr.2.common.plugins.dir}/org.eclipse.persistence.moxy_${version.string}.jar"/>
<property name="jpa.lib" value="${dbwsbldr.2.common.plugins.dir}/org.eclipse.persistence.jpa_${version.string}.jar"/>
<property name="servlet.lib" value="${dbwsbldr.2.common.plugins.dir}/${servlet.jar}"/>
<property name="asm.lib" value="${dbwsbldr.2.common.plugins.dir}/${asm.jar}"/>
<property name="wsdl.lib" value="${dbwsbldr.2.plugins.dir}/${wsdl.jar}"/>
<selectbundle basename="${ddlparser.prefix}" directory="${dbwsbldr.2.plugins.dir}"
criterion="${ddlparser.criteria}" property="ddlparser.jar"
/>
<property name="ddlparser.lib" value="${dbwsbldr.2.plugins.dir}/${ddlparser.jar}"/>
<say message="ddlparser.jar = '${ddlparser.jar}'"/>
<!-- dependency tests -->
<available file="${asm.lib}" property="asm.bundle.exist"/>
<available file="${core.lib}" property="core.bundle.exist"/>
<available file="${dbws.lib}" property="dbws.bundle.exist"/>
<available file="${moxy.lib}" property="moxy.bundle.exist"/>
<available file="${jpa.lib}" property="jpa.bundle.exist"/>
<available file="${servlet.lib}" property="servlet.lib.exist"/>
<available file="${wsdl.lib}" property="wsdl.lib.exist"/>
<available file="${ddlparser.lib}" property="ddlparser.lib.exist"/>
<fail message="Cannot find: '${asm.lib}'" unless="asm.bundle.exist"/>
<fail message="Cannot find: '${core.lib}'" unless="core.bundle.exist"/>
<fail message="Cannot find: '${dbws.lib}'" unless="dbws.bundle.exist"/>
<fail message="Cannot find: '${moxy.lib}'" unless="moxy.bundle.exist"/>
<fail message="Cannot find: '${servlet.lib}'" unless="servlet.lib.exist"/>
<fail message="Cannot find: '${wsdl.lib}'" unless="wsdl.lib.exist"/>
<fail message="Cannot find: '${ddlparser.lib}'" unless="ddlparser.lib.exist"/>
<!-- Set Compile Path-->
<path id="dbwsbldr.compile.path">
<pathelement path="${asm.lib}"/>
<pathelement path="${servlet.lib}"/>
<pathelement path="${core.lib}"/>
<pathelement path="${dbws.lib}"/>
<pathelement path="${moxy.lib}"/>
<pathelement path="${jpa.lib}"/>
<pathelement path="${wsdl.lib}"/>
<pathelement path="${ddlparser.lib}"/>
</path>
<!-- Check for BND library -->
<property name="nobndtool.manifest.dir" value="${dbwsbldr.build.location}/META-INF"/>
<!-- extensions.depend.dir must be tested first to allow user overrides to work properly, **
** once bnd is added to the buildsystem directory. -->
<selectbundle basename="${bndtool.prefix}" directory="${extensions.depend.dir}" separator="${bndtool.separator}"
criterion="${bndtool.criteria}" property="bndtool.lib" includepath="true"
/>
<selectbundle basename="${bndtool.prefix}" directory="${dbwsbldr.2.buildsys.dir}" separator="${bndtool.separator}"
criterion="${bndtool.criteria}" property="bndtool.lib" includepath="true"
/>
<say message="bndtool.lib = '${bndtool.lib}'" if="bndtool.lib"/>
<say message="Bnd bundle not found in '${extensions.depend.dir}' or '${dbwsbldr.2.buildsys.dir}'!" unless="bndtool.lib"/>
<condition property="bld">
<or>
<isset property="bndtool.lib"/>
<isset property="nobnd"/>
</or>
</condition>
<condition property="bnd.bld">
<and>
<isset property="bndtool.lib"/>
<not> <isset property="nobnd"/> </not>
</and>
</condition>
</target>
<target name="fail-on-no-bnd" unless="bld">
<echo message="BND tool (${bndtool.prefix}${bndtool.separator}[version].jar) not found in either:"/>
<echo message=" the extensions.depend.dir: '${extensions.depend.dir}'"/>
<echo message=" or the buildsystem dir: '${dbwsbldr.2.buildsys.dir}'"/>
<echo message=""/>
<echo message="if you have renamed it, you can define a different"/>
<echo message="jarname by adding 'bndtool.lib=[path]/[jarname] to your'"/>
<echo message="${user.home}/build.properties file."/>
<echo message=""/>
<echo message="You can download BND from http://www.aqute.biz/Code/Download"/>
<echo message=""/>
<echo message="or if you really need to build NOW, you can use '-Dnobnd=true'"/>
<echo message="on the ant command-line. However, the manifests used will be those"/>
<echo message="checked-in for development, and will likely have errors."/>
<fail message="Missing BND library!"/>
</target>
<target name="compile" depends="init, fail-on-no-bnd" description="Compile bundle code">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
includes="**/*.java"
debug="${javac.debug}"
debuglevel="${javac.debuglevel}"
encoding="UTF-8"
optimize="${javac.optimize}"
source="1.6"
target="1.6"
deprecation="${javac.deprecation}"
failonerror="true"
memoryMaximumSize="512m"
fork="true"
classpathref="dbwsbldr.compile.path"
/>
</target>
<target name="package-src" depends="init" description="jar OSGI Source bundle">
<jar jarfile="${dbwsbldr.2.common.plugins.dir}/${ant.project.name}.source_${version.string}.jar">
<manifest>
<attribute name="Specification-Vendor" value="${specification.vendor}"/>
<attribute name="Specification-Version" value="${release.version}"/>
<attribute name="Implementation-Vendor" value="${implementation.vendor}"/>
<attribute name="Implementation-Version" value="${version.string}"/>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="${specification.title} Source"/>
<attribute name="Bundle-SymbolicName" value="${ant.project.name}.source"/>
<attribute name="Bundle-Vendor" value="${implementation.vendor}"/>
<attribute name="Bundle-Version" value="${version.string}"/>
<attribute name="Eclipse-SourceBundle" value="${ant.project.name};version=&quot;${version.string}&quot;"/>
</manifest>
<fileset dir="${dbwsbldr.2.base.dir}">
<include name="about.html"/>
<include name="readme.html"/>
<include name="license.*"/>
</fileset>
<fileset dir="${src.dir}">
<include name="org/eclipse/persistence/**/*.java"/>
</fileset>
<fileset dir="${resource.dir}">
<include name="org/eclipse/persistence/**/*.xsd"/>
</fileset>
</jar>
</target>
<target name="package" if="nobnd" depends="init, package-src" description="jar OSGI bundle">
<jar jarfile="${dbwsbldr.2.common.plugins.dir}/${ant.project.name}_${version.string}.jar" manifest="${nobndtool.manifest.dir}/MANIFEST.MF">
<fileset dir="${dbwsbldr.2.base.dir}">
<include name="about.html"/>
<include name="readme.html"/>
<include name="license.*"/>
</fileset>
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
</fileset>
<fileset dir="${resource.dir}">
<include name="org/eclipse/persistence/**/*.xsd"/>
</fileset>
<fileset dir="${src.dir}">
<include name="META-INF/services/**/*.*"/>
</fileset>
</jar>
</target>
<target name="bnd-package" if="bnd.bld" depends="init">
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${bndtool.lib}"/>
<bnd
classpath="${classes.dir}"
eclipse="false"
sourcepath="${src.dir}"
failok="false"
exceptions="true"
files="./org.eclipse.persistence.dbws.builder.bnd"
output="${dbwsbldr.2.common.plugins.dir}/${ant.project.name}_${version.string}.jar"/>
</target>
</project>