source: josm/trunk/build.xml@ 10614

Last change on this file since 10614 was 10614, checked in by Don-vip, 8 years ago

see #11390, see #12472 - Update to error-prone 2.0.11

  • Property svn:eol-style set to native
File size: 36.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/DevelopersGuide/CreateBuild
9**
10-->
11<project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" xmlns:jacoco="antlib:org.jacoco.ant" xmlns:if="ant:if">
12 <target name="init-properties">
13 <!-- Load properties in a target and not at top level, so this build file can be
14 imported from an IDE ant file (Netbeans) without messing up IDE properties.
15 When imported from another file, ${basedir} will point to the parent directory
16 of the importing ant file. Use ${base.dir} instead, which is always the parent
17 directory of this file. -->
18 <dirname property="base.dir" file="${ant.file.josm}"/>
19 <property name="test.dir" location="${base.dir}/test"/>
20 <property name="src.dir" location="${base.dir}/src"/>
21 <property name="build.dir" location="${base.dir}/build"/>
22 <property name="dist.dir" location="${base.dir}/dist"/>
23 <property name="javacc.home" location="${base.dir}/tools"/>
24 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
25 <property name="proj-build.dir" location="${base.dir}/build2"/>
26 <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/>
27 <property name="groovy.jar" location="${base.dir}/tools/groovy-all-2.4.7.jar"/>
28 <property name="error_prone_ant.jar" location="${base.dir}/tools/error_prone_ant-2.0.11.jar"/>
29 <!-- build parameter: compression level (ant -Dclevel=N)
30 N ranges from 0 (no compression) to 9 (maximum compression)
31 default: 9 -->
32 <condition property="clevel" value="${clevel}" else="9">
33 <isset property="clevel"/>
34 </condition>
35 <!-- For Java9-specific stuff -->
36 <condition property="isJava9">
37 <equals arg1="${ant.java.version}" arg2="1.9" />
38 </condition>
39 <path id="test.classpath">
40 <fileset dir="${test.dir}/lib">
41 <include name="**/*.jar"/>
42 </fileset>
43 <pathelement path="${dist.dir}/josm-custom.jar"/>
44 <pathelement path="${groovy.jar}"/>
45 <pathelement path="tools/findbugs/annotations.jar"/>
46 </path>
47 </target>
48
49 <!--
50 ** Used by Eclipse ant builder for updating
51 ** the REVISION file used by JOSM
52 -->
53 <target name="create-revision-eclipse">
54 <property name="revision.dir" value="bin"/>
55 <antcall target="create-revision"/>
56 </target>
57 <!--
58 ** Initializes the REVISION.XML file from SVN information
59 -->
60 <target name="init-svn-revision-xml" depends="init-properties">
61 <exec append="false" output="${base.dir}/REVISION.XML" executable="svn" dir="${base.dir}" failifexecutionfails="false" resultproperty="svn.info.result">
62 <env key="LANG" value="C"/>
63 <arg value="info"/>
64 <arg value="--xml"/>
65 <arg value="."/>
66 </exec>
67 <condition property="svn.info.success">
68 <equals arg1="${svn.info.result}" arg2="0" />
69 </condition>
70 </target>
71 <!--
72 ** Initializes the REVISION.XML file from git information
73 -->
74 <target name="init-git-revision-xml" unless="svn.info.success" depends="init-properties">
75 <exec append="false" output="${base.dir}/REVISION.XML" executable="git" dir="${base.dir}" failifexecutionfails="false">
76 <arg value="log"/>
77 <arg value="-1"/>
78 <arg value="--grep=git-svn-id"/>
79 <!--
80 %B: raw body (unwrapped subject and body)
81 %n: new line
82 %ai: author date, ISO 8601 format
83 -->
84 <arg value="--pretty=format:%B%n%ai"/>
85 <arg value="HEAD"/>
86 </exec>
87 <replaceregexp file="${base.dir}/REVISION.XML" flags="s"
88 match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
89 replace="&lt;info&gt;&lt;entry&gt;&lt;commit revision=&quot;\1&quot;&gt;&lt;date&gt;\2&lt;/date&gt;&lt;/commit&gt;&lt;/entry&gt;&lt;/info&gt;"/>
90 </target>
91 <!--
92 ** Creates the REVISION file to be included in the distribution
93 -->
94 <target name="create-revision" depends="init-properties,init-svn-revision-xml,init-git-revision-xml">
95 <property name="revision.dir" value="${build.dir}"/>
96 <xmlproperty file="${base.dir}/REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
97 <delete file="${base.dir}/REVISION.XML"/>
98 <tstamp>
99 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
100 </tstamp>
101 <property name="version.entry.commit.revision" value="UNKNOWN"/>
102 <property name="version.entry.commit.date" value="UNKNOWN"/>
103 <mkdir dir="${revision.dir}"/>
104 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
105 <echo file="${revision.dir}/REVISION">
106# automatically generated by JOSM build.xml - do not edit
107Revision: ${version.entry.commit.revision}
108Is-Local-Build: true
109Build-Date: ${build.tstamp}
110</echo>
111 </target>
112 <!--
113 ** Check internal XML files against their XSD
114 -->
115 <target name="check-schemas" unless="check-schemas.notRequired" depends="init-properties">
116 <schemavalidate file="data/defaultpresets.xml" >
117 <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
118 </schemavalidate>
119 </target>
120 <!--
121 ** Main target that builds JOSM and checks XML against schemas
122 -->
123 <target name="dist" depends="compile,create-revision,check-schemas,epsg">
124 <echo>Revision ${version.entry.commit.revision}</echo>
125 <copy file="CONTRIBUTION" todir="build"/>
126 <copy file="README" todir="build"/>
127 <copy file="LICENSE" todir="build"/>
128 <!-- create josm-custom.jar -->
129 <delete file="${dist.dir}/josm-custom.jar"/>
130 <jar destfile="${dist.dir}/josm-custom.jar" basedir="${build.dir}" level="${clevel}">
131 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
132 <manifest>
133 <attribute name="Main-class" value="JOSM"/>
134 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
135 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
136 <attribute name="Permissions" value="all-permissions"/>
137 <attribute name="Codebase" value="josm.openstreetmap.de"/>
138 <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
139 </manifest>
140 <zipfileset dir="images" prefix="images"/>
141 <zipfileset dir="data" prefix="data"/>
142 <zipfileset dir="styles" prefix="styles"/>
143 <zipfileset dir="${src.dir}/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
144 </jar>
145 </target>
146 <!-- Mac OS X target -->
147 <target name="mac" depends="init-properties">
148 <!-- Using https://bitbucket.org/infinitekind/appbundler to create mac application bundle -->
149 <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="tools/appbundler-1.0ea.jar"/>
150 <!-- create MacOS X application bundle -->
151 <bundleapp outputdirectory="${bundle.outdir}" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
152 mainclassname="org.openstreetmap.josm.gui.MainApplication"
153 copyright="JOSM, and all its integral parts, are released under the GNU General Public License v2 or later"
154 applicationCategory="public.app-category.utilities"
155 shortversion="${version.entry.commit.revision} SVN"
156 version="${version.entry.commit.revision} SVN"
157 icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
158 highResolutionCapable="true">
159
160 <arch name="x86_64"/>
161 <arch name="i386"/>
162
163 <classpath file="${bundle.jar}"/>
164
165 <option value="-Xmx1024m"/>
166
167 <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
168 <option value="-Xdock:name=JOSM"/>
169
170 <!-- OSX specific options, optional -->
171 <option value="-Dapple.laf.useScreenMenuBar=true"/>
172 <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
173 <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
174 <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
175 <option value="-Dcom.apple.smallTabs=true"/>
176 </bundleapp>
177
178 <!-- appbundler lacks the possibility of defining our own keys or using a template, so update the .plist manually -->
179 <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="tools/xmltask.jar"/>
180
181 <xmltask source="${bundle.outdir}/JOSM.app/Contents/Info.plist" dest="${bundle.outdir}/JOSM.app/Contents/Info.plist" indent="false">
182 <!-- remove empty CFBundleDocumentTypes definition -->
183 <remove path="/plist/dict/key[text()='CFBundleDocumentTypes']|/plist/dict/key[text()='CFBundleDocumentTypes']/following-sibling::array[1]"/>
184 <!-- insert our own keys -->
185 <insert position="before" path="/plist/dict/key[1]" file="macosx/JOSM.app/Contents/Info.plist_template.xml" />
186 </xmltask>
187
188 <!-- create ZIP file with MacOS X application bundle -->
189 <zip destfile="${bundle.outdir}/josm-custom-macosx.zip" update="true">
190 <zipfileset dir="." includes="CONTRIBUTION README LICENSE"/>
191 <zipfileset dir="${bundle.outdir}" includes="JOSM.app/**/*" filemode="755" />
192 </zip>
193 </target>
194 <target name="distmac" depends="dist">
195 <antcall target="mac">
196 <param name="bundle.outdir" value="${dist.dir}"/>
197 <param name="bundle.jar" value="${dist.dir}/josm-custom.jar"/>
198 </antcall>
199 </target>
200 <!-- Windows target -->
201 <target name="distwin" depends="dist">
202 <exec dir="windows" executable="./josm-setup-unix.sh">
203 <arg value="${version.entry.commit.revision}"/>
204 <arg value="../dist/josm-custom.jar"/>
205 </exec>
206 </target>
207 <target name="javacc" depends="init" unless="javacc.notRequired">
208 <mkdir dir="${mapcss.dir}/parsergen"/>
209 <exec append="false" executable="java" failifexecutionfails="true">
210 <arg value="-cp"/>
211 <arg value="${javacc.home}/javacc.jar"/>
212 <arg value="javacc"/>
213 <arg value="-DEBUG_PARSER=false"/>
214 <arg value="-DEBUG_TOKEN_MANAGER=false"/>
215 <arg value="-JDK_VERSION=1.8"/>
216 <arg value="-GRAMMAR_ENCODING=UTF-8"/>
217 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
218 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
219 </exec>
220 </target>
221 <target name="compile" depends="init,javacc">
222 <!-- COTS -->
223 <javac srcdir="${src.dir}" includes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**" nowarn="on" encoding="iso-8859-1"
224 destdir="build" target="1.8" source="1.8" debug="on" includeAntRuntime="false" createMissingPackageInfoClass="false">
225 <!-- get rid of "internal proprietary API" warning -->
226 <compilerarg value="-XDignore.symbol.file"/>
227 <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
228 <exclude name="org/apache/commons/compress/compressors/xz/**"/>
229 <exclude name="org/apache/commons/compress/compressors/CompressorStreamFactory.java"/>
230 <exclude name="org/apache/commons/compress/compressors/deflate/**"/>
231 <exclude name="org/apache/commons/compress/compressors/gzip/**"/>
232 <exclude name="org/apache/commons/compress/compressors/lzw/**"/>
233 <exclude name="org/apache/commons/compress/compressors/pack200/**"/>
234 <exclude name="org/apache/commons/compress/compressors/snappy/**"/>
235 <exclude name="org/apache/commons/compress/compressors/z/**"/>
236 <exclude name="org/apache/commons/jcs/admin/**"/>
237 <exclude name="org/apache/commons/jcs/auxiliary/disk/jdbc/**"/>
238 <exclude name="org/apache/commons/jcs/auxiliary/remote/**"/>
239 <exclude name="org/apache/commons/jcs/utils/servlet/**"/>
240 <exclude name="org/apache/commons/logging/impl/AvalonLogger.java"/>
241 <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"/>
242 <exclude name="org/apache/commons/logging/impl/Log4JLogger.java"/>
243 <exclude name="org/apache/commons/logging/impl/LogKitLogger.java"/>
244 <exclude name="org/apache/commons/logging/impl/ServletContextCleaner.java"/>
245 </javac>
246 <!-- JMapViewer -->
247 <javac compiler="com.google.errorprone.ErrorProneAntCompilerAdapter" sourcepath="" srcdir="${src.dir}"
248 excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java,org/openstreetmap/josm/**,JOSM.java,gnu/**"
249 destdir="build" target="1.8" source="1.8" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
250 <compilerclasspath>
251 <pathelement location="${error_prone_ant.jar}"/>
252 </compilerclasspath>
253 <compilerarg value="-Xlint:cast"/>
254 <compilerarg value="-Xlint:deprecation"/>
255 <compilerarg value="-Xlint:dep-ann"/>
256 <compilerarg value="-Xlint:divzero"/>
257 <compilerarg value="-Xlint:empty"/>
258 <compilerarg value="-Xlint:finally"/>
259 <compilerarg value="-Xlint:overrides"/>
260 <!--<compilerarg value="-Xlint:rawtypes"/>-->
261 <compilerarg value="-Xlint:static"/>
262 <compilerarg value="-Xlint:try"/>
263 <compilerarg value="-Xlint:unchecked"/>
264 <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
265 <compilerarg value="-XDignore.symbol.file"/>
266 </javac>
267 <!-- JOSM -->
268 <javac compiler="com.google.errorprone.ErrorProneAntCompilerAdapter" sourcepath="" srcdir="${src.dir}"
269 excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java"
270 destdir="build" target="1.8" source="1.8" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
271 <compilerclasspath>
272 <pathelement location="${error_prone_ant.jar}"/>
273 </compilerclasspath>
274 <compilerarg value="-Xlint:cast"/>
275 <compilerarg value="-Xlint:deprecation"/>
276 <compilerarg value="-Xlint:dep-ann"/>
277 <compilerarg value="-Xlint:divzero"/>
278 <compilerarg value="-Xlint:empty"/>
279 <compilerarg value="-Xlint:finally"/>
280 <compilerarg value="-Xlint:overrides"/>
281 <!--<compilerarg value="-Xlint:rawtypes"/>-->
282 <compilerarg value="-Xlint:static"/>
283 <compilerarg value="-Xlint:try"/>
284 <compilerarg value="-Xlint:unchecked"/>
285 <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
286 <compilerarg value="-XDignore.symbol.file"/>
287 </javac>
288
289 <copy todir="build" failonerror="no" includeemptydirs="no">
290 <fileset dir="resources"/>
291 </copy>
292 </target>
293 <target name="init" depends="init-properties">
294 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
295 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
296 </uptodate>
297 <mkdir dir="${build.dir}"/>
298 <mkdir dir="${dist.dir}"/>
299 </target>
300 <target name="javadoc" depends="init-properties">
301 <javadoc destdir="javadoc"
302 sourcepath="${src.dir}"
303 encoding="UTF-8"
304 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
305 excludepackagenames="org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.*"
306 windowtitle="JOSM"
307 use="true"
308 private="true"
309 linksource="true"
310 author="false">
311 <link href="http://docs.oracle.com/javase/8/docs/api"/>
312 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
313 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JOSM</a>]]></bottom>
314 </javadoc>
315 </target>
316 <target name="clean" depends="init-properties">
317 <delete dir="${build.dir}"/>
318 <delete dir="${proj-build.dir}"/>
319 <delete dir="${dist.dir}"/>
320 <delete dir="${mapcss.dir}/parsergen"/>
321 <delete file="${src.dir}/org/w3/_2001/xmlschema/Adapter1.java"/>
322 <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
323 <delete file="${epsg.output}"/>
324 </target>
325 <macrodef name="init-test-preferences">
326 <attribute name="testfamily"/>
327 <sequential>
328 <copy file="${test.dir}/config/preferences.template.xml" tofile="${test.dir}/config/@{testfamily}-josm.home/preferences.xml"/>
329 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
330 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
331 </sequential>
332 </macrodef>
333 <target name="test-init" depends="init-properties">
334 <mkdir dir="${test.dir}/build"/>
335 <mkdir dir="${test.dir}/build/unit"/>
336 <mkdir dir="${test.dir}/build/functional"/>
337 <mkdir dir="${test.dir}/build/performance"/>
338 <mkdir dir="${test.dir}/report"/>
339 <init-test-preferences testfamily="unit"/>
340 <init-test-preferences testfamily="functional"/>
341 <init-test-preferences testfamily="performance"/>
342 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
343 </target>
344 <target name="test-clean" depends="init-properties">
345 <delete dir="${test.dir}/build"/>
346 <delete dir="${test.dir}/report"/>
347 <delete file="${test.dir}/jacoco.exec" />
348 <delete file="${test.dir}/jacocoIT.exec" />
349 <delete file="${test.dir}/config/unit-josm.home/preferences.xml" />
350 <delete file="${test.dir}/config/functional-josm.home/preferences.xml" />
351 <delete file="${test.dir}/config/performance-josm.home/preferences.xml" />
352 <delete dir="${test.dir}/config/unit-josm.home/cache" failonerror="false"/>
353 <delete dir="${test.dir}/config/functional-josm.home/cache" failonerror="false"/>
354 <delete dir="${test.dir}/config/performance-josm.home/cache" failonerror="false"/>
355 </target>
356 <macrodef name="call-groovyc">
357 <attribute name="testfamily"/>
358 <element name="cp-elements"/>
359 <sequential>
360 <groovyc srcdir="${test.dir}/@{testfamily}" destdir="${test.dir}/build/@{testfamily}" encoding="UTF-8">
361 <classpath>
362 <cp-elements/>
363 </classpath>
364 <javac target="1.8" source="1.8" debug="on" encoding="UTF-8">
365 <compilerarg value="-Xlint:all"/>
366 <compilerarg value="-Xlint:-serial"/>
367 </javac>
368 </groovyc>
369 </sequential>
370 </macrodef>
371 <target name="test-compile" depends="test-init,dist">
372 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${groovy.jar}"/>
373 <call-groovyc testfamily="unit">
374 <cp-elements>
375 <path refid="test.classpath"/>
376 </cp-elements>
377 </call-groovyc>
378 <call-groovyc testfamily="functional">
379 <cp-elements>
380 <path refid="test.classpath"/>
381 <pathelement path="${test.dir}/build/unit"/>
382 </cp-elements>
383 </call-groovyc>
384 <call-groovyc testfamily="performance">
385 <cp-elements>
386 <path refid="test.classpath"/>
387 <pathelement path="${test.dir}/build/unit"/>
388 </cp-elements>
389 </call-groovyc>
390 </target>
391 <macrodef name="call-junit">
392 <attribute name="testfamily"/>
393 <attribute name="testITsuffix" default=""/>
394 <attribute name="coverage" default="true"/>
395 <sequential>
396 <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/>
397 <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" excludes="jdk.dynalink.*:jdk.nashorn.*">
398 <junit printsummary="yes" fork="true" forkmode="once">
399 <jvmarg value="-Dfile.encoding=UTF-8"/>
400 <jvmarg line="-addmods java.xml.bind" if:set="isJava9" />
401 <jvmarg value="-XaddExports:java.base/sun.security.util=ALL-UNNAMED" if:set="isJava9" />
402 <jvmarg value="-XaddExports:java.base/sun.security.x509=ALL-UNNAMED" if:set="isJava9" />
403 <jvmarg value="-XaddExports:java.xml.bind/javax.xml.bind=ALL-UNNAMED" if:set="isJava9" />
404 <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
405 <sysproperty key="josm.test.data" value="${test.dir}/data"/>
406 <sysproperty key="java.awt.headless" value="true"/>
407 <sysproperty key="glass.platform" value="Monocle"/>
408 <sysproperty key="monocle.platform" value="Headless"/>
409 <sysproperty key="prism.order" value="sw"/>
410 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
411 <classpath>
412 <path refid="test.classpath"/>
413 <pathelement path="${test.dir}/build/unit"/>
414 <pathelement path="${test.dir}/build/@{testfamily}"/>
415 <pathelement path="${test.dir}/config"/>
416 </classpath>
417 <formatter type="plain"/>
418 <formatter type="xml"/>
419 <batchtest fork="yes" todir="${test.dir}/report">
420 <fileset dir="${test.dir}/build/@{testfamily}" includes="**/*Test@{testITsuffix}.class"/>
421 </batchtest>
422 </junit>
423 </jacoco:coverage>
424 </sequential>
425 </macrodef>
426 <target name="test" depends="test-compile" unless="test.notRequired"
427 description="Run unit, functional and performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
428 <call-junit testfamily="unit"/>
429 <call-junit testfamily="functional"/>
430 <call-junit testfamily="performance" coverage="false"/>
431 </target>
432 <target name="test-it" depends="test-compile" unless="test-it.notRequired"
433 description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
434 <call-junit testfamily="unit" testITsuffix="IT"/>
435 <call-junit testfamily="functional" testITsuffix="IT"/>
436 <call-junit testfamily="performance" testITsuffix="IT" coverage="false"/>
437 </target>
438 <target name="test-html" depends="test, test-it" description="Generate HTML test reports">
439 <!-- May require additional ant dependencies like ant-trax package -->
440 <junitreport todir="${test.dir}/report">
441 <fileset dir="${test.dir}/report">
442 <include name="TEST-*.xml"/>
443 </fileset>
444 <report todir="${test.dir}/report/html"/>
445 </junitreport>
446 <jacoco:report>
447 <executiondata>
448 <file file="${test.dir}/jacoco.exec"/>
449 <file file="${test.dir}/jacocoIT.exec"/>
450 </executiondata>
451 <structure name="JOSM Test Coverage">
452 <classfiles>
453 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
454 </classfiles>
455 <sourcefiles encoding="UTF-8">
456 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
457 </sourcefiles>
458 </structure>
459 <html destdir="${test.dir}/report/jacoco"/>
460 </jacoco:report>
461 </target>
462 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
463 <target name="dist-optimized" depends="dist" unless="isJava9">
464 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
465 <proguard>
466 -injars dist/josm-custom.jar
467 -outjars dist/josm-custom-optimized.jar
468
469 -libraryjars ${java.home}/lib/rt.jar
470 -libraryjars ${java.home}/lib/jce.jar
471
472 -dontoptimize
473 -dontobfuscate
474
475 # These options probably are not necessary (and make processing a bit slower)
476 -dontskipnonpubliclibraryclasses
477 -dontskipnonpubliclibraryclassmembers
478
479 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
480 public static void main(java.lang.String[]);
481 }
482
483 -keep class JOSM
484 -keep class * extends org.openstreetmap.josm.io.FileImporter
485 -keep class * extends org.openstreetmap.josm.io.FileExporter
486 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
487 -keep class org.openstreetmap.josm.gui.mappaint.mapcss.Condition$PseudoClasses {
488 static boolean *(org.openstreetmap.josm.gui.mappaint.Environment);
489 }
490 -keep class org.apache.commons.logging.impl.*
491
492 -keepclassmembers enum * {
493 public static **[] values();
494 public static ** valueOf(java.lang.String);
495 }
496
497 # Keep unused public methods (can be useful for plugins)
498 -keepclassmembers class * {
499 public protected *;
500 }
501
502 # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
503 # This note should not be a problem as we don't use obfuscation
504 -dontnote
505 </proguard>
506 </target>
507 <target name="check-plugins" depends="dist-optimized">
508 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
509 <local name="dir"/>
510 <local name="plugins"/>
511 <property name="dir" value="plugin-check"/>
512 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
513 <classpath path="tools/animal-sniffer-ant-tasks-1.14.jar"/>
514 </typedef>
515 <mkdir dir="${dir}"/>
516 <!-- List of deprecated plugins -->
517 <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
518 <filterchain>
519 <linecontains>
520 <contains value="new DeprecatedPlugin("/>
521 </linecontains>
522 <tokenfilter>
523 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
524 </tokenfilter>
525 <striplinebreaks/>
526 <tokenfilter>
527 <replaceregex pattern="\|$" replace="" flags="gi"/>
528 </tokenfilter>
529 </filterchain>
530 </loadfile>
531 <!-- Download list of plugins -->
532 <loadresource property="plugins">
533 <url url="https://josm.openstreetmap.de/plugin"/>
534 <filterchain>
535 <linecontainsregexp negate="true">
536 <regexp pattern="^\t.*"/>
537 </linecontainsregexp>
538 <linecontainsregexp negate="true">
539 <regexp pattern="${deprecated-plugins}"/>
540 </linecontainsregexp>
541 <tokenfilter>
542 <replaceregex pattern="^.*;" replace="" flags="gi"/>
543 </tokenfilter>
544 </filterchain>
545 </loadresource>
546 <!-- Delete files that are not in plugin list (like old plugins) -->
547 <loadresource property="file-list">
548 <propertyresource name="plugins"/>
549 <filterchain>
550 <tokenfilter>
551 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
552 </tokenfilter>
553 <striplinebreaks/>
554 <tokenfilter>
555 <replaceregex pattern="\|$" replace="" flags="gi"/>
556 </tokenfilter>
557 </filterchain>
558 </loadresource>
559 <delete>
560 <restrict>
561 <fileset dir="${dir}"/>
562 <not>
563 <name regex="${file-list}"/>
564 </not>
565 </restrict>
566 </delete>
567 <!-- Download plugins -->
568 <copy todir="${dir}" flatten="true">
569 <resourcelist>
570 <string value="${plugins}"/>
571 </resourcelist>
572 </copy>
573 <!-- Check plugins -->
574 <as:build-signatures destfile="${dir}/api.sig">
575 <path>
576 <fileset file="${dist.dir}/josm-custom-optimized.jar"/>
577 <fileset file="${java.home}/lib/rt.jar"/>
578 <fileset file="${java.home}/lib/jce.jar"/>
579 </path>
580 </as:build-signatures>
581 <as:check-signature signature="${dir}/api.sig">
582 <ignore classname="au.edu.*"/>
583 <ignore classname="au.com.*"/>
584 <ignore classname="com.*"/>
585 <ignore classname="de.miethxml.*"/>
586 <ignore classname="javafx.*"/>
587 <ignore classname="javax.*"/>
588 <ignore classname="jogamp.*"/>
589 <ignore classname="junit.*"/>
590 <ignore classname="net.sf.*"/>
591 <ignore classname="nu.xom.*"/>
592 <ignore classname="org.apache.*"/>
593 <ignore classname="org.codehaus.*"/>
594 <ignore classname="org.dom4j.*"/>
595 <ignore classname="org.hsqldb.*"/>
596 <ignore classname="org.ibex.*"/>
597 <ignore classname="org.iso_relax.*"/>
598 <ignore classname="org.jaitools.*"/>
599 <ignore classname="org.jaxen.*"/>
600 <ignore classname="org.jdom2.*"/>
601 <ignore classname="org.jgraph.*"/>
602 <ignore classname="org.joda.time.*"/>
603 <ignore classname="org.jvnet.staxex.*"/>
604 <ignore classname="org.kxml2.*"/>
605 <ignore classname="org.objectweb.*"/>
606 <ignore classname="org.python.*"/>
607 <ignore classname="org.slf4j.*"/>
608 <!-- plugins used by another ones -->
609 <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
610 <ignore classname="org.openstreetmap.josm.plugins.jna.*"/>
611 <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
612 <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
613 <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
614 <path path="${dir}"/>
615 </as:check-signature>
616 </target>
617
618 <macrodef name="_taginfo">
619 <attribute name="type"/>
620 <attribute name="output"/>
621 <sequential>
622 <echo message="Generating Taginfo for type @{type} to @{output}"/>
623 <groovy src="${taginfoextract}" classpath="${dist.dir}/josm-custom.jar">
624 <arg value="-t"/>
625 <arg value="@{type}"/>
626 <arg value="--noexit"/>
627 <arg value="--svnweb"/>
628 <arg value="--imgurlprefix"/>
629 <arg value="${imgurlprefix}"/>
630 <arg value="-o"/>
631 <arg value="@{output}"/>
632 </groovy>
633 </sequential>
634 </macrodef>
635
636 <target name="taginfo" depends="dist">
637 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
638 <property name="taginfoextract" value="scripts/TagInfoExtract.groovy"/>
639 <property name="imgurlprefix" value="http://josm.openstreetmap.de/download/taginfo/taginfo-img"/>
640 <_taginfo type="mappaint" output="taginfo_style.json"/>
641 <_taginfo type="presets" output="taginfo_presets.json"/>
642 <_taginfo type="external_presets" output="taginfo_external_presets.json"/>
643 </target>
644
645 <target name="imageryindex" depends="init-properties">
646 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
647 <echo message="Checking editor imagery difference"/>
648 <groovy src="scripts/SyncEditorImageryIndex.groovy" classpath="${dist.dir}/josm-custom.jar">
649 <arg value="-nomissingeii"/>
650 </groovy>
651 </target>
652
653 <target name="imageryindexdownload">
654 <exec append="false" executable="wget" failifexecutionfails="true">
655 <arg value="https://josm.openstreetmap.de/maps"/>
656 <arg value="-O"/>
657 <arg value="maps.xml"/>
658 <arg value="--unlink"/>
659 </exec>
660 <exec append="false" executable="wget" failifexecutionfails="true">
661 <arg value="https://raw.githubusercontent.com/osmlab/editor-imagery-index/gh-pages/imagery.json"/>
662 <arg value="-O"/>
663 <arg value="imagery.json"/>
664 <arg value="--unlink"/>
665 </exec>
666 <antcall target="imageryindex"/>
667 </target>
668
669 <target name="checkstyle" depends="init-properties">
670 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
671 classpath="tools/checkstyle/checkstyle-7.0-all.jar"/>
672 <checkstyle config="tools/checkstyle/josm_checks.xml">
673 <fileset dir="${base.dir}/src/org/openstreetmap/josm" includes="**/*.java"
674 excludes="gui/mappaint/mapcss/parsergen/*.java"/>
675 <fileset dir="${base.dir}/test" includes="**/*.java"/>
676 <formatter type="xml" toFile="checkstyle-josm.xml"/>
677 </checkstyle>
678 </target>
679
680 <target name="findbugs" depends="dist">
681 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
682 <path id="findbugs-classpath">
683 <fileset dir="${base.dir}/tools/findbugs/">
684 <include name="*.jar"/>
685 </fileset>
686 </path>
687 <property name="findbugs-classpath" refid="findbugs-classpath"/>
688 <findbugs output="xml"
689 outputFile="findbugs-josm.xml"
690 classpath="${findbugs-classpath}"
691 pluginList=""
692 excludeFilter="tools/findbugs/josm-filter.xml"
693 effort="max"
694 reportLevel="low"
695 >
696 <sourcePath path="${base.dir}/src" />
697 <class location="${dist.dir}/josm-custom.jar" />
698 </findbugs>
699 </target>
700 <target name="run" depends="dist">
701 <java jar="${dist.dir}/josm-custom.jar" fork="true">
702 <arg value="--set=expert=true"/>
703 <arg value="--set=remotecontrol.enabled=true"/>
704 <arg value="--set=debug.edt-checker.enable=false"/>
705 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
706 </java>
707 </target>
708 <!--
709 ** Compile build script for generating projection list.
710 -->
711 <target name="epsg-compile">
712 <property name="proj-classpath" location="${build.dir}"/>
713 <mkdir dir="${proj-build.dir}"/>
714 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true"
715 destdir="${proj-build.dir}" target="1.8" source="1.8" debug="on"
716 includeantruntime="false" createMissingPackageInfoClass="false"
717 encoding="UTF-8" classpath="${proj-classpath}">
718 </javac>
719 </target>
720 <!--
721 ** generate projection list.
722 -->
723 <target name="epsg" depends="epsg-compile">
724 <touch file="${epsg.output}"/>
725 <java classname="BuildProjectionDefinitions" failonerror="true" fork="true">
726 <sysproperty key="java.awt.headless" value="true"/>
727 <classpath>
728 <pathelement path="${base.dir}"/>
729 <pathelement path="${proj-classpath}"/>
730 <pathelement path="${proj-build.dir}"/>
731 </classpath>
732 <arg value="${base.dir}"/>
733 </java>
734 </target>
735</project>
Note: See TracBrowser for help on using the repository browser.