Index: build.xml
===================================================================
--- build.xml	(revision 367)
+++ build.xml	(working copy)
@@ -17,7 +17,7 @@
     Author: Steve Ratcliffe
     Create date: 3 Jan 2008
 -->
-<project name="splitter" default="dist" basedir=".">
+<project name="splitter" default="dist" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
 
   <!-- Init -->
   <property name="top" value="."/>
@@ -26,6 +26,8 @@
 	<property name="ant.build.javac.target" value="1.7"/>
 	<property name="ant.build.javac.source" value="1.7"/>
 
+	<property name="project.name" value="${ant.project.name}"/>
+
   <!--
     This file is not checked into svn, so you can create it and put any
     property definitions that you want to override those below.
@@ -45,12 +47,10 @@
   <property name="build.test-classes" value="${build}/test-classes"/>
   <property name="build.test-output" location="${build}/test-output"/>
 
+	<property name="project.jar" value="${dist}/${project.name}.jar"/>
+
   <!-- 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="protobuf.jar" location="${lib}/protobuf.jar"/>
+	<property name="xpp.jar" location="${lib}/compile/xpp3-1.1.4c.jar"/>
 
 	<!-- the project's build timestamp -->
 	<tstamp>
@@ -57,23 +57,71 @@
 		<format property="build.timestamp" pattern="yyyy-MM-dd'T'HH:mm:ssZ" />
 	</tstamp>
 
+	<!-- ivy dependency support -->
+	<property name="ivy.version" value="2.2.0"/>
+	<property name="ivy.lib.dir" value="${basedir}/lib" />
+	<property name="ivy.jar.dir" value="${ivy.lib.dir}/build" />
+	<property name="ivy.retrieve.pattern" value="${ivy.lib.dir}/[conf]/[artifact]-[revision].[ext]" />
+	<property name="ivy.distrib.dir" value="ivy-distrib" />
   
-
   <!-- Classpaths -->
   <path id="classpath">
     <pathelement location="${build.classes}"/>
-    <pathelement path="${xpp.jar}"/>
-    <pathelement path="${osmbin.jar}"/>
-    <pathelement path="${fastutil.jar}"/>
-    <pathelement path="${protobuf.jar}"/>
+		<fileset dir="${ivy.lib.dir}/compile" />
   </path>
 
   <path id="test.classpath">
     <path refid="classpath"/>
     <pathelement location="${build.test-classes}"/>
-    <pathelement path="${testng.jar}"/>
+		<fileset dir="${ivy.lib.dir}/test" includes="*.jar"/>
   </path>
 
+	<!-- targets for downloading and registering ivy -->
+	<target name="ivy-availability" description="Checks if the ivy library is available">
+		<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-${ivy.version}.jar" />
+		<available property="ivy.available" file="${ivy.jar.file}" />
+	</target>
+
+	<target name="download-ivy" unless="ivy.available" description="Downloads the ivy library from public repositories.">
+		<delete dir="${ivy.jar.dir}"/>
+		<mkdir dir="${ivy.jar.dir}" />
+		<mkdir dir="${ivy.lib.dir}/compile" />
+		<mkdir dir="${ivy.lib.dir}/test" />
+		<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
+				 dest="${ivy.jar.file}" usetimestamp="true"/>
+	</target>
+
+	<target name="init-ivy" depends="ivy-availability, download-ivy" description="Registers ivy with ant and initializes it." unless="ivy.initialized">
+		<path id="ivy.lib.path">
+			<fileset dir="${ivy.jar.dir}" includes="*.jar" />
+			<path refid="test.classpath"/>
+		</path>
+		<taskdef resource="org/apache/ivy/ant/antlib.xml"
+			 uri="antlib:org.apache.ivy.ant"
+			 classpathref="ivy.lib.path" />
+		<ivy:configure />
+		<ivy:info />
+		<property name="ivy.initialized" value="true"/>
+	</target>
+
+	<!-- targets for fetching dependencies via ivy -->
+	<target name="resolve-compile" depends="init-ivy" description="Downloads compile dependencies using ivy.">
+		<ivy:retrieve conf="compile" log="download-only" />
+	</target>
+	<target name="resolve-test" depends="init-ivy" description="Downloads test program dependencies using ivy.">
+		<ivy:retrieve conf="test" log="download-only"/>
+	</target>
+	<target name="resolve" depends="resolve-compile, resolve-test"
+					description="Downloads all program dependencies using ivy." />
+
+	<!-- targets for publishing the project (locally) via ivy -->
+	<target name="publish" depends="dist">
+		<copy file="${project.jar}"
+					tofile="${ivy.distrib.dir}/jars/${project.name}-${project.version}.jar"/>
+		<ivy:deliver pubrevision="${project.version}"/>
+		<ivy:publish resolver="local" pubrevision="${project.version}" overwrite="true"/>
+	</target>
+
   <!-- Prepare - make all the directories -->
   <target name="prepare">
     <mkdir dir="${build.classes}"/>
@@ -156,7 +204,7 @@
 		</propertyfile>
 	</target>
 
