File: build.xml

package info (click to toggle)
mkgmap-splitter 0.0.0+svn592-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,276 kB
  • sloc: java: 13,186; xml: 1,674; sh: 35; makefile: 17
file content (391 lines) | stat: -rw-r--r-- 13,403 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<?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="." xmlns:ivy="antlib:org.apache.ivy.ant">

  <!-- Init -->
  <property name="top" value="."/>

	<property name="project.name" value="${ant.project.name}"/>

        <property name="deblib" value="/usr/share/java"/>

  <!--
    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"/>

	<property name="project.jar" value="${dist}/${project.name}.jar"/>

  <!-- Third party libraries -->
	<property name="xpp.jar" location="${deblib}/xpp3.jar"/>

	<!-- the project's build timestamp -->
	<tstamp>
		<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" />

	<!-- 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.

	 You can set it in the external.properties file too.
	 -->
	<property name="test.input.cache" value="/opt/data/testinput"/> 
 
  <!-- Classpaths -->
  <path id="classpath">
    <pathelement location="${build.classes}"/>
    <fileset dir="${deblib}/">
      <include name="fastutil.jar"/>
      <include name="protobuf.jar"/>
      <include name="osmpbf.jar"/>
      <include name="xpp3.jar"/>
    </fileset>
  </path>

  <path id="test.classpath">
    <path refid="classpath"/>
    <pathelement location="${build.test-classes}"/>
    <fileset dir="${deblib}/">
      <include name="testng.jar"/>
      <include name="bsh.jar"/>
      <include name="jcommander.jar"/>
      <include name="junit4.jar"/>
    </fileset>
  </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}"/>
    <mkdir dir="${build.test-classes}"/>
    <mkdir dir="${build.test-output}"/>
    <mkdir dir="${resources}"/>
		<property environment="env"/>

		<condition property="have.svn">
			<and>
				<available file="${top}/.svn"/>
				<or>
					<available file="svnversion" filepath="${env.PATH}"/>
					<available file="svnversion.exe" filepath="${env.PATH}"/>
					<available file="svnversion.exe" filepath="${env.Path}"/>
				</or>
			</and>
		</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" description="Run the junit tests">
		<mkdir dir="tmp/report"/>
		<junit printsummary="yes" failureproperty="junit.failure" forkmode="once">
	
			<classpath refid="test.classpath"/>
			<formatter type="xml"/>
			
			<assertions>
				<enable/>
			</assertions>
	
			<batchtest fork="yes" todir="tmp/report">
				<fileset dir="test">
					<include name="**/*Test.java"/>
	
					<!-- These are standalone tests, not  unit tests. -->
					<exclude name="func/**"/>
				</fileset>
			</batchtest>
		</junit>
		<junitreport todir="tmp">
	    <fileset dir="tmp/report"/>
	    <report todir="test-reports"/>
	  </junitreport>
	  <fail if="junit.failure" message="Test failed.  See test-reports/index.html"/>
	</target>

  <target name="dist" depends="build, check-version, version-file" description="Make the distribution area">

    <mkdir dir="${dist}"/>
    <mkdir dir="${dist}/doc/api"/>

    <copy todir="${dist}/doc">
      <fileset dir="doc" includes="*.txt"/>
    </copy>

    <copy todir="${dist}/lib">
      <path refid="classpath" />
    </copy>

    <!-- misc -->
    <copy todir="${dist}">
      <fileset dir="${basedir}">
        <include name="README"/>
        <include name="LICENCE*"/>
      </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 -->
  <target name="clean">
    <delete dir="${build}"/>
  </target>

  <!-- Clobber all generated and built files -->
  <target name="clobber" depends="clean">
    <delete dir="${dist}"/>
		<delete dir="${ivy.lib.dir}"/>
  </target>

	<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">
    <copy todir="${build.classes}">
      <fileset dir="${resources}">
        <include name="*.properties"/>
      </fileset>
    </copy>
  </target>

  <target name="rebuild" depends="clean, build"/>
  
	<target name="obtain-test-input-files" description="download the input files for the functional tests">
		<!-- Local cache, if it doesn't exist then it is not a problem the files
		will be downloaded in the next step -->
		<copy todir="test/resources/in/" failonerror="false"> 
			<fileset dir="${test.input.cache}" includes="osm/*.osm.pbf" />
		</copy>
		<mkdir dir="test/resources/in/osm"/>
		<get src="http://www.mkgmap.org.uk/testinput/osm/alaska-2016-12-27.osm.pbf"
			dest="test/resources/in/osm/alaska-2016-12-27.osm.pbf" usetimestamp="true"
			ignoreerrors="true"/>
		<get src="http://www.mkgmap.org.uk/testinput/osm/hamburg-2016-12-26.osm.pbf"
			dest="test/resources/in/osm/hamburg-2016-12-26.osm.pbf" usetimestamp="true"
			ignoreerrors="true"/>
	</target>
 
	<target name="run.func-tests" depends="compile,compile.tests,obtain-test-input-files" description="Run the functional tests">
		<mkdir dir="tmp/report"/>
		<junit printsummary="yes" failureproperty="junit.failure" forkmode="once">
	
			<classpath refid="test.classpath"/>
			<formatter type="xml"/>
			
			<assertions>
				<enable/>
			</assertions>
	
			<batchtest fork="yes" todir="tmp/report">
				<fileset dir="test">
					<include name="func/**/*Test.java"/>
	
					<!-- These are standalone tests, not  unit tests. -->
					<exclude name="main/**"/>
				</fileset>
			</batchtest>
		</junit>
		<junitreport todir="tmp">
	    <fileset dir="tmp/report"/>
	    <report todir="test-reports"/>
	  </junitreport>
	  <fail if="junit.failure" message="Test failed.  See test-reports/index.html"/>
	</target>
</project>