source: josm/trunk/build.xml@ 16624

Last change on this file since 16624 was 16624, checked in by simon04, 4 years ago

see #19334 - Use @SuppressWarnings to ignore seldom occurring error-prone warnings

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