source: josm/trunk/build.xml@ 18296

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

see #20522 - re-enable Proguard on Java 17+

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