source: josm/trunk/build.xml @ 16156

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

see #17516 - see #17827 - see #18755 - Enable Jacoco coverage on Java 13/14/15

upgraded jacocoant to jacoco-0.8.6-20200313.013328-40 snapshot

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