source: josm/trunk/build.xml@ 17947

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

see #20921 - JavaCC: get rid of warnings

Use relative OUTPUT_DIRECTORY specified in MapCSSParser.jj

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