source: josm/trunk/build.xml@ 17406

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

see #16567 - JUnit 5: enable parallel execution mode with command line parameters

See https://junit.org/junit5/docs/snapshot/user-guide/index.html#writing-tests-parallel-execution

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