On 2012-01-31 00:46, Richard Hansen wrote:
> On 2012-01-30 19:13, Steve Ratcliffe wrote:
>> I'd also like to remove the build-support directory, and just move the
>> scripts to the top level and combine them into one or even add them to
>> the build.xml. The ivy jar file can go under lib/build or something.
> 
> I agree; I'll make a patch.

Attached is a series of patches that moves the contents of
build-support/scripts/*.xml into build.xml, derives the project version
from the svn revision, and fixes some minor issues.

Thanks,
Richard
>From c1593adf02e3dad88a36c4e9584e97e3c37fbd10 Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Tue, 31 Jan 2012 00:44:24 -0500
Subject: [PATCH 1/8] use svn revision for project version

---
 build.xml |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/build.xml b/build.xml
index e3f7a47..2518abf 100644
--- a/build.xml
+++ b/build.xml
@@ -54,9 +54,27 @@
 	<property name="test.input.cache" value="/opt/data/testinput"/>
 
 	<!-- mkgmap's version number -->
-	<!-- todo: programmatically get the svn revision and put it in
-	     project.version -->
-	<property name="project.version" value="svn" />
+	<tstamp>
+		<format property="tstamp.iso8601" pattern="yyyy-MM-dd'T'HH:mm:ssZ" />
+	</tstamp>
+	<property name="project.version.default" value="${tstamp.iso8601}" />
+	<exec executable="svnversion" dir="${top}" logError="true"
+	      outputproperty="svn.version" 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="project.version" value="${svn.version}">
+		<and>
+			<isset property="svn.version" />
+			<equals arg1="${svnversion.result}" arg2="0" />
+			<not><equals arg1="${svn.version}" arg2="" /></not>
+		</and>
+	</condition>
+	<property name="project.version" value="${project.version.default}" />
 
 	<!-- ivy dependency support -->
 	<property name="build-support.dir" location="build-support"/>
-- 
1.7.8.3

>From a23e492ae566ece14336d6108d2aa37130999cf8 Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 14:39:19 -0500
Subject: [PATCH 2/8] rename *.classpath to ivy.classpath.*

This should make it easier for the reader to understand that the
contents of these properties are the dependencies downloaded by ivy.
---
 build.xml |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/build.xml b/build.xml
index 2518abf..600338f 100644
--- a/build.xml
+++ b/build.xml
@@ -84,25 +84,25 @@
 	<import file="${build-support.dir}/script/build-ivy.xml"/>
 
 	<!-- For class paths -->
-	<path id="compile.classpath">
+	<path id="ivy.classpath.compile">
 		<fileset dir="${ivy.lib.dir}/compile" />
 	</path>
-	<path id="test.classpath">
+	<path id="ivy.classpath.test">
 		<fileset dir="${ivy.lib.dir}/test" />
 	</path>
-	<path id="macker.classpath">
+	<path id="ivy.classpath.macker">
 		<fileset dir="${ivy.lib.dir}/macker" />
 	</path>
 
 	<path id="main">
 		<pathelement location="${build.classes}" />
-		<path refid="compile.classpath" />
+		<path refid="ivy.classpath.compile" />
 	</path>
 
 	<path id="test">
 		<pathelement location="test/resources"/>
 		<pathelement location="build/test"/>
-		<path refid="test.classpath" />
+		<path refid="ivy.classpath.test" />
 		<pathelement location="${build.classes}" />
 		<pathelement location="test"/>
 	</path>
@@ -213,7 +213,7 @@
 		<mkdir dir="${dist}/doc/api"/>
 
 		<copy todir="${dist}/lib" >
-			<path refid="compile.classpath" />
+			<path refid="ivy.classpath.compile" />
 		</copy>
 
 		<manifestclasspath property="manifest_cp" jarfile="${dist}/mkgmap.jar">
@@ -283,7 +283,7 @@
 	<target name="macker" depends="build, resolve-macker">
 		<taskdef name="macker"
 						 classname="net.innig.macker.ant.MackerAntTask"
-						 classpathref="macker.classpath"/>
+						 classpathref="ivy.classpath.macker"/>
 
 		<property name="macker.report.xml" value="macker.out.xml"/>
 		<property name="macker.report.html" value="macker.out.html"/>
@@ -297,7 +297,7 @@
 
 		<taskdef name="macker-report"
 			classname="net.innig.macker.ant.MackerReportAntTask"
-			classpathref="macker.classpath"/>
+			classpathref="ivy.classpath.macker"/>
 		<macker-report xmlReportfile="${macker.report.xml}" outputFile="${macker.report.html}" />
 	</target>
 
-- 
1.7.8.3

>From ba4d4d693e7b7a47566599f358d9623d8dc5df79 Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 14:22:01 -0500
Subject: [PATCH 3/8] make sure all dependency libs are copied to dist

Unless all of the jars in ivy.classpath.compile are in the same
directory, the copy task will not copy all of them unless
flatten="true".
---
 build.xml |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build.xml b/build.xml
index 600338f..75f76e6 100644
--- a/build.xml
+++ b/build.xml
@@ -212,7 +212,7 @@
 		<mkdir dir="${dist}/lib"/>
 		<mkdir dir="${dist}/doc/api"/>
 
-		<copy todir="${dist}/lib" >
+		<copy todir="${dist}/lib" flatten="true">
 			<path refid="ivy.classpath.compile" />
 		</copy>
 
-- 
1.7.8.3

>From a3c03d1ce10a5e340d25c6044881b856905fcffc Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 14:32:59 -0500
Subject: [PATCH 4/8] make resolve-compile a dependency of compile, not
 prepare

---
 build.xml |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/build.xml b/build.xml
index 75f76e6..16b9109 100644
--- a/build.xml
+++ b/build.xml
@@ -108,7 +108,7 @@
 	</path>
 
 	<!-- Prepare - make all the directories -->
-	<target name="prepare" depends="resolve-compile">
+	<target name="prepare">
 		<mkdir dir="${build.classes}" />
 		<propertyfile file="${build.classes}/version.properties">
 			<entry key="svn.version" value="${project.version}" />
@@ -116,7 +116,7 @@
 	</target>
 
 	<!-- Compile the product itself (no tests). -->
-	<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="true">
 			<include name="**/*.java" />
