source: josm/trunk/build.xml@ 18051

Last change on this file since 18051 was 17971, checked in by Don-vip, 3 years ago

fix #21059 - see #19724 - export java.base/sun.security.action to unnamed module

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