source: josm/trunk/build.xml@ 19069

Last change on this file since 19069 was 19050, checked in by taylor.smock, 8 months ago

Revert most var changes from r19048, fix most new compile warnings and checkstyle issues

Also, document why various ErrorProne checks were originally disabled and fix
generic SonarLint issues.

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