-- 
1.7.8.3

>From 09180ce22f2686c929369a3b2fc654991344031c Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 14:18:04 -0500
Subject: [PATCH 5/8] move stuff in build-support into build.xml

---
 build-support/script/build-ivy-base.xml |   65 -------------------------------
 build-support/script/build-ivy.xml      |   29 --------------
 build.xml                               |   57 +++++++++++++++++++++++++--
 3 files changed, 53 insertions(+), 98 deletions(-)
 delete mode 100644 build-support/script/build-ivy-base.xml
 delete mode 100644 build-support/script/build-ivy.xml

diff --git a/build-support/script/build-ivy-base.xml b/build-support/script/build-ivy-base.xml
deleted file mode 100644
index 6812e81..0000000
--- a/build-support/script/build-ivy-base.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<project name="mkgmap.Build.Ivy.Base" default="init-ivy" basedir="."
-	xmlns:ivy="antlib:org.apache.ivy.ant">
-
-	<description>
-		Installs and configures the ivy build dependencies system.
-	</description>
-
-	<!-- Include common build components. -->
-	<property name="build-support.dir" location="../"/>
-
-	<target name="ivy-availability" description="Checks if the ivy library is available">
-		<property name="ivy.version" value="${dependency.version.ivy}" />
-		<property name="ivy.jar.dir" value="${build-support.dir}/ivy" />
-		<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-${ivy.version}.jar" />
-
-		<!-- Determine if the ivy jar is already available. -->
-		<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 any existing ivy files -->
-		<delete dir="${ivy.jar.dir}"/>
-
-		<mkdir dir="${ivy.jar.dir}" />
-
-		<!--
-			Download Ivy from web site so that it can be used even without any
-			special installation
-		-->
-		<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">
-		<!--
-			Try to load ivy in case the user has not already
-			dropped it into ant's lib dir (note that the latter copy will always
-			take precedence). We will not fail as long as local lib dir exists
-			(it may be empty) and ivy is in at least one of ant's lib dir or the
-			local lib dir.
-		-->
-		<path id="ivy.lib.path">
-			<fileset dir="${ivy.jar.dir}" includes="*.jar" />
-		</path>
-		<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant"
-			classpathref="ivy.lib.path" />
-
-		<ivy:configure />
-
-		<!-- Retrieve ivy details from the config file. -->
-		<ivy:info />
-
-		<property name="ivy.initialized" value="true"/>
-	</target>
-
-	<target name="clean-cache" depends="init-ivy" description="Clean the ivy cache.">
-		<ivy:cleancache />
-	</target>
-
-	<target name="clean-ivy" description="Clean the ivy installation.">
-		<delete dir="${ivy.jar.dir}"/>
-	</target>
-</project>
diff --git a/build-support/script/build-ivy.xml b/build-support/script/build-ivy.xml
deleted file mode 100644
index 4956cb3..0000000
--- a/build-support/script/build-ivy.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<project name="mkgmap.Build.Ivy" default="init-ivy" basedir="."
-	xmlns:ivy="antlib:org.apache.ivy.ant">
-
-	<description>Ivy-specific tasks</description>
-
-	<!-- Include common build components. -->
-	<property name="build-support.dir" location="../"/>
-	<import file="${build-support.dir}/script/build-ivy-base.xml"/>
-	<property name="ivy.retrieve.pattern" value="${ivy.lib.dir}/[conf]/[artifact]-[revision].[ext]" />
-
-	<target name="resolve-compile" depends="init-ivy" description="Downloads compile dependencies using ivy.">
-		<ivy:retrieve conf="compile" />
-	</target>
-	<target name="resolve-test" depends="init-ivy" description="Downloads test program dependencies using ivy.">
-		<ivy:retrieve conf="test" />
-	</target>
-	<target name="resolve-macker" depends="init-ivy" description="Downloads macker program dependencies using ivy.">
-		<ivy:retrieve conf="macker" />
-	</target>
-	<target name="resolve" depends="resolve-compile, resolve-test, resolve-macker" description="Downloads all program dependencies using ivy." />
-
-	<property name="ivy.distrib.dir" value="${ivy.project.dir}/dist" />
-	<property name="ivy.publish.src.artifacts.pattern" value="${ivy.distrib.dir}/[artifact].[ext]" />
-	<target name="publish" depends="dist">
-		<ivy:deliver pubrevision="${project.version}"/>
-		<ivy:publish resolver="local" pubrevision="${project.version}" overwrite="true"/>
-	</target>
-</project>
diff --git a/build.xml b/build.xml
index 16b9109..113dfa4 100644
--- a/build.xml
+++ b/build.xml
@@ -77,11 +77,11 @@
 	<property name="project.version" value="${project.version.default}" />
 
 	<!-- ivy dependency support -->
