Rev 263 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?xml version="1.0"?>
<!--
File: build.xml
Copyright (C) 2006 Steve Ratcliffe
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 or 3 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Author: Steve Ratcliffe
Create date: 3 Jan 2008
-->
<project name="splitter" default="dist" basedir=".">
<!-- Init -->
<property name="top" value="."/>
<!--
This file is not checked into svn, so you can create it and put any
property definitions that you want to override those below.
-->
<property file="${top}/local.properties"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="src" value="src"/>
<property name="lib" value="lib"/>
<property name="test" value="test"/>
<property name="doc" value="doc"/>
<property name="javadoc" value="${doc}/api"/>
<property name="resources" value="resources"/>
<property name="build.classes" value="${build}/classes"/>
<property name="build.test-classes" value="${build}/test-classes"/>
<property name="build.test-output" location="${build}/test-output"/>
<!-- Third party libraries -->
<property name="xpp.jar" location="${lib}/xpp3-1.1.4c.jar"/>
<property name="testng.jar" location="${lib}/testng-5.9-jdk15.jar"/>
<property name="osmbin.jar" location="${lib}/osmpbf.jar"/>
<property name="fastutil.jar" location="${lib}/fastutil.jar"/>
<property name="dsiutils.jar" location="${lib}/dsiutils-1.0.11.jar"/>
<property name="protobuf.jar" location="${lib}/protobuf.jar"/>
<!-- the project's build timestamp -->
<tstamp>
<format property="build.timestamp" pattern="yyyy-MM-dd'T'HH:mm:ssZ" />
</tstamp>
<!-- Classpaths -->
<path id="classpath">
<pathelement location="${build.classes}"/>
<pathelement path="${xpp.jar}"/>
<pathelement path="${osmbin.jar}"/>
<pathelement path="${fastutil.jar}"/>
<pathelement path="${dsiutils.jar}"/>
<pathelement path="${protobuf.jar}"/>
</path>
<path id="test.classpath">
<path refid="classpath"/>
<pathelement location="${build.test-classes}"/>
<pathelement path="${testng.jar}"/>
</path>
<!-- Prepare - make all the directories -->
<target name="prepare">
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.test-classes}"/>
<mkdir dir="${build.test-output}"/>
<property environment="env"/>
<condition property="have.svn">
<or>
<available file="svnversion" filepath="${env.PATH}"/>
<available file="svnversion.exe" filepath="${env.PATH}"/>
<available file="svnversion.exe" filepath="${env.Path}"/>
</or>
</condition>
<condition property="have.git">
<available file="${top}/.git"/>
</condition>
</target>
<target name="svn-version" if="have.svn">
<exec executable="svnversion" dir="${top}" logError="false"
outputproperty="svn.version.tmp" resultproperty="svnversion.result"
failifexecutionfails="false">
<arg value="-n" /><arg value="-c" />
<redirector><outputfilterchain><tokenfilter>
<replaceregex pattern="^([0-9]*:)?" replace="" />
<replaceregex pattern="^exported$" replace="" />
</tokenfilter></outputfilterchain></redirector>
</exec>
<condition property="svn.version.build" value="${svn.version.tmp}" else="unknown">
<and>
<isset property="svn.version.tmp" />
<equals arg1="${svnversion.result}" arg2="0" />
<not><equals arg1="${svn.version.tmp}" arg2="" /></not>
</and>
</condition>
<property name="project.version" value="${svn.version.build}" />
</target>
<target name="git-version" if="have.git">
<exec executable="git" dir="${top}" logError="false"
outputproperty="git.version.tmp" resultproperty="gitdescribe.result"
failifexecutionfails="false">
<arg value="describe" /><arg value="--dirty" /><arg value="--tags" /><arg value="--always" />
</exec>
<condition property="git.version.build" value="${git.version.tmp}">
<and>
<isset property="git.version.tmp" />
<equals arg1="${gitdescribe.result}" arg2="0" />
<not><equals arg1="${git.version.tmp}" arg2="" /></not>
</and>
</condition>
<property name="project.version" value="${git.version.build}" />
</target>
<target name="check-version" depends="svn-version, git-version">
<property file="${build.classes}/splitter-version.properties"/>
<condition property="have.version">
<or>
<and>
<isset property="have.svn"/>
<equals arg1="${svn.version.build}" arg2="${svn.version}"/>
</and>
<and>
<not><isset property="have.svn"/></not>
<available file="${build}/classes/splitter-version.properties"/>
</and>
</or>
</condition>
</target>
<target name="version-file" unless="have.version">
<property name="project.version" value="${build.timestamp}" />
<property name="svn.version.build" value="unknown"/>
<propertyfile file="${build.classes}/splitter-version.properties">
<entry key="svn.version" value="${svn.version.build}" />
<entry key="build.timestamp" value="${build.timestamp}" />
</propertyfile>
</target>
<target name="compile" depends="prepare" description="main compilation">
<javac srcdir="${src}" destdir="${build.classes}" debug="yes" includeantruntime="false">
<include name="**/*.java"/>
<classpath refid="classpath"/>
</javac>
</target>
<target name="compile.tests" depends="prepare" description="test compilation">
<javac srcdir="${test}" destdir="${build.test-classes}" debug="yes" includeantruntime="false">
<include name="**/*.java"/>
<classpath refid="test.classpath"/>
</javac>
</target>
<target name="javadoc" description="Create the javadoc">
<mkdir dir="doc"/>
<javadoc destdir="${javadoc}">
<fileset dir="${src}" includes="**/*.java"/>
<classpath refid="classpath"/>
</javadoc>
</target>
<target name="run.tests" depends="compile.tests">
<!-- Run the java unit tests -->
<taskdef resource="testngtasks" classpath="${testng.jar}"/>
<testng classpathref="test.classpath" outputdir="${build.test-output}" haltonfailure="true">
<classfileset dir="${build.test-classes}">
<include name="**/*.class"/>
</classfileset>
</testng>
</target>
<target name="dist" depends="build, check-version, version-file" description="Make the distribution area">
<mkdir dir="${dist}"/>
<mkdir dir="${dist}/doc/api"/>
<!-- Make the jar -->
<jar basedir="${build.classes}" jarfile="${dist}/splitter.jar" manifest="resources/MANIFEST.MF">
<!--<manifest>-->
<!--<attribute name="Main-Class" value="uk.me.parabola.splitter.Main"/>-->
<!--</manifest>-->
<include name="**/*.class"/>
<include name="*.csv"/>
<include name="*.properties"/>
<zipfileset src="${xpp.jar}" includes="**/*.class,META-INF/services/**"/>
</jar>
<copy todir="${dist}/doc">
<fileset dir="doc" includes="*.txt"/>
</copy>
<!-- Copy the source code -->
<copy todir="${dist}/src">
<fileset dir="${src}"/>
</copy>
<copy todir="${dist}/test">
<fileset dir="${test}"/>
</copy>
<copy todir="${dist}/lib">
<fileset dir="${lib}"/>
</copy>
<!-- misc -->
<copy todir="${dist}">
<fileset dir="${basedir}">
<include name="README"/>
<include name="LICENCE*"/>
<include name="build.xml"/>
<include name="external.properties"/>
<include name="resources/**"/>
</fileset>
</copy>
</target>
<!-- Clean everything -->
<target name="clean">
<delete dir="${build}"/>
</target>
<!-- Clobber all generated and built files -->
<target name="clobber" depends="clean">
<delete dir="${dist}"/>
</target>
<!-- Main -->
<target name="build" depends="compile,compile.tests,run.tests">
<copy todir="${build.classes}">
<fileset dir="${resources}">
<include name="*.csv"/>
<include name="*.properties"/>
<include name="**/*.trans"/>
</fileset>
</copy>
</target>
<target name="rebuild" depends="clean, build"/>
</project>