source: josm/trunk/build.xml@ 6168

Last change on this file since 6168 was 6144, checked in by Don-vip, 11 years ago

see #8954 - new tagging preset reader regression test (patch by AlfonZ)

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