-	<property name="build-support.dir" location="build-support"/>
-	<property name="dependency.version.ivy" value="2.2.0"/>
+	<property name="ivy.version" value="2.2.0"/>
 	<property name="ivy.lib.dir" value="${basedir}/lib" />
-	<import file="${build-support.dir}/script/build-ivy-base.xml"/>
-	<import file="${build-support.dir}/script/build-ivy.xml"/>
+	<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.publish.src.artifacts.pattern" value="${dist}/[artifact].[ext]" />
 
 	<!-- For class paths -->
 	<path id="ivy.classpath.compile">
@@ -107,6 +107,55 @@
 		<pathelement location="test"/>
 	</path>
 
+	<!-- ******************** TARGETS ******************** -->
+
+	<!-- 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}" />
+		<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>
+		<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>
+	<target name="clean-cache" depends="init-ivy" description="Clean the ivy cache.">
+		<ivy:cleancache />
+	</target>
+	<target name="clean-ivy" description="Clean the ivy installation.">
+		<delete dir="${ivy.jar.dir}"/>
+	</target>
+
+	<!-- targets for fetching dependencies via ivy -->
+	<target name="resolve-compile" depends="init-ivy" description="Downloads compile dependencies using ivy.">
+		<ivy:retrieve conf="compile" />
+	</target>
+	<target name="resolve-test" depends="init-ivy" description="Downloads test program dependencies using ivy.">
+		<ivy:retrieve conf="test" />
+	</target>
+	<target name="resolve-macker" depends="init-ivy" description="Downloads macker program dependencies using ivy.">
+		<ivy:retrieve conf="macker" />
+	</target>
+	<target name="resolve" depends="resolve-compile, resolve-test, resolve-macker" description="Downloads all program dependencies using ivy." />
+
+	<!-- targets for publishing mkgmap (locally) via ivy -->
+	<target name="publish" depends="dist">
+		<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}" />
-- 
1.7.8.3

>From 2b8921841703c9abcf1b1c02324ad2cbabb77dbc Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 15:33:16 -0500
Subject: [PATCH 6/8] remove dead code

---
 build.xml |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/build.xml b/build.xml
