source: josm/trunk/build.xml@ 19039

Last change on this file since 19039 was 18985, checked in by taylor.smock, 9 months ago

Fix #23355: Sanity check JVM arguments on startup

See #17858: JOSM will no longer continue running if the user is on an unsupported
Java version (for this commit, older than Java 11; message indicates Java 17).
This does update the link for Azul from Java 17 to Java 21 as well.

In order to (hopefully) reduce confusion, the webstart and Java update nags will
also be reset in the event that JOSM will exit due to old Java versions. This is
mostly so that users will get the messages to update to OpenWebstart or the
appropriate Java link for their platform and architecture.

Additionally, this will (hopefully) reduce the number of tickets we have to close
due to missing JVM arguments by informing users of the missing arguments at startup.

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