blob: 24e6369a7967014b3aca627fb621ffad90693c5d [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 concatinated
* e.g. 'runpathref'
* - multi-word tasks (taskdef) names are concatinated
* 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
#******************************************************************************/-->
<project name="javax.persistence" default="build" basedir=".">
<available file="../${ant.project.name}" type="dir" property="jpaproto.is.local"/>
<!-- Test to make sure that the calling script doesn't inherit the variable -->
<!-- (should be set locally, and be destroyed upon return) -->
<fail message="Not running from '${ant.project.name}' directory" unless="jpaproto.is.local"/>
<dirname property="jpaproto.build.location_temp" file="${ant.file.javax.persistence}"/>
<pathconvert targetos="unix" property="jpaproto.build.location">
<path>
<pathelement location="${jpaproto.build.location_temp}"/>
</path>
</pathconvert>
<condition property="jpaproto.2.base.dir" value="../../.." else="..">
<contains string="${jpaproto.build.location}" substring="jpa"/>
</condition>
<property name="jpaproto.2.common.plugins.dir" value="${jpaproto.2.base.dir}/plugins"/>
<property name="jpaproto.2.buildsys.dir" value="${jpaproto.2.base.dir}/buildsystem"/>
<!-- Properties usually defined in build.properties, set here to avoid easy redefinition. -->
<!-- Persistence Version properties -->
<tstamp>
<format property="jpaproto.build.date" pattern="yyyyMMdd"/>
<format property="jpaproto.build.time" pattern="HHmm"/>
</tstamp>
<property name="jpaproto.qualifier" value="v${jpaproto.build.date}${jpaproto.build.time}"/>
<property name="jpaproto.spec.vendor" value="Sun Microsystems Inc."/>
<property name="implementation.vendor" value="Eclipse.org - EclipseLink Project"/>
<property name="jpaproto.spec.version" value="2.0"/>
<property name="jpaproto.version" value="2.0.0"/>
<property name="jpaproto.bundle.name" value="Java Persistence API 2.0"/>
<!-- Project infrastructure properties -->
<property name="src.dir" value="src"/>
<property name="package.dir" value=".."/>
<property name="classes.dir" value="classes"/>
<property name="jpaproto.resource.dir" value="META-INF"/>
<property name="jpaproto.jar" value="${ant.project.name}_${jpaproto.version}.${jpaproto.qualifier}.jar"/>
<property name="jpaproto.src.jar" value="${ant.project.name}.source_${jpaproto.version}.${jpaproto.qualifier}.jar"/>
<!-- 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"/>
<!-- Defaults, set var in ${user.home}/build.properties if different version required -->
<property name="bndtool.jar" value="bnd-0.0.366.jar"/>
<!-- Primary Targets -->
<target name="build" depends="clean, compile, jar" description="build ${ant.project.name}_${jpaproto.version} component"/>
<target name="jar" depends="bnd-package, package" description="package ${ant.project.name} component"/>
<!-- clean -->
<target name="clean" description="Clean all generated content">
<delete dir="${classes.dir}" includeEmptyDirs="true" failonerror="false" quiet="true"/>
<!-- Remove Build artifacts, and potential "confict" files from check-out -->
<delete failonerror="false" quiet="true">
<fileset dir="${package.dir}" includes="${jpaproto.jar}*"/>
</delete>
<delete failonerror="false" quiet="true">
<fileset dir="${package.dir}" includes="${jpaproto.src.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">
<!-- 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="${jpaproto.2.base.dir}/../extension.lib.external"
else="${jpaproto.build.location}">
<available file="${jpaproto.2.base.dir}/../extension.lib.external" type="dir"/>
</condition>
<echo message="extensions.depend.dir = '${extensions.depend.dir}'"/>
<!-- Compiler flag properties -->
<property name="javac.debug" value="true"/>
<property name="javac.optimize" value="off"/>
<property name="javac.deprecation" value="off"/>
<property name="javac.version" value="1.5"/>
<!-- Set Compile Path-->
<path id="jpaproto.compile.path">
<pathelement path="${jpaproto.2.common.plugins.dir}/osgi.core.zip"/>
<pathelement path="${jpaproto.2.common.plugins.dir}/osgi.cmpn_4.1.0.jar"/>
</path>
<!-- Check for BND library -->
<property name="alt.manifest.dir" value="${jpaproto.build.location}/META-INF"/>
<condition property="bnd.lib" value="${extensions.depend.dir}/${bndtool.jar}">
<available file="${extensions.depend.dir}/${bndtool.jar}"/>
</condition>
<condition property="bnd.lib" value="${jpaproto.2.buildsys.dir}/${bndtool.jar}">
<available file="${jpaproto.2.buildsys.dir}/${bndtool.jar}"/>
</condition>
<echo message="bnd.lib = '${bnd.lib}'"/>
<condition property="bld">
<or>
<isset property="bnd.lib"/>
<isset property="nobnd"/>
</or>
</condition>
<condition property="bnd.bld">
<and>
<isset property="bnd.lib"/>
<not> <isset property="nobnd"/> </not>
</and>
</condition>
</target>
<target name="fail-on-no-bnd" unless="bld">
<echo message="BND tool (${bndtool.jar}) not found in either:"/>
<echo message=" the extensions.depend.dir: '${extensions.depend.dir}'"/>
<echo message=" or the buildsystem dir: '${jpaproto.2.buildsys.dir}'"/>
<echo message=""/>
<echo message="if you have a different version, you can define a different"/>
<echo message="jarname by adding 'bndtool.jar=bnd-{version}.jar 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>
<!-- compile -->
<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="**"
debug="${javac.debug}"
debuglevel="${javac.debuglevel}"
optimize="${javac.optimize}"
source="${javac.version}"
target="${javac.version}"
deprecation="${javac.deprecation}"
failonerror="true"
memoryMaximumSize="512m"
fork="true">
<classpath>
<path refid="jpaproto.compile.path"/>
</classpath>
</javac>
</target>
<!-- package -->
<target name="package" if="nobnd" depends="init" description="jar OSGI bundle">
<jar jarfile="${package.dir}/${jpaproto.jar}" duplicate="preserve" manifest="${alt.manifest.dir}/MANIFEST.MF">
<fileset dir="${jpaproto.2.base.dir}">
<include name="about.html"/>
<include name="readme.html"/>
<include name="license.*"/>
</fileset>
<fileset dir="."
includes="readme.txt"
/>
<fileset dir="${src.dir}"
includes="**/*.xsd"
/>
<fileset dir="${classes.dir}"
includes="**/*.class"
/>
</jar>
<jar jarfile="${package.dir}/${jpaproto.src.jar}" duplicate="preserve">
<manifest>
<attribute name="Specification-Vendor" value="${jpaproto.spec.vendor}"/>
<attribute name="Specification-Version" value="${jpaproto.spec.version}"/>
<attribute name="Implementation-Vendor" value="${implementation.vendor}"/>
<attribute name="Implementation-Version" value="${jpaproto.version}"/>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="${jpaproto.bundle.name} Source"/>
<attribute name="Bundle-SymbolicName" value="${ant.project.name}.source"/>
<attribute name="Bundle-Vendor" value="${implementation.vendor}"/>
<attribute name="Bundle-Version" value="${jpaproto.version}.${jpaproto.qualifier}"/>
<attribute name="Eclipse-SourceBundle" value="${ant.project.name};version=&quot;${jpaproto.version}.${jpaproto.qualifier}&quot;"/>
</manifest>
<fileset dir="${jpaproto.2.base.dir}">
<include name="about.html"/>
<include name="readme.html"/>
<include name="license.*"/>
</fileset>
<fileset dir="."
includes="readme.txt"
/>
<fileset dir="${src.dir}"
includes="**"
/>
</jar>
</target>
<target name="bnd-package" if="bnd.bld" depends="init">
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${bnd.lib}"/>
<bnd
classpath="${classes.dir}"
eclipse="false"
sourcepath="${src.dir}"
failok="false"
exceptions="true"
files="./javax.persistence.bnd"
output="${package.dir}/${jpaproto.jar}"/>
<jar jarfile="${package.dir}/${jpaproto.src.jar}" duplicate="preserve">
<manifest>
<attribute name="Specification-Vendor" value="${jpaproto.spec.vendor}"/>
<attribute name="Specification-Version" value="${jpaproto.spec.version}"/>
<attribute name="Implementation-Vendor" value="${implementation.vendor}"/>
<attribute name="Implementation-Version" value="${jpaproto.version}"/>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="${jpaproto.bundle.name} Source"/>
<attribute name="Bundle-SymbolicName" value="${ant.project.name}.source"/>
<attribute name="Bundle-Vendor" value="${implementation.vendor}"/>
<attribute name="Bundle-Version" value="${jpaproto.version}.${jpaproto.qualifier}"/>
<attribute name="Eclipse-SourceBundle" value="${ant.project.name};version=&quot;${jpaproto.version}.${jpaproto.qualifier}&quot;"/>
</manifest>
<fileset dir="${jpaproto.2.base.dir}">
<include name="about.html"/>
<include name="readme.html"/>
<include name="license.*"/>
</fileset>
<fileset dir="."
includes="readme.txt"
/>
<fileset dir="${src.dir}"
includes="**"
/>
</jar>
</target>
</project>