index 113dfa4..07de710 100644
--- a/build.xml
+++ b/build.xml
@@ -301,10 +301,6 @@
 				<include name="README"/>
 				<include name="LICENCE*"/>
 			</fileset>
-			<files>
-				<include name="${protobuf.jar}"/>
-				<include name="${osmprotobuf.jar}"/>
-			</files>
 		</copy>
 
 		<mkdir dir="${dist}/examples"/>
-- 
1.7.8.3

>From 95a40df86d49f86ddcca2d6bd136dd10c11e1135 Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 15:36:27 -0500
Subject: [PATCH 7/8] define project.name and project.jar properties

This will make it easier to copy the code to splitter's build system.
---
 build.xml |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/build.xml b/build.xml
index 07de710..5dec5fc 100644
--- a/build.xml
+++ b/build.xml
@@ -20,6 +20,8 @@
 <project name="mkgmap" default="dist" basedir="."
 	 xmlns:ivy="antlib:org.apache.ivy.ant">
 
+	<property name="project.name" value="${ant.project.name}"/>
+
 	<!-- Init -->
 	<property name="top" value="."/>
 
@@ -45,6 +47,8 @@
 	<property name="javadoc" value="${doc}/api"/>
 	<property name="resources" value="resources"/>
 
+	<property name="project.jar" value="${dist}/${project.name}.jar"/>
+
 	<!-- A place to keep a local copy of the test input data.  The test files
 	 are large and so are not kept in svn.	If you don't set this then they
 	 will be downloaded.
@@ -53,7 +57,7 @@
 	 -->
 	<property name="test.input.cache" value="/opt/data/testinput"/>
 
-	<!-- mkgmap's version number -->
+	<!-- the project's version number -->
 	<tstamp>
 		<format property="tstamp.iso8601" pattern="yyyy-MM-dd'T'HH:mm:ssZ" />
 	</tstamp>
@@ -150,7 +154,7 @@
 	</target>
 	<target name="resolve" depends="resolve-compile, resolve-test, resolve-macker" description="Downloads all program dependencies using ivy." />
 
-	<!-- targets for publishing mkgmap (locally) via ivy -->
+	<!-- targets for publishing the project (locally) via ivy -->
 	<target name="publish" depends="dist">
 		<ivy:deliver pubrevision="${project.version}"/>
 		<ivy:publish resolver="local" pubrevision="${project.version}" overwrite="true"/>
@@ -265,7 +269,7 @@
 			<path refid="ivy.classpath.compile" />
 		</copy>
 
-		<manifestclasspath property="manifest_cp" jarfile="${dist}/mkgmap.jar">
+		<manifestclasspath property="manifest_cp" jarfile="${project.jar}">
 			<classpath>
 				<fileset dir="${dist}/lib">
 					<include name="**/*.jar" />
@@ -274,7 +278,7 @@
 		</manifestclasspath>
 
 		<!-- Make the jar -->
-		<jar basedir="${build.classes}" jarfile="${dist}/mkgmap.jar">
+		<jar basedir="${build.classes}" jarfile="${project.jar}">
 			<manifest>
 				<attribute name="Main-Class" value="uk.me.parabola.mkgmap.main.Main" />
 				<attribute name="Class-Path" value="${manifest_cp}" />
-- 
1.7.8.3

>From 1ec087ddb2a87df7639ee23f7eca14e8e1f089ec Mon Sep 17 00:00:00 2001
From: Richard Hansen <[email protected]>
Date: Sat, 4 Feb 2012 15:36:59 -0500
Subject: [PATCH 8/8] fix the publish target

Before, the publish target caused ivy:deliver to create dist/ivy.xml.
If the publish target was run again, the second run of ivy:deliver
would fail to create dist/ivy.xml if the project version had changed
since the previous run.

Now the publish target creates ivy-distrib/ivys/ivy-<version>.xml and
ivy-distrib/jars/mkgmap-<version>.jar for publication via ivy:publish.
---
 build.xml |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/build.xml b/build.xml
index 5dec5fc..66b0a4a 100644
--- a/build.xml
+++ b/build.xml
@@ -85,7 +85,7 @@
 	<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.publish.src.artifacts.pattern" value="${dist}/[artifact].[ext]" />
+	<property name="ivy.distrib.dir" value="ivy-distrib" />
 
 	<!-- For class paths -->
 	<path id="ivy.classpath.compile">
@@ -156,6 +156,8 @@
 
 	<!-- 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>
-- 
1.7.8.3

_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to