-  <target name="compile" depends="prepare" description="main compilation">
+  <target name="compile" depends="prepare, resolve-compile" description="main compilation">
     <javac srcdir="${src}" destdir="${build.classes}" debug="yes" includeantruntime="false">
       <include name="**/*.java"/>
       <classpath refid="classpath"/>
@@ -163,7 +211,7 @@
     </javac>
   </target>
 
-  <target name="compile.tests" depends="prepare" description="test compilation">
+  <target name="compile.tests" depends="prepare, resolve-test" description="test compilation">
     <javac srcdir="${test}" destdir="${build.test-classes}" debug="yes" includeantruntime="false">
       <include name="**/*.java"/>
       <classpath refid="test.classpath"/>
@@ -180,7 +228,7 @@
 
   <target name="run.tests" depends="compile.tests">
     <!-- Run the java unit tests -->
-    <taskdef resource="testngtasks" classpath="${testng.jar}"/>
+    <taskdef resource="testngtasks" classpathref="test.classpath"/>
     <testng classpathref="test.classpath" outputdir="${build.test-output}" haltonfailure="true">
       <classfileset dir="${build.test-classes}">
         <include name="**/*.class"/>
@@ -194,17 +242,6 @@
     <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>
@@ -217,7 +254,7 @@
       <fileset dir="${test}"/>
     </copy>
     <copy todir="${dist}/lib">
-      <fileset dir="${lib}"/>
+      <fileset dir="${lib}/compile"/>
     </copy>
 
     <!-- misc -->
@@ -230,6 +267,27 @@
         <include name="resources/**"/>
       </fileset>
     </copy>
+
+		<manifestclasspath property="manifest_cp" jarfile="${project.jar}">
+			<classpath>
+				<fileset dir="${dist}/lib">
+					<include name="*.jar" />
+				</fileset>
+			</classpath>
+		</manifestclasspath>
+
+		<!-- Make the jar -->
+		<jar basedir="${build.classes}" jarfile="${dist}/splitter.jar">
+			<manifest>
+				<attribute name="Main-Class" value="uk.me.parabola.splitter.Main" />
+				<attribute name="Class-Path" value="${manifest_cp}" />
+				<attribute name="Implementation-Version" value="${project.version}" />
+			</manifest>
+			<include name="**/*.class"/>
+			<include name="*.csv"/>
+			<include name="*.properties"/>
+			<zipfileset src="${xpp.jar}" includes="**/*.class,META-INF/services/**"/>
+		</jar>
   </target>
 
   <!-- Clean everything -->
@@ -240,20 +298,20 @@
   <!-- Clobber all generated and built files -->
   <target name="clobber" depends="clean">
     <delete dir="${dist}"/>
+		<delete dir="${ivy.lib.dir}"/>
   </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 name="clean-ivy" description="Clean the ivy installation.">
+		<delete dir="${ivy.jar.dir}"/>
   </target>
 
+	<target name="clean-cache" depends="init-ivy" description="Clean the ivy cache.">
+		<ivy:cleancache />
+	</target>
+
+	<!-- Main -->
+	<target name="build" depends="compile,compile.tests,run.tests" />
+
   <target name="rebuild" depends="clean, build"/>
-
 </project>
 
Index: ivysettings.xml
===================================================================
--- ivysettings.xml	(revision 0)
+++ ivysettings.xml	(working copy)
@@ -0,0 +1,25 @@
+<ivysettings>
+	<property name="mkgmap.ivy.repo" value="http://ivy.mkgmap.org.uk/repo" />
+	<settings defaultResolver="custom" />
+
+	<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
+	<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
+	<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
+	<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
+	<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
+
+	<resolvers>
+		<chain name="custom" returnFirst="true">
+
+			<resolver ref="default" />
+
+			<url name="mkgmap">
+				<ivy pattern="${mkgmap.ivy.repo}/[organisation]/[module]/[revision]/ivys/ivy.xml" />
+				<artifact pattern="${mkgmap.ivy.repo}/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" />
+			</url>
+
+		</chain>
+
+	</resolvers>
+
+</ivysettings>
Index: ivy.xml
===================================================================
--- ivy.xml	(revision 0)
+++ ivy.xml	(working copy)
@@ -0,0 +1,35 @@
+<ivy-module version="2.0">
+	<info organisation="uk.org.mkgmap" module="splitter"/>
+
+	<configurations>
+		<conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
+		<conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
+		<conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
+		<conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
+		<conf name="test" visibility="public"
+					description="this scope indicates that the dependency is required for running tests."
+					/>
+
+	</configurations>
+
+	<dependencies>
+		<dependency org="com.google.protobuf" name="protobuf-java"
+								rev="2.5.0"
+								conf="compile->compile(*),master(*)" />
+
+		<dependency org="crosby" name="osmpbf"
+								rev="1.3.3"
+								conf="compile->compile(*),master(*)"/>
+
+		<dependency org="it.unimi.dsi" name="fastutil"
+								rev="6.5.2-mkg.1"
+								conf="compile->default(*)"/>
+
+		<dependency org="xpp3" name="xpp3" rev="1.1.4c"
+								conf="compile->default(*)"/>
+
+		<dependency org="org.testng" name="testng" rev="6.8.8"
+								conf="test->default(*),master(*)"/>
+
+	</dependencies>
+</ivy-module>
