1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
2 | <!-- ** build.xml - main ant file for JOSM
|
---|
3 | **
|
---|
4 | ** To build run
|
---|
5 | ** ant clean
|
---|
6 | ** ant dist
|
---|
7 | ** This will create 'josm-custom.jar' in directory 'dist'. See also
|
---|
8 | ** https://josm.openstreetmap.de/wiki/CreateBuild
|
---|
9 | **
|
---|
10 | -->
|
---|
11 | <project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
|
---|
12 | <property name="test.dir" location="test"/>
|
---|
13 | <property name="src.dir" location="src"/>
|
---|
14 | <property name="build.dir" location="build"/>
|
---|
15 | <property name="javacc.home" location="tools"/>
|
---|
16 | <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
|
---|
17 | <!-- build parameter: compression level (ant -Dclevel=N)
|
---|
18 | N ranges from 0 (no compression) to 9 (maximum compression)
|
---|
19 | default: 9 -->
|
---|
20 | <condition property="clevel" value="${clevel}" else="9">
|
---|
21 | <isset property="clevel"/>
|
---|
22 | </condition>
|
---|
23 | <!-- Java classpath addition (all jar files to compile tests with this) -->
|
---|
24 | <path id="classpath">
|
---|
25 | <fileset dir="lib">
|
---|
26 | <include name="**/*.jar"/>
|
---|
27 | </fileset>
|
---|
28 | </path>
|
---|
29 |
|
---|
30 | <!--
|
---|
31 | ** Used by Eclipse ant builder for updating
|
---|
32 | ** the REVISION file used by JOSM
|
---|
33 | -->
|
---|
34 | <target name="create-revision-eclipse">
|
---|
35 | <property name="revision.dir" value="bin"/>
|
---|
36 | <antcall target="create-revision"/>
|
---|
37 | </target>
|
---|
38 | <!--
|
---|
39 | ** Creates the REVISION file to be included in the distribution
|
---|
40 | -->
|
---|
41 | <target name="create-revision">
|
---|
42 | <property name="revision.dir" value="${build.dir}"/>
|
---|
43 | <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false">
|
---|
44 | <env key="LANG" value="C"/>
|
---|
45 | <arg value="info"/>
|
---|
46 | <arg value="--xml"/>
|
---|
47 | <arg value="."/>
|
---|
48 | </exec>
|
---|
49 | <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
|
---|
50 | <delete file="REVISION.XML"/>
|
---|
51 | <tstamp>
|
---|
52 | <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
|
---|
53 | </tstamp>
|
---|
54 | <property name="version.entry.commit.revision" value="UNKNOWN"/>
|
---|
55 | <mkdir dir="${revision.dir}"/>
|
---|
56 | <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
|
---|
57 | <echo file="${revision.dir}/REVISION">
|
---|
58 | # automatically generated by JOSM build.xml - do not edit
|
---|
59 | Revision: ${version.entry.commit.revision}
|
---|
60 | Is-Local-Build: true
|
---|
61 | Build-Date: ${build.tstamp}
|
---|
62 | </echo>
|
---|
63 | </target>
|
---|
64 | <target name="check-schemas">
|
---|
65 | <schemavalidate file="data/defaultpresets.xml" >
|
---|
66 | <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
|
---|
67 | </schemavalidate>
|
---|
68 | <schemavalidate file="styles/standard/elemstyles.xml" >
|
---|
69 | <schema namespace="http://josm.openstreetmap.de/mappaint-style-1.0" file="data/mappaint-style.xsd" />
|
---|
70 | </schemavalidate>
|
---|
71 | </target>
|
---|
72 | <target name="dist" depends="compile,create-revision,check-schemas">
|
---|
73 | <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
|
---|
74 | <env key="LANG" value="C"/>
|
---|
75 | <arg value="info"/>
|
---|
76 | <arg value="--xml"/>
|
---|
77 | <arg value="."/>
|
---|
78 | </exec>
|
---|
79 | <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
|
---|
80 | <delete file="REVISION"/>
|
---|
81 | <property name="version.entry.commit.revision" value="UNKNOWN"/>
|
---|
82 | <property name="version.entry.commit.date" value="UNKNOWN"/>
|
---|
83 | <echo>Revision ${version.entry.commit.revision}</echo>
|
---|
84 | <copy file="CONTRIBUTION" todir="build"/>
|
---|
85 | <copy file="README" todir="build"/>
|
---|
86 | <copy file="LICENSE" todir="build"/>
|
---|
87 | <!-- create josm-custom.jar -->
|
---|
88 | <delete file="dist/josm-custom.jar"/>
|
---|
89 | <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
|
---|
90 | <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
|
---|
91 | <manifest>
|
---|
92 | <attribute name="Main-class" value="JOSM"/>
|
---|
93 | <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
|
---|
94 | <attribute name="Main-Date" value="${version.entry.commit.date}"/>
|
---|
95 | </manifest>
|
---|
96 | <zipfileset dir="images" prefix="images"/>
|
---|
97 | <zipfileset dir="data" prefix="data"/>
|
---|
98 | <zipfileset dir="styles" prefix="styles"/>
|
---|
99 | <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
|
---|
100 | <!-- All jar files necessary to run only JOSM (no tests) -->
|
---|
101 | <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
|
---|
102 | <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
|
---|
103 | </jar>
|
---|
104 | </target>
|
---|
105 | <target name="distmac" depends="dist">
|
---|
106 | <!-- modify MacOS X Info.plist file to hold the SVN version number -->
|
---|
107 | <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/>
|
---|
108 | <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/>
|
---|
109 | <!-- create ZIP file with MacOS X application bundle -->
|
---|
110 | <zip destfile="dist/josm-custom-macosx.zip" update="true">
|
---|
111 | <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
|
---|
112 | <zipfileset dir="macosx" includes="JOSM.app/Contents JOSM.app/Contents/MacOS JOSM.app/Contents/Resources JOSM.app/Contents/Resources/Java JOSM.app/Contents/PkgInfo JOSM.app/Contents/Resources/JOSM.icns"/>
|
---|
113 | <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/>
|
---|
114 | <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/>
|
---|
115 | <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/>
|
---|
116 | </zip>
|
---|
117 | </target>
|
---|
118 | <target name="javacc" depends="init" unless="javacc.notRequired">
|
---|
119 | <mkdir dir="${mapcss.dir}/parsergen"/>
|
---|
120 | <exec append="false" executable="java" failifexecutionfails="true">
|
---|
121 | <arg value="-cp"/>
|
---|
122 | <arg value="${javacc.home}/javacc.jar"/>
|
---|
123 | <arg value="javacc"/>
|
---|
124 | <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
|
---|
125 | <arg value="${mapcss.dir}/MapCSSParser.jj"/>
|
---|
126 | </exec>
|
---|
127 | <!-- <javacc target="${mapcss.dir}/MapCSSParser.jj" javacchome="${javacc.home}" outputdirectory="${mapcss.dir}/parsergen"/>-->
|
---|
128 | </target>
|
---|
129 | <target name="compile" depends="init,javacc">
|
---|
130 | <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="iso-8859-1"/>
|
---|
131 | <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="UTF-8">
|
---|
132 | <compilerarg value="-Xlint:deprecation"/>
|
---|
133 | <compilerarg value="-Xlint:unchecked"/>
|
---|
134 | </javac>
|
---|
135 | </target>
|
---|
136 | <target name="init">
|
---|
137 | <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
|
---|
138 | <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
|
---|
139 | </uptodate>
|
---|
140 | <mkdir dir="build"/>
|
---|
141 | <mkdir dir="dist"/>
|
---|
142 | </target>
|
---|
143 | <target name="javadoc">
|
---|
144 | <javadoc destdir="javadoc"
|
---|
145 | sourcepath="src"
|
---|
146 | packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
|
---|
147 | windowtitle="JOSM"
|
---|
148 | use="true"
|
---|
149 | private="true"
|
---|
150 | linksource="true"
|
---|
151 | author="false">
|
---|
152 | <link href="http://docs.oracle.com/javase/6/docs/api"/>
|
---|
153 | <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
|
---|
154 | <bottom><![CDATA[<a href="http://josm.openstreetmap.de/">JOSM</a>]]></bottom>
|
---|
155 | </javadoc>
|
---|
156 | </target>
|
---|
157 | <target name="clean">
|
---|
158 | <delete dir="build"/>
|
---|
159 | <delete dir="dist"/>
|
---|
160 | <delete dir="${mapcss.dir}/parsergen"/>
|
---|
161 | </target>
|
---|
162 | <path id="test.classpath">
|
---|
163 | <fileset dir="${test.dir}/lib">
|
---|
164 | <include name="**/*.jar"/>
|
---|
165 | </fileset>
|
---|
166 | <fileset dir="lib">
|
---|
167 | <include name="**/*.jar"/>
|
---|
168 | </fileset>
|
---|
169 | <pathelement path="dist/josm-custom.jar"/>
|
---|
170 | </path>
|
---|
171 | <target name="test-init">
|
---|
172 | <mkdir dir="${test.dir}/build"/>
|
---|
173 | <mkdir dir="${test.dir}/report"/>
|
---|
174 | </target>
|
---|
175 | <target name="test-clean">
|
---|
176 | <delete dir="${test.dir}/build"/>
|
---|
177 | <delete dir="${test.dir}/report"/>
|
---|
178 | <delete file="${test.dir}/jacoco.exec" />
|
---|
179 | </target>
|
---|
180 | <target name="test-compile" depends="test-init,dist">
|
---|
181 | <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="UTF-8">
|
---|
182 | <compilerarg value="-Xlint:deprecation"/>
|
---|
183 | <compilerarg value="-Xlint:unchecked"/>
|
---|
184 | </javac>
|
---|
185 | <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="UTF-8">
|
---|
186 | <compilerarg value="-Xlint:deprecation"/>
|
---|
187 | <compilerarg value="-Xlint:unchecked"/>
|
---|
188 | </javac>
|
---|
189 | </target>
|
---|
190 | <target name="test" depends="test-compile">
|
---|
191 | <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
|
---|
192 | <jacoco:coverage destfile="${test.dir}/jacoco.exec">
|
---|
193 | <junit printsummary="yes" fork="true" forkmode="once">
|
---|
194 | <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
|
---|
195 | <sysproperty key="josm.test.data" value="${test.dir}/data"/>
|
---|
196 | <sysproperty key="java.awt.headless" value="true"/>
|
---|
197 | <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
|
---|
198 | <classpath>
|
---|
199 | <path refid="test.classpath"/>
|
---|
200 | <pathelement path="${test.dir}/build"/>
|
---|
201 | <pathelement path="${test.dir}/config"/>
|
---|
202 | </classpath>
|
---|
203 | <formatter type="plain"/>
|
---|
204 | <formatter type="xml"/>
|
---|
205 | <batchtest fork="yes" todir="${test.dir}/report">
|
---|
206 | <fileset dir="${test.dir}/unit" includes="**/*.java"/>
|
---|
207 | </batchtest>
|
---|
208 | </junit>
|
---|
209 | </jacoco:coverage>
|
---|
210 | </target>
|
---|
211 | <target name="test-html" depends="test" description="Generate HTML test reports">
|
---|
212 | <!-- May require additional ant dependencies like ant-trax package -->
|
---|
213 | <junitreport todir="${test.dir}/report">
|
---|
214 | <fileset dir="${test.dir}/report">
|
---|
215 | <include name="TEST-*.xml"/>
|
---|
216 | </fileset>
|
---|
217 | <report todir="${test.dir}/report/html"/>
|
---|
218 | </junitreport>
|
---|
219 | <jacoco:report>
|
---|
220 | <executiondata>
|
---|
221 | <file file="${test.dir}/jacoco.exec"/>
|
---|
222 | </executiondata>
|
---|
223 | <structure name="JOSM Test Coverage">
|
---|
224 | <classfiles>
|
---|
225 | <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
|
---|
226 | </classfiles>
|
---|
227 | <sourcefiles encoding="UTF-8">
|
---|
228 | <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
|
---|
229 | </sourcefiles>
|
---|
230 | </structure>
|
---|
231 | <html destdir="${test.dir}/report/jacoco"/>
|
---|
232 | </jacoco:report>
|
---|
233 | </target>
|
---|
234 | <target name="dist-optimized" depends="dist">
|
---|
235 | <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
|
---|
236 | <proguard>
|
---|
237 | -injars dist/josm-custom.jar
|
---|
238 | -outjars dist/josm-custom-optimized.jar
|
---|
239 |
|
---|
240 | -libraryjars ${java.home}/lib/rt.jar
|
---|
241 | -libraryjars ${java.home}/lib/jce.jar
|
---|
242 |
|
---|
243 | -dontoptimize
|
---|
244 | -dontobfuscate
|
---|
245 |
|
---|
246 | # These options probably are not necessary (and make processing a bit slower)
|
---|
247 | -dontskipnonpubliclibraryclasses
|
---|
248 | -dontskipnonpubliclibraryclassmembers
|
---|
249 |
|
---|
250 | -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
|
---|
251 | public static void main(java.lang.String[]);
|
---|
252 | }
|
---|
253 | -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
|
---|
254 |
|
---|
255 | -keep class JOSM
|
---|
256 | -keep class * extends org.openstreetmap.josm.io.FileImporter
|
---|
257 | -keep class * extends org.openstreetmap.josm.io.FileExporter
|
---|
258 | -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
|
---|
259 | -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
|
---|
260 |
|
---|
261 | -keepclassmembers enum * {
|
---|
262 | public static **[] values();
|
---|
263 | public static ** valueOf(java.lang.String);
|
---|
264 | }
|
---|
265 |
|
---|
266 | # Keep unused public methods (can be useful for plugins)
|
---|
267 | -keepclassmembers class * {
|
---|
268 | public protected *;
|
---|
269 | }
|
---|
270 |
|
---|
271 | # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'. This notes should not be a problem as we don't use obfuscation
|
---|
272 | -dontnote
|
---|
273 | </proguard>
|
---|
274 | </target>
|
---|
275 | <target name="check-plugins" depends="dist-optimized">
|
---|
276 | <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
|
---|
277 | <local name="dir"/>
|
---|
278 | <local name="plugins"/>
|
---|
279 | <property name="dir" value="plugin-check"/>
|
---|
280 | <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
|
---|
281 | <classpath path="tools/animal-sniffer-ant-tasks-1.8.jar"/>
|
---|
282 | </typedef>
|
---|
283 | <mkdir dir="${dir}"/>
|
---|
284 | <!-- List of deprecated plugins -->
|
---|
285 | <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
|
---|
286 | <filterchain>
|
---|
287 | <linecontains>
|
---|
288 | <contains value="new DeprecatedPlugin("/>
|
---|
289 | </linecontains>
|
---|
290 | <tokenfilter>
|
---|
291 | <replaceregex pattern=".*new DeprecatedPlugin\("(.+?)".*" replace="\1|" flags="gi"/>
|
---|
292 | </tokenfilter>
|
---|
293 | <striplinebreaks/>
|
---|
294 | <tokenfilter>
|
---|
295 | <replaceregex pattern="\|$" replace="" flags="gi"/>
|
---|
296 | </tokenfilter>
|
---|
297 | </filterchain>
|
---|
298 | </loadfile>
|
---|
299 | <!-- Download list of plugins -->
|
---|
300 | <loadresource property="plugins">
|
---|
301 | <url url="http://josm.openstreetmap.de/plugin"/>
|
---|
302 | <filterchain>
|
---|
303 | <linecontainsregexp negate="true">
|
---|
304 | <regexp pattern="^\t.*"/>
|
---|
305 | </linecontainsregexp>
|
---|
306 | <linecontainsregexp negate="true">
|
---|
307 | <regexp pattern="${deprecated-plugins}"/>
|
---|
308 | </linecontainsregexp>
|
---|
309 | <tokenfilter>
|
---|
310 | <replaceregex pattern="^.*;" replace="" flags="gi"/>
|
---|
311 | </tokenfilter>
|
---|
312 | </filterchain>
|
---|
313 | </loadresource>
|
---|
314 | <!-- Delete files that are not in plugin list (like old plugins) -->
|
---|
315 | <loadresource property="file-list">
|
---|
316 | <propertyresource name="plugins"/>
|
---|
317 | <filterchain>
|
---|
318 | <tokenfilter>
|
---|
319 | <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
|
---|
320 | </tokenfilter>
|
---|
321 | <striplinebreaks/>
|
---|
322 | <tokenfilter>
|
---|
323 | <replaceregex pattern="\|$" replace="" flags="gi"/>
|
---|
324 | </tokenfilter>
|
---|
325 | </filterchain>
|
---|
326 | </loadresource>
|
---|
327 | <delete>
|
---|
328 | <restrict>
|
---|
329 | <fileset dir="${dir}"/>
|
---|
330 | <not>
|
---|
331 | <name regex="${file-list}"/>
|
---|
332 | </not>
|
---|
333 | </restrict>
|
---|
334 | </delete>
|
---|
335 | <!-- Download plugins -->
|
---|
336 | <copy todir="${dir}" flatten="true">
|
---|
337 | <resourcelist>
|
---|
338 | <string value="${plugins}"/>
|
---|
339 | </resourcelist>
|
---|
340 | </copy>
|
---|
341 | <!-- Check plugins -->
|
---|
342 | <as:build-signatures destfile="${dir}/api.sig">
|
---|
343 | <path>
|
---|
344 | <fileset file="dist/josm-custom-optimized.jar"/>
|
---|
345 | <fileset file="${java.home}/lib/rt.jar"/>
|
---|
346 | <fileset file="${java.home}/lib/jce.jar"/>
|
---|
347 | </path>
|
---|
348 | </as:build-signatures>
|
---|
349 | <as:check-signature signature="${dir}/api.sig">
|
---|
350 | <ignore classname="org.jgraph.*"/>
|
---|
351 | <ignore classname="com.touchgraph.*"/>
|
---|
352 | <ignore classname="com.sun.xml.fastinfoset.*"/>
|
---|
353 | <ignore classname="javax.jms.*"/>
|
---|
354 | <ignore classname="org.jvnet.staxex.*"/>
|
---|
355 | <ignore classname="javax.mail.*"/>
|
---|
356 | <ignore classname="com.sun.jdmk.*"/>
|
---|
357 | <ignore classname="org.apache.avalon.framework.logger.Logger"/>
|
---|
358 | <ignore classname="org.apache.log.*"/>
|
---|
359 | <ignore classname="junit.*"/>
|
---|
360 | <path path="${dir}"/>
|
---|
361 | </as:check-signature>
|
---|
362 | </target>
|
---|
363 |
|
---|
364 | <target name="findbugs" depends="dist">
|
---|
365 | <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
|
---|
366 | <path id="findbugs-classpath">
|
---|
367 | <fileset dir="tools/findbugs/">
|
---|
368 | <include name="*.jar"/>
|
---|
369 | </fileset>
|
---|
370 | </path>
|
---|
371 | <property name="findbugs-classpath" refid="findbugs-classpath"/>
|
---|
372 | <findbugs output="xml"
|
---|
373 | outputFile="findbugs-josm.xml"
|
---|
374 | classpath="${findbugs-classpath}"
|
---|
375 | pluginList=""
|
---|
376 | excludeFilter="tools/findbugs/josm-filter.xml"
|
---|
377 | effort="max"
|
---|
378 | >
|
---|
379 | <sourcePath path="${basedir}/src" />
|
---|
380 | <class location="${basedir}/dist/josm-custom.jar" />
|
---|
381 | </findbugs>
|
---|
382 | </target>
|
---|
383 | <target name="run" depends="dist">
|
---|
384 | <java jar="dist/josm-custom.jar" fork="true">
|
---|
385 | <arg value="--set=expert=true"/>
|
---|
386 | <arg value="--set=remotecontrol.enabled=true"/>
|
---|
387 | <arg value="--set=debug.edt-checker.enable=false"/>
|
---|
388 | <jvmarg value="-Djosm.home=/tmp/.josm/"/>
|
---|
389 | </java>
|
---|
390 | </target>
|
---|
391 |
|
---|
392 | </project>
|
---|