Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

501 lines (421 sloc) 20.633 kB
<!-- $Id: build.xml,v 1.57 2009/07/23 06:48:27 jhunter Exp $ -->
<!--
For instructions on how to build JDOM, please view the README.txt file.
-->
<project default="package" basedir=".">
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<tstamp >
<format property="snapshot.time" pattern="yyyy.MM.dd.HH.mm" />
<format property="year" pattern="yyyy" />
</tstamp>
<!--
Give user a chance to override without editing this file
(and without using -D arguments each time they build).
The build properties a user is likely to override include:
- lib.dir The directory where to look for the default JAR
files. Defaults to ./lib
- xml-apis.jar The JAR containing the DOM, SAX and JAXP classes.
Defaults to ${lib.dir}/xml-apis.jar
- parser.jar The JAR containing the XML parser to use.
Defaults to ${lib.dir}/xerces.jar
- jaxen.lib.dir The directory containing the Jaxen JAR libraries.
Defaults to ${lib.dir}
-->
<property file="${user.home}/jdom.build.properties" />
<property file="${basedir}/build.properties" />
<property name="Name" value="JDOM"/>
<property name="name" value="jdom"/>
<property name="version" value="2.x-${snapshot.time}"/>
<property name="version.impl" value="${version}"/>
<property name="version.spec" value="2.0.0"/>
<property name="gpg" value="gpg"
description="Path to the GNU gpg program for maven target"/>
<property name="jarbase" value="${name}-${version}" />
<property name="instrument" value="true" />
<echo message="----------- ${Name} ${version} ------------"/>
<property name="compile.debug" value="true" />
<property name="compile.optimize" value="true" />
<property name="compile.target" value="1.5" />
<property name="compile.source" value="1.5" />
<property name="compile.deprecation" value="true" />
<property name="build" value="./build"/>
<property name="core" value="./core" />
<property name="core.src" value="${core}/src/java" />
<property name="core.build" value="${build}/core" />
<property name="about" value="./core/package" />
<property name="about.src" value="${about}" />
<property name="about.build" value="${build}/about" />
<property name="metainf" value="./core/package/META-INF" />
<property name="metainf.build" value="${build}/META-INF" />
<property name="contrib" value="./contrib" />
<property name="contrib.src" value="${contrib}/src/java" />
<property name="contrib.build" value="${build}/contrib" />
<property name="junit" value="./test" />
<property name="junit.src" value="${junit}/src/java" />
<property name="junit.build" value="${build}/junit" />
<property name="junit.xml" value="${build}/junit.xml" />
<property name="junit.report" value="${build}/junit.report" />
<property name="junit.instrumented" value="${build}/instrumented" />
<property name="samples" value="./core/samples/" />
<property name="samples.src" value="${samples}/" />
<property name="samples.build" value="${build}/samples"/>
<!-- Do not set a stax.dir
but it is available for override (for Java5 for example) -->
<property name="stax.dir" value="dummy" />
<property name="lib.dir" value="./lib"/>
<property name="packages" value="org.jdom2.*"/>
<property name="build.javadocs" value="${build}/apidocs"/>
<property name="package" value="${build}/package"/>
<property name="coverage.out" value="${build}/coverage" />
<property name="mavendir" value="${build}/maven" />
<filter token="year" value="${year}"/>
<filter token="version" value="${version}"/>
<filter token="date" value="${TODAY}"/>
<filter token="jdk" value="${compile.target}" />
<!-- Default JAR libraries -->
<property name="parser.jar" value="${lib.dir}/xercesImpl.jar" />
<property name="xmlapi.jar" value="${lib.dir}/xml-apis.jar" />
<property name="jaxen.jar" value="${lib.dir}/jaxen-1.1.3.jar" />
<property name="junit.jar" value="${lib.dir}/junit-4.8.2.jar" />
<property name="isorelax.jar" value="${contrib}/lib/isorelax.jar" />
<property name="xalan.jar" value="${lib.dir}/xalan/xalan-2.7.1.jar" />
<property name="xalanser.jar" value="${lib.dir}/xalan/serializer-2.7.1.jar" />
<!-- Compilation class path -->
<path id="base.class.path">
<pathelement location="${jaxen.jar}" />
<pathelement location="${parser.jar}" />
<pathelement location="${xmlapi.jar}" />
<pathelement location="${junit.jar}" />
<pathelement location="${isorelax.jar}" />
<pathelement location="${xalan.jar}" />
<pathelement location="${xalanser.jar}" />
<!-- normally these stax jars will not be found -->
<!-- this is used for testing Java5 (the test sets stax.dir) -->
<pathelement location="${stax.dir}/jsr173_1.0_api.jar" />
<pathelement location="${stax.dir}/sjsxp.jar" />
</path>
<path id="core.class.path">
<path refid="base.class.path"/>
<pathelement location="${core.build}"/>
</path>
<path id="contrib.class.path">
<path refid="core.class.path"/>
<pathelement location="${contrib.build}"/>
</path>
<path id="junit.class.path">
<pathelement location="${junit.instrumented}" />
<pathelement location="${junit.build}"/>
<path refid="contrib.class.path"/>
<fileset dir="${lib.dir}/cobertura" includes="*.jar" />
</path>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage">
<echo message=""/>
<echo message=""/>
<echo message="JDOM Build file"/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=" available targets are:"/>
<echo message=""/>
<echo message=" - package [default] -> generates ./build/jdom2.jar and other supporting files"/>
<echo message=" - compile -> compiles the source code"/>
<echo message=" - javadoc -> generates the API documentation in ./build/javadocs"/>
<echo message=" - junit -> runs the JUnit tests"/>
<echo message=" - coverage -> generates test coverage metrics"/>
<echo message=" - eclipse -> generates an Eclipse project (source folders, jars, etc)"/>
<echo message=" - clean -> restores the distribution to its original and clean state"/>
<echo message=" - maven -> Prepares a package-upload for maven-central"/>
<echo message=""/>
<echo message=" See the comments inside the build.xml file for more details."/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=""/>
</target>
<!-- =================================================================== -->
<!-- Prepares the build directory -->
<!-- =================================================================== -->
<target name="prepare">
<mkdir dir="${build}"/>
<mkdir dir="${core.build}"/>
<mkdir dir="${about.build}"/>
<mkdir dir="${samples.build}"/>
<mkdir dir="${junit.build}"/>
<mkdir dir="${contrib.build}"/>
<mkdir dir="${metainf.build}"/>
</target>
<!-- =================================================================== -->
<!-- Compiles the source directory -->
<!-- =================================================================== -->
<target name="compile.core" depends="prepare"
description="Compiles the core source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${core.build}" >
<fileset dir="${core.src}" excludes="**/*.java" />
</copy>
<javac srcdir="${core.src}"
destdir="${core.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="${compile.deprecation}"
includeantruntime="false">
<classpath refid="base.class.path"/>
</javac>
</target>
<target name="compile.samples" depends="compile.core, compile.contrib"
description="Compiles the sample source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${samples.build}" >
<fileset dir="${samples.src}" excludes="**/*.java" />
</copy>
<javac srcdir="${samples.src}"
destdir="${samples.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="${compile.deprecation}"
includeantruntime="false">
<classpath refid="contrib.class.path" />
</javac>
</target>
<target name="compile.contrib" depends="compile.core"
description="Compiles the contrib source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${contrib.build}" >
<fileset dir="${contrib.src}" excludes="**/*.java" />
</copy>
<javac srcdir="${contrib.src}"
destdir="${contrib.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="${compile.deprecation}"
includeantruntime="false">
<classpath refid="core.class.path" />
</javac>
</target>
<target name="compile.junit" depends="compile.core, compile.contrib"
description="Compiles the junit source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${junit.build}" >
<fileset dir="${junit.src}" excludes="**/*.java" />
</copy>
<!-- ignore deprecation warnings in jUnit -->
<javac srcdir="${junit.src}"
destdir="${junit.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="no"
includeantruntime="false">
<classpath refid="contrib.class.path" />
</javac>
</target>
<target name="compile" depends="compile.core, compile.junit, compile.contrib, compile.samples"
description="Compiles all JDOM code (core, samples, junit, contrib)" />
<!-- =================================================================== -->
<!-- Creates the API documentation -->
<!-- =================================================================== -->
<target name="javadoc" depends="prepare"
description="Creates the API documentation">
<mkdir dir="${build.javadocs}"/>
<javadoc packagenames="${packages}"
sourcepath="${core.src}"
destdir="${build.javadocs}"
author="true"
version="true"
use="true"
splitindex="true"
noindex="false"
windowtitle="${Name} v${version}"
doctitle="${Name} v${version}&lt;br&gt;API Specification"
header="&lt;b&gt;${Name}&lt;br&gt;&lt;font size='-1'&gt;${version}&lt;/font&gt;&lt;/b&gt;"
bottom="Copyright &#169; ${year} Jason Hunter, Brett McLaughlin. All Rights Reserved.">
<classpath refid="base.class.path"/>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- Creates the class package -->
<!-- =================================================================== -->
<target name="package" depends="compile, javadoc, coverage"
description="Creates the class package">
<fixcrlf srcdir="." includes="**/*.bat" excludes="build*.*" eol="crlf"/>
<fixcrlf srcdir="." includes="**/*.sh" excludes="build*.*" eol="lf"/>
<!-- Filters defined specifically for updating the manifest -->
<filter token="version.spec" value="${version.spec}"/>
<filter token="version.impl" value="${version.impl}"/>
<copy todir="${metainf.build}/META-INF" filtering="yes">
<fileset dir="${metainf}"/>
<fileset dir=".">
<include name="LICENSE.txt"/>
</fileset>
</copy>
<jar jarfile="${package}/${jarbase}.jar" manifest="${metainf.build}/META-INF/MANIFEST.MF">
<fileset dir="${core.build}" includes="**/*.class" />
<fileset dir="${metainf.build}" excludes="**/MANIFEST.MF" />
</jar>
<jar jarfile="${package}/${jarbase}-contrib.jar" >
<fileset dir="${contrib.build}" includes="**/*" />
<fileset dir="${metainf.build}" excludes="**/MANIFEST.MF" />
</jar>
<jar jarfile="${package}/${jarbase}-junit.jar" >
<fileset dir="${junit.build}" includes="**/*" />
<fileset dir="${metainf.build}" excludes="**/MANIFEST.MF" />
</jar>
<jar destfile="${package}/${jarbase}-javadoc.jar"
basedir="${build.javadocs}" includes="**/*" />
<jar jarfile="${package}/${jarbase}-sources.jar" >
<fileset dir="${core.src}" includes="**/*" />
<fileset dir="${junit.src}" includes="**/*" />
<fileset dir="${contrib.src}" includes="**/*" />
</jar>
<zip destfile="${package}/${jarbase}.zip">
<fileset dir="${package}" includes="${jarbase}*.jar" />
<fileset dir="${basedir}" includes="lib/xerces* lib/jaxen* lib/xml*" />
</zip>
</target>
<!-- =================================================================== -->
<!-- Clean targets -->
<!-- =================================================================== -->
<target name="clean" description="Removes build files">
<delete dir="${build}" failonerror="false"/>
</target>
<!-- =================================================================== -->
<!-- JUnit and Test Coverage targets -->
<!-- =================================================================== -->
<target name="coverage.setup" description="Set up code-coverage metrics" depends="compile.core">
<taskdef classpathref="junit.class.path" resource="tasks.properties"/>
<delete dir="${junit.instrumented}"/>
<mkdir dir="${junit.instrumented}" />
<property name="cobertura.datafile" value="${junit.instrumented}/cobertura.ser"/>
<cobertura-instrument todir="${junit.instrumented}" datafile="${cobertura.datafile}">
<fileset dir="${core.build}">
<include name="**/*.class"/>
<!-- exclude name="**/**/jaxen/**/*.class"/ -->
</fileset>
</cobertura-instrument>
<property name="forkjunit" value="true" />
</target>
<target name="junit.nodeps"
description="Run all the JUnit tests, but do not compile anything first">
<delete dir="${junit.report}" />
<mkdir dir="${junit.report}" />
<delete dir="${junit.xml}" />
<mkdir dir="${junit.xml}" />
<!-- We need to fork to get the resources on the classpath -->
<!-- Otherwise we rely on ant's ClassLoader which does not do resources nicely -->
<junit fork="true" forkmode="once" haltonerror="false" haltonfailure="false"
failureproperty="junit.failed" printsummary="true" timeout="100000"
showoutput="true" includeantruntime="true" >
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${cobertura.datafile}" />
<classpath refid="junit.class.path" />
<formatter type="xml"/>
<batchtest haltonerror="false" haltonfailure="false"
failureproperty="junit.failed" todir="${junit.xml}" >
<sort>
<name />
<fileset dir="${junit.src}">
<include name="**/Test*.java"/>
<exclude name="**/generate/**" />
</fileset>
</sort>
</batchtest>
</junit>
<junitreport todir="${junit.report}">
<fileset dir="${junit.xml}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.report}"/>
</junitreport>
</target>
<target name="junit" depends="compile.core, compile.junit, junit.nodeps"
description="Compile code required for JUnit, then run JUnit tests"/>
<target name="coverage" depends="coverage.setup, junit"
description="Run the code coverage tool.">
<delete dir="${coverage.out}"/>
<mkdir dir="${coverage.out}" />
<cobertura-report srcdir="${core.src}" destdir="${coverage.out}" datafile="${cobertura.datafile}"/>
<echo message="See ${coverage.out}/index.html for results." />
</target>
<!-- =================================================================== -->
<!-- Eclipse targets -->
<!-- =================================================================== -->
<target name="eclipse" description="Set up your eclipse project (source folders, jars, etc.)">
<echo file="./.classpath" xml:space="preserve"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src/java"/>
<classpathentry kind="src" path="core/package"/>
<classpathentry kind="src" path="core/samples"/>
<classpathentry kind="src" path="test/src/java"/>
<classpathentry kind="src" path="contrib/src/java" excluding="org/jdom/contrib/ids/doc-files/|org/jdom/contrib/input/scanner/doc-files/|org/jdom2/contrib/ids/doc-files/|org/jdom2/contrib/ids/doc-files/|org/jdom2/contrib/input/scanner/doc-files/|org/jdom2/contrib/input/scanner/doc-files/"/>
<classpathentry kind="src" path="contrib/samples"/>
<classpathentry kind="src" path="contrib/src/java/org/jdom2/contrib/ids/doc-files"/>
<classpathentry kind="src" path="contrib/src/java/org/jdom2/contrib/input/scanner/doc-files"/>
<classpathentry kind="lib" path="lib/junit-4.8.2.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="lib" path="lib/jaxen-1.1.3.jar"/>
<classpathentry kind="lib" path="contrib/lib/isorelax.jar"/>
<classpathentry kind="lib" path="lib/xalan/serializer-2.7.1.jar"/>
<classpathentry kind="lib" path="lib/xalan/xalan-2.7.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="ebuild"/>
</classpath>
]]>
</echo>
</target>
<!-- =================================================================== -->
<!-- Maven targets -->
<!-- =================================================================== -->
<target name="maven.clean">
<delete dir="${mavendir}" includes="**/*" failonerror="false"/>
</target>
<target name="maven" depends="maven.clean, package"
description="Prepares Maven bundle to load on to Sonatype Nexus for Maven-Central">
<mkdir dir="${mavendir}" />
<mkdir dir="${mavendir}/core" />
<mkdir dir="${mavendir}/test" />
<mkdir dir="${mavendir}/contrib" />
<!-- copy the build jar -->
<copy todir="${mavendir}/core" file="${package}/${jarbase}.jar"/>
<copy todir="${mavendir}/core" file="${package}/${jarbase}-javadoc.jar"/>
<copy todir="${mavendir}/core" file="${package}/${jarbase}-sources.jar"/>
<!-- copy/rename the pom template -->
<copy filtering="true" file="maven/maven.pom" tofile="${mavendir}/core/${jarbase}.pom">
<filterset>
<filter token="artifactID" value="${name}"/>
<filter token="version" value="${version}" />
<filter token="jdk" value="${compile.target}" />
</filterset>
</copy>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${jarbase}.pom"/>
</exec>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${jarbase}.jar"/>
</exec>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${jarbase}-sources.jar"/>
</exec>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${jarbase}-javadoc.jar"/>
</exec>
<jar destfile="${mavendir}/${jarbase}-maven-bundle.jar"
basedir="${mavendir}/core"
includes="${jarbase}*" excludes="*maven-bundle*" />
</target>
</project>
<!-- End of file -->
Jump to Line
Something went wrong with that request. Please try again.