source: josm/trunk/build.xml @ 15032

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

see #17671 - allow to include/exclude specific unit test on the command line

  • Property svn:eol-style set to native
File size: 59.8 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" xmlns:unless="ant:unless">
12    <target name="init-properties">
13        <property environment="env"/>
14        <!-- Load properties in a target and not at top level, so this build file can be
15        imported from an IDE ant file (Netbeans) without messing up IDE properties.
16        When imported from another file, ${basedir} will point to the parent directory
17        of the importing ant file. Use ${base.dir} instead, which is always the parent
18        directory of this file. -->
19        <dirname property="base.dir" file="${ant.file.josm}"/>
20        <property name="test.dir" location="${base.dir}/test"/>
21        <property name="src.dir" location="${base.dir}/src"/>
22        <condition property="noJavaFX">
23            <or>
24                <isset property="env.JOSM_NOJAVAFX"/>
25                <not>
26                    <available classname="javafx.scene.media.Media"/>
27                </not>
28            </or>
29        </condition>
30        <property name="build.dir" location="${base.dir}/build"/>
31        <property name="dist.dir" location="${base.dir}/dist"/>
32        <property name="modules.dir" location="${dist.dir}/modules"/>
33        <property name="tools.dir" location="${base.dir}/tools"/>
34        <property name="pmd.dir" location="${tools.dir}/pmd"/>
35        <property name="checkstyle.dir" location="${tools.dir}/checkstyle"/>
36        <property name="spotbugs.dir" location="${tools.dir}/spotbugs"/>
37        <property name="javacc.home" location="${tools.dir}"/>
38        <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
39        <property name="proj-build.dir" location="${base.dir}/build2"/>
40        <property name="taginfo-build.dir" location="${base.dir}/build2"/>
41        <property name="checkstyle-build.dir" location="${base.dir}/build2"/>
42        <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/>
43        <property name="error_prone_core.jar" location="${tools.dir}/error_prone_core.jar"/>
44        <property name="error_prone_javac.jar" location="${tools.dir}/error_prone_javac.jar"/>
45        <property name="dataflow.jar" location="${tools.dir}/dataflow.jar"/>
46        <property name="javacutil.jar" location="${tools.dir}/javacutil.jar"/>
47        <property name="failureaccess.jar" location="${tools.dir}/failureaccess.jar"/>
48        <property name="guava.jar" location="${tools.dir}/guava.jar"/>
49        <property name="jformatstring.jar" location="${spotbugs.dir}/jFormatString-3.0.0.jar"/>
50        <property name="dist.jar" location="${dist.dir}/josm-custom.jar"/>
51        <property name="dist-optimized.jar" location="${dist.dir}/josm-custom-optimized.jar"/>
52        <property name="java.lang.version" value="1.8" />
53        <property name="test.headless" value="true" />
54        <property name="jacoco.includes" value="org.openstreetmap.josm.*" />
55        <property name="jacoco.inclbootstrapclasses" value="false" />
56        <property name="jacoco.inclnolocationclasses" value="false" />
57        <property name="junit.printsummary" value="on" />
58        <property name="default-junit-includes" value="**/*Test.class"/>
59        <property name="default-junitIT-includes" value="**/*TestIT.class"/>
60        <!-- build parameter: compression level (ant -Dclevel=N)
61                 N ranges from 0 (no compression) to 9 (maximum compression)
62                 default: 9 -->
63        <condition property="clevel" value="${clevel}" else="9">
64            <isset property="clevel"/>
65        </condition>
66        <!-- For Java specific stuff by version -->
67        <condition property="isJava9"><matches string="${ant.java.version}" pattern="(1.)?(9|1[0-9])" /></condition>
68        <condition property="isJava10"><matches string="${ant.java.version}" pattern="1[0-9]" /></condition>
69        <condition property="isJava11"><matches string="${ant.java.version}" pattern="1[1-9]" /></condition>
70        <condition property="isJava12"><matches string="${ant.java.version}" pattern="1[2-9]" /></condition>
71        <condition property="isJava13"><matches string="${ant.java.version}" pattern="1[3-9]" /></condition>
72        <!-- Disable jacoco on Java 13+, see https://github.com/jacoco/jacoco/pull/738 -->
73        <condition property="coverageByDefault">
74            <not>
75                <isset property="isJava13"/>
76            </not>
77        </condition>
78        <condition property="java.library.dir" value="jmods" else="lib">
79            <isset property="isJava9"/>
80        </condition>
81        <path id="groovy.classpath">
82            <fileset dir="${tools.dir}/groovy">
83                <include name="*.jar"/>
84            </fileset>
85        </path>
86        <path id="test.classpath">
87            <fileset dir="${test.dir}/lib">
88                <include name="**/*.jar"/>
89            </fileset>
90            <pathelement path="${dist.jar}"/>
91            <pathelement path="${failureaccess.jar}"/>
92            <pathelement path="${guava.jar}"/>
93            <pathelement path="${pmd.dir}/commons-lang3-3.8.1.jar"/>
94            <pathelement path="${spotbugs.dir}/spotbugs-annotations.jar"/>
95        </path>
96        <path id="pmd.classpath">
97            <fileset dir="${pmd.dir}">
98                <include name="*.jar"/>
99            </fileset>
100        </path>
101        <path id="processor.path">
102            <pathelement location="${error_prone_core.jar}"/>
103            <pathelement location="${dataflow.jar}"/>
104            <pathelement location="${javacutil.jar}"/>
105            <pathelement location="${failureaccess.jar}"/>
106            <pathelement location="${guava.jar}"/>
107            <pathelement location="${jformatstring.jar}"/>
108        </path>
109    </target>
110
111    <!--
112      ** Used by Eclipse ant builder for updating
113      ** the REVISION file used by JOSM
114    -->
115    <target name="create-revision-eclipse">
116        <property name="revision.dir" value="bin"/>
117        <antcall target="create-revision"/>
118        <mkdir dir="bin/META-INF/services"/>
119        <echo encoding="UTF-8" file="bin/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider">org.openstreetmap.josm.tools.JosmDecimalFormatSymbolsProvider</echo>
120    </target>
121    <!--
122      ** Initializes the REVISION.XML file from SVN information
123    -->
124    <target name="init-svn-revision-xml" depends="init-properties">
125        <exec append="false" output="${base.dir}/REVISION.XML" executable="svn" dir="${base.dir}" failifexecutionfails="false" resultproperty="svn.info.result">
126            <env key="LANG" value="C"/>
127            <arg value="info"/>
128            <arg value="--xml"/>
129            <arg value="."/>
130        </exec>
131        <condition property="svn.info.success">
132            <equals arg1="${svn.info.result}" arg2="0" />
133        </condition>
134    </target>
135    <!--
136      ** Initializes the REVISION.XML file from git information
137    -->
138    <target name="init-git-revision-xml" unless="svn.info.success" depends="init-properties">
139        <exec append="false" output="${base.dir}/REVISION.XML" executable="git" dir="${base.dir}" failifexecutionfails="false">
140            <arg value="log"/>
141            <arg value="-1"/>
142            <arg value="--grep=git-svn-id"/>
143            <!--
144            %B:  raw body (unwrapped subject and body)
145            %n:  new line
146            %ai: author date, ISO 8601 format
147            -->
148            <arg value="--pretty=format:%B%n%ai"/>
149            <arg value="HEAD"/>
150        </exec>
151        <replaceregexp file="${base.dir}/REVISION.XML" flags="s"
152                       match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
153                       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;"/>
154    </target>
155    <!--
156      ** Creates the REVISION file to be included in the distribution
157    -->
158    <target name="create-revision" depends="init-properties,init-svn-revision-xml,init-git-revision-xml">
159        <property name="revision.dir" value="${build.dir}"/>
160        <xmlproperty file="${base.dir}/REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
161        <delete file="${base.dir}/REVISION.XML"/>
162        <tstamp>
163            <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
164        </tstamp>
165        <property name="version.entry.commit.revision" value="UNKNOWN"/>
166        <property name="version.entry.commit.date" value="UNKNOWN"/>
167        <mkdir dir="${revision.dir}"/>
168        <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
169        <echo file="${revision.dir}/REVISION">
170# automatically generated by JOSM build.xml - do not edit
171Revision: ${version.entry.commit.revision}
172Is-Local-Build: true
173Build-Date: ${build.tstamp}
174</echo>
175    </target>
176    <!--
177      ** Check internal XML files against their XSD
178    -->
179    <target name="check-schemas" unless="check-schemas.notRequired" depends="init-properties">
180        <schemavalidate file="data/defaultpresets.xml" >
181            <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
182        </schemavalidate>
183    </target>
184    <!--
185      ** Main target that builds JOSM and checks XML against schemas
186    -->
187    <target name="dist" depends="compile,create-revision,check-schemas,epsg">
188        <echo>Revision ${version.entry.commit.revision}</echo>
189        <copy file="CONTRIBUTION" todir="${build.dir}"/>
190        <copy file="README" todir="${build.dir}"/>
191        <copy file="LICENSE" todir="${build.dir}"/>
192        <!-- create josm-custom.jar -->
193        <delete file="${dist.jar}"/>
194        <jar destfile="${dist.jar}" basedir="${build.dir}" level="${clevel}">
195            <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
196            <manifest>
197                <attribute name="Main-class" value="org.openstreetmap.josm.gui.MainApplication"/>
198                <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
199                <attribute name="Main-Date" value="${version.entry.commit.date}"/>
200                <attribute name="Permissions" value="all-permissions"/>
201                <attribute name="Codebase" value="josm.openstreetmap.de"/>
202                <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
203                <!-- Java 9 stuff. Entries are safely ignored by Java 8 -->
204                <attribute name="Add-Exports" value="java.base/sun.security.util java.base/sun.security.x509 java.desktop/com.apple.eawt java.desktop/com.sun.imageio.spi javafx.graphics/com.sun.javafx.application jdk.deploy/com.sun.deploy.config" />
205                <attribute name="Add-Opens" value="java.base/java.lang java.base/java.nio java.base/jdk.internal.loader java.base/jdk.internal.ref java.desktop/javax.imageio.spi java.desktop/javax.swing.text.html java.prefs/java.util.prefs" />
206            </manifest>
207            <service type="java.text.spi.DecimalFormatSymbolsProvider" provider="org.openstreetmap.josm.tools.JosmDecimalFormatSymbolsProvider" />
208            <zipfileset dir="images" prefix="images"/>
209            <zipfileset dir="data" prefix="data"/>
210            <zipfileset dir="styles" prefix="styles"/>
211            <zipfileset dir="${src.dir}/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
212        </jar>
213    </target>
214    <!-- Mac OS X target -->
215    <target name="mac" depends="init-properties">
216        <!-- Using https://bitbucket.org/infinitekind/appbundler to create mac application bundle -->
217        <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="${tools.dir}/appbundler.jar"/>
218        <!-- create MacOS X application bundle -->
219        <bundleapp outputdirectory="${bundle.outdir}" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
220                   mainclassname="org.openstreetmap.josm.gui.MainApplication"
221                   copyright="JOSM, and all its integral parts, are released under the GNU General Public License v2 or later"
222                   applicationCategory="public.app-category.utilities"
223                   shortversion="${version.entry.commit.revision} SVN"
224                   version="${version.entry.commit.revision} SVN"
225                   icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
226                   highResolutionCapable="true">
227
228            <arch name="x86_64"/>
229            <arch name="i386"/>
230
231            <classpath file="${bundle.jar}"/>
232
233            <option value="-Xmx2048m"/>
234
235            <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
236            <option value="-Xdock:name=JOSM"/>
237
238            <!-- OSX specific options, optional -->
239            <option value="-Dapple.laf.useScreenMenuBar=true"/>
240            <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
241            <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
242            <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
243            <option value="-Dcom.apple.smallTabs=true"/>
244        </bundleapp>
245
246        <!-- appbundler lacks the possibility of defining our own keys or using a template, so update the .plist manually -->
247        <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="${tools.dir}/xmltask.jar"/>
248
249        <xmltask source="${bundle.outdir}/JOSM.app/Contents/Info.plist" dest="${bundle.outdir}/JOSM.app/Contents/Info.plist" indent="false">
250            <!-- remove empty CFBundleDocumentTypes definition -->
251            <remove path="/plist/dict/key[text()='CFBundleDocumentTypes']|/plist/dict/key[text()='CFBundleDocumentTypes']/following-sibling::array[1]"/>
252            <!-- insert our own keys -->
253            <insert position="before" path="/plist/dict/key[1]" file="macosx/JOSM.app/Contents/Info.plist_template.xml" />
254        </xmltask>
255
256        <!-- create ZIP file with MacOS X application bundle -->
257        <zip destfile="${bundle.outdir}/josm-custom-macosx.zip" update="true">
258            <zipfileset dir="." includes="CONTRIBUTION README LICENSE"/>
259            <zipfileset dir="${bundle.outdir}" includes="JOSM.app/**/*" filemode="755" />
260        </zip>
261    </target>
262    <target name="distmac" depends="dist">
263        <antcall target="mac">
264            <param name="bundle.outdir" value="${dist.dir}"/>
265            <param name="bundle.jar" value="${dist.jar}"/>
266        </antcall>
267    </target>
268    <!-- Windows target -->
269    <target name="distwin" depends="dist">
270        <exec dir="windows" executable="./josm-setup-unix.sh">
271            <arg value="${version.entry.commit.revision}"/>
272            <arg value="${dist.jar}"/>
273        </exec>
274    </target>
275    <target name="javacc" depends="init" unless="javacc.notRequired">
276        <mkdir dir="${mapcss.dir}/parsergen"/>
277        <java classname="javacc" fork="true" failonerror="true">
278            <classpath path="${javacc.home}/javacc.jar"/>
279            <arg value="-DEBUG_PARSER=false"/>
280            <arg value="-DEBUG_TOKEN_MANAGER=false"/>
281            <arg value="-JDK_VERSION=${java.lang.version}"/>
282            <arg value="-GRAMMAR_ENCODING=UTF-8"/>
283            <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
284            <arg value="${mapcss.dir}/MapCSSParser.jj"/>
285        </java>
286    </target>
287    <target name="compile-cots" depends="init">
288        <!-- COTS -->
289        <javac srcdir="${src.dir}" includes="com/**,javax/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/tukaani/**" nowarn="on" encoding="iso-8859-1"
290            destdir="${build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on" includeAntRuntime="false" createMissingPackageInfoClass="false">
291            <!-- get rid of "internal proprietary API" warning -->
292            <compilerarg value="-XDignore.symbol.file"/>
293            <exclude name="org/apache/commons/compress/PasswordRequiredException.java"/>
294            <exclude name="org/apache/commons/compress/archivers/**"/>
295            <exclude name="org/apache/commons/compress/changes/**"/>
296            <exclude name="org/apache/commons/compress/compressors/bzip2/BZip2Utils.java"/>
297            <exclude name="org/apache/commons/compress/compressors/brotli/**"/>
298            <exclude name="org/apache/commons/compress/compressors/CompressorStreamFactory.java"/>
299            <exclude name="org/apache/commons/compress/compressors/CompressorStreamProvider.java"/>
300            <exclude name="org/apache/commons/compress/compressors/CompressorException.java"/>
301            <exclude name="org/apache/commons/compress/compressors/FileNameUtil.java"/>
302            <exclude name="org/apache/commons/compress/compressors/deflate/**"/>
303            <exclude name="org/apache/commons/compress/compressors/gzip/**"/>
304            <exclude name="org/apache/commons/compress/compressors/lz4/**"/>
305            <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
306            <exclude name="org/apache/commons/compress/compressors/lz77support/**"/>
307            <exclude name="org/apache/commons/compress/compressors/pack200/**"/>
308            <exclude name="org/apache/commons/compress/compressors/snappy/**"/>
309            <exclude name="org/apache/commons/compress/compressors/xz/XZUtils.java"/>
310            <exclude name="org/apache/commons/compress/compressors/z/**"/>
311            <exclude name="org/apache/commons/compress/compressors/zstandard/**"/>
312            <exclude name="org/apache/commons/compress/parallel/**"/>
313            <exclude name="org/apache/commons/compress/utils/ArchiveUtils.java"/>
314            <exclude name="org/apache/commons/jcs/JCS.java"/>
315            <exclude name="org/apache/commons/jcs/access/GroupCacheAccess.java"/>
316            <exclude name="org/apache/commons/jcs/access/PartitionedCacheAccess.java"/>
317            <exclude name="org/apache/commons/jcs/access/behavior/IGroupCacheAccess.java"/>
318            <exclude name="org/apache/commons/jcs/access/exception/InvalidGroupException.java"/>
319            <exclude name="org/apache/commons/jcs/admin/servlet/**"/>
320            <exclude name="org/apache/commons/jcs/auxiliary/AbstractAuxiliaryCacheMonitor.java"/>
321            <exclude name="org/apache/commons/jcs/auxiliary/disk/jdbc/**"/>
322            <exclude name="org/apache/commons/jcs/auxiliary/lateral/**"/>
323            <exclude name="org/apache/commons/jcs/auxiliary/remote/**"/>
324            <exclude name="org/apache/commons/jcs/engine/CacheAdaptor.java"/>
325            <exclude name="org/apache/commons/jcs/engine/CacheGroup.java"/>
326            <exclude name="org/apache/commons/jcs/engine/CacheWatchRepairable.java"/>
327            <exclude name="org/apache/commons/jcs/engine/Zombie*.java"/>
328            <exclude name="org/apache/commons/jcs/engine/logging/CacheEventLoggerDebugLogger.java"/>
329            <exclude name="org/apache/commons/jcs/utils/access/**"/>
330            <exclude name="org/apache/commons/jcs/utils/discovery/**"/>
331            <exclude name="org/apache/commons/jcs/utils/net/**"/>
332            <exclude name="org/apache/commons/jcs/utils/props/**"/>
333            <exclude name="org/apache/commons/jcs/utils/servlet/**"/>
334            <exclude name="org/apache/commons/logging/impl/AvalonLogger.java"/>
335            <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"/>
336            <exclude name="org/apache/commons/logging/impl/Log4JLogger.java"/>
337            <exclude name="org/apache/commons/logging/impl/LogKitLogger.java"/>
338            <exclude name="org/apache/commons/logging/impl/ServletContextCleaner.java"/>
339        </javac>
340    </target>
341    <target name="compile-jmapviewer" depends="init">
342        <!-- JMapViewer -->
343        <javac sourcepath="" srcdir="${src.dir}" fork="yes"
344            excludes="com/**,javax/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java,org/openstreetmap/gui/jmapviewer/JMapViewerTree.java,org/openstreetmap/gui/jmapviewer/checkBoxTree/**,org/openstreetmap/josm/**,org/tukaani/**"
345            destdir="${build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
346            <compilerarg value="-J-Xbootclasspath/p:${error_prone_javac.jar}" unless:set="isJava9"/>
347            <compilerarg line="-XDcompilePolicy=simple"/>
348            <compilerarg value="-processorpath"/>
349            <compilerarg pathref="processor.path"/>
350            <compilerarg value="-Xlint:cast"/>
351            <compilerarg value="-Xlint:deprecation"/>
352            <compilerarg value="-Xlint:dep-ann"/>
353            <compilerarg value="-Xlint:divzero"/>
354            <compilerarg value="-Xlint:empty"/>
355            <compilerarg value="-Xlint:finally"/>
356            <compilerarg value="-Xlint:overrides"/>
357            <!--<compilerarg value="-Xlint:rawtypes"/>-->
358            <compilerarg value="-Xlint:static"/>
359            <compilerarg value="-Xlint:try"/>
360            <compilerarg value="-Xlint:unchecked"/>
361            <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
362            <compilerarg value="-XDignore.symbol.file"/>
363            <compilerarg value="-Xplugin:ErrorProne -Xep:CatchAndPrintStackTrace:OFF -Xep:ReferenceEquality:OFF -Xep:StringSplitter:OFF"/>
364            <compilerarg line="-Xmaxwarns 1000"/>
365        </javac>
366    </target>
367    <target name="compile" depends="init,javacc,compile-cots,compile-jmapviewer">
368        <!-- JOSM -->
369        <javac sourcepath="" srcdir="${src.dir}" fork="yes"
370            excludes="com/**,javax/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/**,org/tukaani/**"
371            destdir="${build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
372            <compilerarg value="-J-Xbootclasspath/p:${error_prone_javac.jar}" unless:set="isJava9"/>
373            <compilerarg line="-XDcompilePolicy=simple"/>
374            <compilerarg value="-processorpath"/>
375            <compilerarg pathref="processor.path"/>
376            <compilerarg value="-Xlint:cast"/>
377            <compilerarg value="-Xlint:deprecation"/>
378            <compilerarg value="-Xlint:dep-ann"/>
379            <compilerarg value="-Xlint:divzero"/>
380            <compilerarg value="-Xlint:empty"/>
381            <compilerarg value="-Xlint:finally"/>
382            <compilerarg value="-Xlint:overrides"/>
383            <!--<compilerarg value="-Xlint:rawtypes"/>-->
384            <compilerarg value="-Xlint:static"/>
385            <compilerarg value="-Xlint:try"/>
386            <compilerarg value="-Xlint:unchecked"/>
387            <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
388            <compilerarg value="-XDignore.symbol.file"/>
389            <compilerarg value="-Xplugin:ErrorProne -Xep:ReferenceEquality:OFF -Xep:ImmutableEnumChecker:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:FloatingPointLiteralPrecision:OFF -Xep:ShortCircuitBoolean:OFF -Xep:StringSplitter:OFF -Xep:JdkObsolete:OFF -Xep:UnnecessaryParentheses:OFF -Xep:EqualsGetClass:OFF -Xep:ThreadPriorityCheck:OFF -Xep:UndefinedEquals:OFF -Xep:MixedMutabilityReturnType:OFF -Xep:OverrideThrowableToString:OFF -Xep:JavaTimeDefaultTimeZone:OFF -Xep:UnusedVariable:OFF -Xep:EqualsUsingHashCode:OFF"/>
390            <compilerarg line="-Xmaxwarns 1000"/>
391            <exclude name="org/openstreetmap/josm/io/audio/fx/*.java" if:set="noJavaFX"/>
392        </javac>
393
394        <copy todir="build" failonerror="no" includeemptydirs="no">
395            <fileset dir="resources"/>
396        </copy>
397    </target>
398    <target name="init" depends="init-properties">
399        <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
400            <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
401        </uptodate>
402        <mkdir dir="${build.dir}"/>
403        <mkdir dir="${dist.dir}"/>
404    </target>
405    <target name="javadoc" depends="init-properties">
406        <javadoc destdir="javadoc"
407                sourcepath="${src.dir}"
408                encoding="UTF-8"
409                packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
410                excludepackagenames="org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.*"
411                windowtitle="JOSM"
412                use="true"
413                private="true"
414                linksource="true"
415                author="false">
416            <link href="https://docs.oracle.com/javase/8/docs/api"/>
417            <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
418            <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JOSM</a>]]></bottom>
419            <arg value="-html5" if:set="isJava9" />
420            <arg value="--add-exports" if:set="isJava9" />
421            <arg value="java.base/sun.security.util=ALL-UNNAMED" if:set="isJava9" />
422            <arg value="--add-exports" if:set="isJava9" />
423            <arg value="java.base/sun.security.x509=ALL-UNNAMED" if:set="isJava9" />
424            <arg value="--add-exports" if:set="isJava9" unless:set="noJavaFX" />
425            <arg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" unless:set="noJavaFX" />
426            <excludepackage name="org/openstreetmap/josm/io/audio/fx" if:set="noJavaFX" />
427        </javadoc>
428    </target>
429    <target name="clean" depends="init-properties">
430        <delete dir="${build.dir}"/>
431        <delete dir="${proj-build.dir}"/>
432        <delete dir="${checkstyle-build.dir}"/>
433        <delete dir="${dist.dir}"/>
434        <delete dir="${mapcss.dir}/parsergen"/>
435        <delete file="${src.dir}/org/w3/_2001/xmlschema/Adapter1.java"/>
436        <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
437        <delete file="${epsg.output}"/>
438        <delete file="${pmd.dir}/cache"/>
439    </target>
440    <macrodef name="init-test-preferences">
441        <attribute name="testfamily"/>
442        <sequential>
443            <copy file="${test.dir}/config/preferences.template.xml" tofile="${test.dir}/config/@{testfamily}-josm.home/preferences.xml"/>
444            <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
445            <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
446        </sequential>
447    </macrodef>
448    <target name="test-init" depends="init-properties">
449        <mkdir dir="${test.dir}/build"/>
450        <mkdir dir="${test.dir}/build/unit"/>
451        <mkdir dir="${test.dir}/build/functional"/>
452        <mkdir dir="${test.dir}/build/performance"/>
453        <mkdir dir="${test.dir}/report"/>
454        <init-test-preferences testfamily="unit"/>
455        <init-test-preferences testfamily="functional"/>
456        <init-test-preferences testfamily="performance"/>
457        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="${tools.dir}/jacocoant.jar" />
458    </target>
459    <target name="test-clean" depends="init-properties">
460        <delete dir="${test.dir}/build"/>
461        <delete dir="${test.dir}/report"/>
462        <delete file="${test.dir}/jacoco.exec" />
463        <delete file="${test.dir}/jacocoIT.exec" />
464        <delete file="${test.dir}/config/unit-josm.home" failonerror="false"/>
465        <delete file="${test.dir}/config/functional-josm.home" failonerror="false"/>
466        <delete file="${test.dir}/config/performance-josm.home" failonerror="false"/>
467    </target>
468    <macrodef name="call-javac">
469        <attribute name="testfamily"/>
470        <element name="cp-elements"/>
471        <sequential>
472            <javac srcdir="${test.dir}/@{testfamily}" destdir="${test.dir}/build/@{testfamily}"
473                target="${java.lang.version}" source="${java.lang.version}" debug="on"
474                includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
475                <compilerarg value="-Xlint:all"/>
476                <compilerarg value="-Xlint:-serial"/>
477                <classpath>
478                    <cp-elements/>
479                </classpath>
480            </javac>
481        </sequential>
482    </macrodef>
483    <target name="test-compile" depends="test-init,dist">
484        <call-javac testfamily="unit">
485            <cp-elements>
486                <path refid="test.classpath"/>
487            </cp-elements>
488        </call-javac>
489        <call-javac testfamily="functional">
490            <cp-elements>
491                <path refid="test.classpath"/>
492                <pathelement path="${test.dir}/build/unit"/>
493            </cp-elements>
494        </call-javac>
495        <call-javac testfamily="performance">
496            <cp-elements>
497                <path refid="test.classpath"/>
498                <pathelement path="${test.dir}/build/unit"/>
499            </cp-elements>
500        </call-javac>
501    </target>
502    <macrodef name="call-junit">
503        <attribute name="testfamily"/>
504        <attribute name="testITsuffix" default=""/>
505        <attribute name="coverage" default="${coverageByDefault}"/>
506        <attribute name="includes" default="${default-junit@{testITsuffix}-includes}"/>
507        <attribute name="excludes" default="${default-junit@{testITsuffix}-excludes}"/>
508        <sequential>
509            <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/>
510            <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="${jacoco.includes}"
511                inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}">
512                <junit printsummary="${junit.printsummary}" fork="true" forkmode="once" failureproperty="test.@{testfamily}@{testITsuffix}.failed">
513                    <jvmarg value="-Dfile.encoding=UTF-8"/>
514                    <jvmarg value="-javaagent:${test.dir}/lib/jmockit.jar"/>
515                    <jvmarg value="--add-modules" if:set="isJava9" unless:set="isJava11" />
516                    <jvmarg value="java.activation,java.se.ee" if:set="isJava9" unless:set="isJava11" />
517                    <jvmarg value="--add-exports" if:set="isJava9" />
518                    <jvmarg value="java.base/sun.security.util=ALL-UNNAMED" if:set="isJava9" />
519                    <jvmarg value="--add-exports" if:set="isJava9" />
520                    <jvmarg value="java.base/sun.security.x509=ALL-UNNAMED" if:set="isJava9" />
521                    <jvmarg value="--add-exports" if:set="isJava9" unless:set="noJavaFX" />
522                    <jvmarg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" unless:set="noJavaFX" />
523                    <jvmarg value="--add-exports" if:set="isJava9" unless:set="isJava11" />
524                    <jvmarg value="jdk.deploy/com.sun.deploy.config=ALL-UNNAMED" if:set="isJava9" unless:set="isJava11" />
525                    <jvmarg value="--add-opens" if:set="isJava9" />
526                    <jvmarg value="java.base/java.io=ALL-UNNAMED" if:set="isJava9" />
527                    <jvmarg value="--add-opens" if:set="isJava9" />
528                    <jvmarg value="java.base/java.lang=ALL-UNNAMED" if:set="isJava9" />
529                    <jvmarg value="--add-opens" if:set="isJava9" />
530                    <jvmarg value="java.base/java.nio=ALL-UNNAMED" if:set="isJava9" />
531                    <jvmarg value="--add-opens" if:set="isJava9" />
532                    <jvmarg value="java.base/java.text=ALL-UNNAMED" if:set="isJava9" />
533                    <jvmarg value="--add-opens" if:set="isJava9" />
534                    <jvmarg value="java.base/java.util=ALL-UNNAMED" if:set="isJava9" />
535                    <jvmarg value="--add-opens" if:set="isJava9" />
536                    <jvmarg value="java.base/jdk.internal.loader=ALL-UNNAMED" if:set="isJava9" />
537                    <jvmarg value="--add-opens" if:set="isJava9" />
538                    <jvmarg value="java.desktop/java.awt=ALL-UNNAMED" if:set="isJava9" />
539                    <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
540                    <sysproperty key="josm.test.data" value="${test.dir}/data"/>
541                    <sysproperty key="java.awt.headless" value="${test.headless}"/>
542                    <sysproperty key="glass.platform" value="Monocle"/>
543                    <sysproperty key="monocle.platform" value="Headless"/>
544                    <sysproperty key="prism.order" value="sw"/>
545                    <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
546                    <classpath>
547                        <path refid="test.classpath"/>
548                        <pathelement path="${test.dir}/build/unit"/>
549                        <pathelement path="${test.dir}/build/@{testfamily}"/>
550                        <pathelement path="${test.dir}/config"/>
551                    </classpath>
552                    <formatter type="plain"/>
553                    <formatter type="xml"/>
554                    <batchtest fork="yes" todir="${test.dir}/report">
555                        <fileset dir="${test.dir}/build/@{testfamily}" includes="@{includes}" excludes="@{excludes}"/>
556                    </batchtest>
557                </junit>
558            </jacoco:coverage>
559        </sequential>
560    </macrodef>
561    <target name="test" depends="test-compile" unless="test.notRequired"
562        description="Run unit and functional tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
563        <call-junit testfamily="unit"/>
564        <call-junit testfamily="functional"/>
565    </target>
566    <target name="test-hardfail" depends="test" description="Run 'test' target but abort if tests failed">
567        <fail message="'test' failed">
568            <condition>
569                <or>
570                    <isset property="test.unit.failed"/>
571                    <isset property="test.functional.failed"/>
572                </or>
573            </condition>
574        </fail>
575    </target>
576    <target name="test-unit" depends="test-compile" unless="test-unit.notRequired"
577        description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
578        <call-junit testfamily="unit"/>
579    </target>
580    <target name="test-unit-hardfail" depends="test-unit" description="Run 'test-unit' target but abort if tests failed">
581        <fail message="'test-unit' failed" if="test.unit.failed"/>
582    </target>
583    <target name="test-it" depends="test-compile" unless="test-it.notRequired"
584        description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
585        <call-junit testfamily="unit" testITsuffix="IT"/>
586        <call-junit testfamily="functional" testITsuffix="IT"/>
587    </target>
588    <target name="test-it-hardfail" depends="test-it" description="Run 'test-it' target but abort if tests failed">
589        <fail message="'test-it' failed">
590            <condition>
591                <or>
592                    <isset property="test.unitIT.failed"/>
593                    <isset property="test.functionalIT.failed"/>
594                </or>
595            </condition>
596        </fail>
597    </target>
598    <target name="test-perf" depends="test-compile" unless="test-perf.notRequired"
599        description="Run performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
600        <call-junit testfamily="performance" coverage="false"/>
601    </target>
602    <target name="test-perf-hardfail" depends="test-perf" description="Run 'test-perf' target but abort if tests failed">
603        <fail message="'test-perf' failed" if="test.performance.failed"/>
604    </target>
605    <target name="test-html" depends="test, test-it, test-perf" description="Generate HTML test reports">
606        <!-- May require additional ant dependencies like ant-trax package -->
607        <junitreport todir="${test.dir}/report">
608            <fileset dir="${test.dir}/report">
609                <include name="TEST-*.xml"/>
610            </fileset>
611            <report todir="${test.dir}/report/html"/>
612        </junitreport>
613        <jacoco:report>
614            <executiondata>
615                <fileset dir="${test.dir}" includes="*.exec"/>
616            </executiondata>
617            <structure name="JOSM Test Coverage">
618                <classfiles>
619                    <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
620                </classfiles>
621                <sourcefiles encoding="UTF-8">
622                    <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
623                </sourcefiles>
624            </structure>
625            <html destdir="${test.dir}/report/jacoco"/>
626        </jacoco:report>
627    </target>
628    <target name="dist-optimized" depends="dist" unless="isJava11">
629        <taskdef resource="proguard/ant/task.properties" classpath="${tools.dir}/proguard.jar"/>
630        <proguard>
631        -injars ${dist.jar}
632        -outjars ${dist-optimized.jar}
633
634        -libraryjars ${java.home}/${java.library.dir}
635
636        -dontoptimize
637        -dontobfuscate
638
639        # These options probably are not necessary (and make processing a bit slower)
640        -dontskipnonpubliclibraryclasses
641        -dontskipnonpubliclibraryclassmembers
642
643        -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
644            public static void main(java.lang.String[]);
645        }
646
647        -keep class * extends org.openstreetmap.josm.io.FileImporter
648        -keep class * extends org.openstreetmap.josm.io.FileExporter
649        -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
650        -keep class org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory$PseudoClasses {
651            static boolean *(org.openstreetmap.josm.gui.mappaint.Environment);
652        }
653        -keep class org.apache.commons.logging.impl.*
654
655        -keepclassmembers enum  * {
656            public static **[] values();
657            public static ** valueOf(java.lang.String);
658        }
659
660        # Keep unused public classes and methods (needed for plugins)
661        -keep public class * {
662            public protected *;
663        }
664
665        # Keep serialization code
666        -keepclassmembers class * implements java.io.Serializable {
667            static final long serialVersionUID;
668            private static final java.io.ObjectStreamField[] serialPersistentFields;
669            private void writeObject(java.io.ObjectOutputStream);
670            private void readObject(java.io.ObjectInputStream);
671            java.lang.Object writeReplace();
672            java.lang.Object readResolve();
673        }
674
675        # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
676        # This note should not be a problem as we don't use obfuscation
677        -dontnote
678        </proguard>
679    </target>
680    <target name="dist-optimized-report" depends="dist-optimized">
681        <!-- generate difference report between optimized jar and normal one -->
682        <exec executable="perl" dir="${basedir}">
683            <arg value="${tools.dir}/japicc/japi-compliance-checker.pl"/>
684            <arg value="--lib=JOSM"/>
685            <arg value="--keep-internal"/>
686            <arg value="--v1=${version.entry.commit.revision}"/>
687            <arg value="--v2=${version.entry.commit.revision}-optimized"/>
688            <arg value="--report-path=${dist.dir}/compat_report.html"/>
689            <arg value="${dist.jar}"/>
690            <arg value="${dist-optimized.jar}"/>
691        </exec>
692    </target>
693    <target name="check-plugins" depends="dist-optimized" description="Check of plugins binary compatibility" unless="isJava11">
694        <local name="dir"/>
695        <local name="plugins"/>
696        <property name="dir" value="plugin-check"/>
697        <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
698            <classpath path="${tools.dir}/animal-sniffer-ant-tasks.jar"/>
699        </typedef>
700        <delete dir="${dir}" failonerror="false"/>
701        <mkdir dir="${dir}"/>
702        <!-- List of deprecated plugins -->
703        <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
704            <filterchain>
705                <linecontains>
706                    <contains value="new DeprecatedPlugin("/>
707                </linecontains>
708                <tokenfilter>
709                    <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
710                </tokenfilter>
711                <striplinebreaks/>
712                <tokenfilter>
713                    <replaceregex pattern="\|$" replace="" flags="gi"/>
714                </tokenfilter>
715            </filterchain>
716        </loadfile>
717        <!-- Download list of plugins -->
718        <loadresource property="plugins">
719            <url url="https://josm.openstreetmap.de/plugin"/>
720            <filterchain>
721                <linecontainsregexp negate="true">
722                    <regexp pattern="^\t.*"/>
723                </linecontainsregexp>
724                <linecontainsregexp negate="true">
725                    <regexp pattern="${deprecated-plugins}"/>
726                </linecontainsregexp>
727                <linecontainsregexp negate="true" unless:set="isJava10">
728                    <!-- Skip javafx on Java 8/9, built for Java 10+ only -->
729                    <regexp pattern="javafx.*"/>
730                </linecontainsregexp>
731                <tokenfilter>
732                    <replaceregex pattern="^.*;" replace="" flags="gi"/>
733                </tokenfilter>
734            </filterchain>
735        </loadresource>
736        <!-- Delete files that are not in plugin list (like old plugins) -->
737        <loadresource property="file-list">
738            <propertyresource name="plugins"/>
739            <filterchain>
740                <tokenfilter>
741                    <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
742                </tokenfilter>
743                <striplinebreaks/>
744                <tokenfilter>
745                    <replaceregex pattern="\|$" replace="" flags="gi"/>
746                </tokenfilter>
747            </filterchain>
748        </loadresource>
749        <delete>
750            <restrict>
751                <fileset dir="${dir}"/>
752                <not>
753                    <name regex="${file-list}"/>
754                </not>
755            </restrict>
756        </delete>
757        <!-- Download plugins -->
758        <copy todir="${dir}" flatten="true" verbose="true" failonerror="false">
759            <resourcelist>
760                <string value="${plugins}"/>
761            </resourcelist>
762        </copy>
763        <!-- Check plugins -->
764        <as:build-signatures destfile="${dir}/api.sig">
765            <path>
766                <fileset file="${dist-optimized.jar}"/>
767                <fileset file="${java.home}/lib/rt.jar" unless:set="isJava9"/>
768                <fileset file="${java.home}/lib/jce.jar" unless:set="isJava9"/>
769                <fileset file="${java.home}/lib/ext/jfxrt.jar" unless:set="isJava9"/>
770                <fileset dir="${java.home}/jmods" if:set="isJava9"/>
771                <fileset dir="/usr/share/openjfx/lib" unless:set="isJava9"/>
772            </path>
773        </as:build-signatures>
774        <as:check-signature signature="${dir}/api.sig" failonerror="false">
775            <ignore classname="afu.*"/>
776            <ignore classname="android.*"/>
777            <ignore classname="au.*"/>
778            <ignore classname="com.*"/>
779            <ignore classname="de.*"/>
780            <ignore classname="edu.*"/>
781            <ignore classname="groovy.*"/>
782            <ignore classname="io.*"/>
783            <ignore classname="it.*"/>
784            <ignore classname="java.lang.invoke.MethodHandle"/>
785            <ignore classname="javax.*"/>
786            <ignore classname="jdk.swing.interop.*"/>
787            <ignore classname="jogamp.*"/>
788            <ignore classname="junit.*"/>
789            <ignore classname="kdu_jni.*"/>
790            <ignore classname="net.*"/>
791            <ignore classname="netscape.*"/>
792            <ignore classname="nu.*"/>
793            <ignore classname="oracle.*"/>
794            <ignore classname="org.apache.*"/>
795            <ignore classname="org.bouncycastle.*"/>
796            <ignore classname="org.checkerframework.*"/>
797            <ignore classname="org.codehaus.*"/>
798            <ignore classname="org.conscrypt.*"/>
799            <ignore classname="org.dom4j.*"/>
800            <ignore classname="org.eclipse.*"/>
801            <ignore classname="org.ejml.*"/>
802            <ignore classname="org.fusesource.*"/>
803            <ignore classname="org.gdal.*"/>
804            <ignore classname="org.hibernate.*"/>
805            <ignore classname="org.hsqldb.*"/>
806            <ignore classname="org.ibex.*"/>
807            <ignore classname="org.iso_relax.*"/>
808            <ignore classname="org.jaitools.*"/>
809            <ignore classname="org.jaxen.*"/>
810            <ignore classname="org.jboss.*"/>
811            <ignore classname="org.jctools.*"/>
812            <ignore classname="org.jdom.*"/>
813            <ignore classname="org.jdom2.*"/>
814            <ignore classname="org.jfree.*"/>
815            <ignore classname="org.jgraph.*"/>
816            <ignore classname="org.joda.*"/>
817            <ignore classname="org.json.*"/>
818            <ignore classname="org.junit.*"/>
819            <ignore classname="org.jvnet.*"/>
820            <ignore classname="org.kxml2.*"/>
821            <ignore classname="org.objectweb.*"/>
822            <ignore classname="org.osgi.*"/>
823            <ignore classname="org.postgresql.*"/>
824            <ignore classname="org.python.*"/>
825            <ignore classname="org.seasar.*"/>
826            <ignore classname="org.slf4j.*"/>
827            <ignore classname="org.springframework.*"/>
828            <ignore classname="org.testng.*"/>
829            <ignore classname="org.w3c.*"/>
830            <ignore classname="org.zeromq.*"/>
831            <!-- plugins used by another ones -->
832            <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
833            <ignore classname="org.openstreetmap.josm.plugins.jaxb.*"/>
834            <ignore classname="org.openstreetmap.josm.plugins.jna.*"/>
835            <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
836            <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
837            <ignore classname="org.openstreetmap.josm.plugins.openjfx.*"/>
838            <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
839            <ignore classname="sun.*"/>
840            <path path="${dir}"/>
841        </as:check-signature>
842    </target>
843
844    <target name="taginfo-compile" depends="dist">
845        <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true" includes="TagInfoExtract.java"
846               destdir="${taginfo-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
847               includeantruntime="false" createMissingPackageInfoClass="false"
848               encoding="UTF-8" classpath="${build.dir}">
849        </javac>
850    </target>
851
852    <macrodef name="_taginfo">
853        <attribute name="type"/>
854        <attribute name="output"/>
855        <sequential>
856            <echo message="Generating Taginfo for type @{type} to @{output}"/>
857            <java classname="TagInfoExtract" failonerror="true" fork="false">
858                <sysproperty key="java.awt.headless" value="true"/>
859                <classpath>
860                    <pathelement path="${dist.jar}"/>
861                    <pathelement path="${taginfo-build.dir}"/>
862                </classpath>
863                <arg value="--type"/>
864                <arg value="@{type}"/>
865                <arg value="--noexit"/>
866                <arg value="--imgurlprefix"/>
867                <arg value="http://josm.openstreetmap.de/download/taginfo/taginfo-img"/>
868                <arg value="--output"/>
869                <arg value="@{output}"/>
870            </java>
871        </sequential>
872    </macrodef>
873
874    <target name="taginfo" depends="taginfo-compile">
875        <_taginfo type="mappaint" output="taginfo_style.json"/>
876        <_taginfo type="presets" output="taginfo_presets.json"/>
877        <_taginfo type="external_presets" output="taginfo_external_presets.json"/>
878    </target>
879
880    <target name="imageryindex" depends="init-properties">
881        <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath"/>
882        <echo message="Checking editor imagery difference"/>
883        <groovy src="scripts/SyncEditorLayerIndex.groovy" classpath="${dist.jar}">
884                <arg value="-noeli"/>
885                <arg value="-p"/>
886                <arg value="imagery_eliout.imagery.xml"/>
887                <arg value="-q"/>
888                <arg value="imagery_josmout.imagery.xml"/>
889        </groovy>
890    </target>
891
892    <target name="imageryindexdownload">
893        <exec append="false" executable="wget" failifexecutionfails="true">
894            <arg value="https://josm.openstreetmap.de/maps"/>
895            <arg value="-O"/>
896            <arg value="imagery_josm.imagery.xml"/>
897            <arg value="--unlink"/>
898        </exec>
899        <exec append="false" executable="wget" failifexecutionfails="true">
900            <arg value="https://josm.openstreetmap.de/wiki/ImageryCompareIgnores?format=txt"/>
901            <arg value="-O"/>
902            <arg value="imagery_josm.ignores.txt"/>
903            <arg value="--unlink"/>
904        </exec>
905        <exec append="false" executable="wget" failifexecutionfails="true">
906            <arg value="https://raw.githubusercontent.com/osmlab/editor-layer-index/gh-pages/imagery.geojson"/>
907            <arg value="-O"/>
908            <arg value="imagery_eli.geojson"/>
909            <arg value="--unlink"/>
910        </exec>
911        <antcall target="imageryindex"/>
912    </target>
913
914    <target name="checkstyle-compile" depends="init-properties">
915        <mkdir dir="${checkstyle-build.dir}"/>
916        <javac sourcepath="" srcdir="${checkstyle.dir}/src" failonerror="true"
917            destdir="${checkstyle-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
918            includeantruntime="false" createMissingPackageInfoClass="false"
919            encoding="UTF-8" classpath="${checkstyle.dir}/checkstyle-all.jar">
920        </javac>
921    </target>
922    <target name="checkstyle-changed" depends="checkstyle-compile">
923        <exec append="false" osfamily="unix" executable="bash" failifexecutionfails="true">
924            <arg value="-c"/>
925            <arg value="svn status -q --ignore-externals src test | grep -o '\(src\|test\)/.*' | xargs java -cp '${checkstyle.dir}/checkstyle-all.jar:${checkstyle-build.dir}' com.puppycrawl.tools.checkstyle.Main -c ${checkstyle.dir}/josm_checks.xml | sed -e 's:\([^ ]*\) [^:]*/\([^:/]*.java\:[^:]*\):(\2)\1:'"/>
926        </exec>
927        <exec append="false" osfamily="windows" executable="powershell" failifexecutionfails="true">
928            <arg value="/c"/>
929            <arg value="svn status -q --ignore-externals src test | ForEach-Object {java -cp '${checkstyle.dir}/checkstyle-all.jar;${checkstyle-build.dir}' com.puppycrawl.tools.checkstyle.Main -c ${checkstyle.dir}/josm_checks.xml $_.split(' ')[7]}"/>
930        </exec>
931    </target>
932    <target name="checkstyle" depends="checkstyle-compile">
933        <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
934             classpath="${checkstyle.dir}/checkstyle-all.jar:${checkstyle-build.dir}"/>
935        <checkstyle config="${checkstyle.dir}/josm_checks.xml">
936            <fileset dir="${base.dir}/src/org/openstreetmap/josm" includes="**/*.java"
937                excludes="gui/mappaint/mapcss/parsergen/*.java"/>
938            <fileset dir="${base.dir}/test" includes="**/*.java"/>
939            <fileset dir="${base.dir}/scripts" includes="**/*.java"/>
940            <formatter type="plain"/>
941            <formatter type="xml" toFile="checkstyle-josm.xml"/>
942        </checkstyle>
943    </target>
944
945    <target name="spotbugs" depends="dist">
946        <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${spotbugs.dir}/spotbugs-ant.jar"/>
947        <path id="spotbugs-classpath">
948            <fileset dir="${spotbugs.dir}">
949                <include name="*.jar"/>
950            </fileset>
951        </path>
952        <property name="spotbugs-classpath" refid="spotbugs-classpath"/>
953        <spotbugs output="xml"
954                outputFile="spotbugs-josm.xml"
955                classpath="${spotbugs-classpath}"
956                pluginList=""
957                excludeFilter="${spotbugs.dir}/josm-filter.xml"
958                effort="max"
959                reportLevel="low"
960                >
961            <sourcePath path="${base.dir}/src" />
962            <class location="${dist.jar}" />
963        </spotbugs>
964    </target>
965
966    <target name="pmd" depends="init-properties">
967        <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpath="${toString:pmd.classpath}"/>
968        <pmd shortFilenames="true" cacheLocation="${pmd.dir}/cache" encoding="UTF-8">
969            <sourceLanguage name="java" version="${java.lang.version}" />
970            <ruleset>${pmd.dir}/josm-ruleset.xml</ruleset>
971            <formatter type="text" toConsole="true" />
972            <formatter type="xml" toFile="pmd-josm.xml">
973                <param name="encoding" value="UTF-8" />
974            </formatter>
975            <fileset dir="${src.dir}">
976                <include name="org/openstreetmap/josm/**/*.java"/>
977                <exclude name="org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/*.java" />
978            </fileset>
979            <fileset dir="${base.dir}/scripts" includes="**/*.java"/>
980        </pmd>
981    </target>
982
983    <target name="run" depends="dist">
984        <java jar="${dist.jar}" fork="true">
985            <arg value="--set=expert=true"/>
986            <arg value="--set=remotecontrol.enabled=true"/>
987            <arg value="--set=debug.edt-checker.enable=false"/>
988            <jvmarg value="-Djosm.home=/tmp/.josm/"/>
989        </java>
990    </target>
991    <!--
992      ** Compile build script for generating projection list.
993    -->
994    <target name="epsg-compile" depends="init-properties">
995        <property name="proj-classpath" location="${build.dir}"/>
996        <mkdir dir="${proj-build.dir}"/>
997        <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true" includes="BuildProjectionDefinitions.java"
998            destdir="${proj-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
999            includeantruntime="false" createMissingPackageInfoClass="false"
1000            encoding="UTF-8" classpath="${proj-classpath}">
1001        </javac>
1002    </target>
1003    <!--
1004      ** generate projection list.
1005    -->
1006    <target name="epsg" depends="epsg-compile">
1007        <touch file="${epsg.output}" mkdirs="true"/>
1008        <java classname="BuildProjectionDefinitions" failonerror="true" fork="true">
1009            <sysproperty key="java.awt.headless" value="true"/>
1010            <classpath>
1011                <pathelement path="${base.dir}"/>
1012                <pathelement path="${proj-classpath}"/>
1013                <pathelement path="${proj-build.dir}"/>
1014            </classpath>
1015            <arg value="${base.dir}"/>
1016        </java>
1017    </target>
1018    <!--
1019      ** update projection test files after an update of projection definitions
1020    -->
1021    <target name="update-proj-files" depends="test-compile">
1022        <java classname="org.openstreetmap.josm.data.projection.ProjectionRefTest" failonerror="true" fork="true">
1023            <classpath>
1024                <path refid="test.classpath"/>
1025                <pathelement path="${test.dir}/build/unit"/>
1026            </classpath>
1027        </java>
1028        <java classname="org.openstreetmap.josm.data.projection.ProjectionRegressionTest" failonerror="true" fork="true">
1029            <classpath>
1030                <path refid="test.classpath"/>
1031                <pathelement path="${test.dir}/build/unit"/>
1032            </classpath>
1033        </java>
1034    </target>
1035    <!--
1036      ** generate jdeps dependency graph
1037    -->
1038    <target name="jdeps" depends="compile">
1039        <delete dir="${modules.dir}"/>
1040        <mkdir dir="${modules.dir}"/>
1041        <!-- JOSM only -->
1042        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-actions.jar" includes="org/openstreetmap/josm/actions/**/*.class"/>
1043        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-cli.jar" includes="org/openstreetmap/josm/cli/**/*.class"/>
1044        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-command.jar" includes="org/openstreetmap/josm/command/**/*.class"/>
1045        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-data.jar" includes="org/openstreetmap/josm/data/**/*.class"/>
1046        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-gui.jar" includes="org/openstreetmap/josm/gui/**/*.class"/>
1047        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-io.jar" includes="org/openstreetmap/josm/io/**/*.class"/>
1048        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-plugins.jar" includes="org/openstreetmap/josm/plugins/**/*.class"/>
1049        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-spi.jar" includes="org/openstreetmap/josm/spi/**/*.class"/>
1050        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-tools.jar" includes="org/openstreetmap/josm/tools/**/*.class"/>
1051        <exec executable="jdeps" dir="${modules.dir}">
1052            <arg line="-f 'java.*|org.xml.*|org.w3c.*|sun.*|com.*|oauth.*|org.apache.*|org.glassfish.*|org.jdesktop.*|org.openstreetmap.gui.*'"/>
1053            <arg line="-dotoutput dots *.jar"/>
1054        </exec>
1055        <exec executable="dot" dir="${modules.dir}/dots">
1056            <arg line="-O -Tpng summary.dot"/>
1057        </exec>
1058        <move file="${modules.dir}/dots/summary.dot.png" tofile="${modules.dir}/josm-without-dependencies.png"/>
1059        <!-- Direct dependencies -->
1060        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/metadata-extractor.jar" includes="com/drew/**/*.class"/>
1061        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/svgSalamander.jar" includes="com/kitfox/**/*.class"/>
1062        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/javax-json.jar" includes="javax/**/*.class"/>
1063        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/oauth-signpost.jar" includes="oauth/**/*.class"/>
1064        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/commons-compress.jar" includes="org/apache/commons/compress/**/*.class"/>
1065        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/commons-jcs.jar" includes="org/apache/commons/jcs/**/*.class"/>
1066        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/glassfish-json.jar" includes="org/glassfish/**/*.class"/>
1067        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/jdesktop.jar" includes="org/jdesktop/**/*.class"/>
1068        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/jmapviewer.jar" includes="org/openstreetmap/gui/**/*.class"/>
1069        <exec executable="jdeps" dir="${modules.dir}">
1070            <arg line="-f 'java.*|org.xml.*|org.w3c.*|sun.*|com.sun.*|com.google.*|org.tukaani.*|org.apache.commons.logging.*'"/>
1071            <arg line="-dotoutput dots *.jar"/>
1072        </exec>
1073        <exec executable="dot" dir="${modules.dir}/dots">
1074            <arg line="-O -Tpng summary.dot"/>
1075        </exec>
1076        <move file="${modules.dir}/dots/summary.dot.png" tofile="${modules.dir}/josm-with-direct-dependencies.png"/>
1077        <!-- All dependencies -->
1078        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/commons-logging.jar" includes="org/apache/commons/logging/**/*.class"/>
1079        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/google-gdata.jar" includes="com/google/**/*.class"/>
1080        <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/tukaani-xz.jar" includes="org/tukaani/**/*.class"/>
1081        <exec executable="jdeps" dir="${modules.dir}">
1082            <arg line="-dotoutput dots *.jar"/>
1083        </exec>
1084        <exec executable="dot" dir="${modules.dir}/dots">
1085            <arg line="-O -Tpng summary.dot"/>
1086        </exec>
1087        <move file="${modules.dir}/dots/summary.dot.png" tofile="${modules.dir}/josm-with-all-dependencies.png"/>
1088    </target>
1089</project>
Note: See TracBrowser for help on using the repository browser.