source: josm/trunk/build.xml@ 16746

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

see #16567 - JUnit 5: set -Djunit.jupiter.extensions.autodetection.enabled=true to clear JMockit mocks (patch by taylor.smock)

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