source: josm/trunk/build.xml@ 16589

Last change on this file since 16589 was 16571, checked in by simon04, 4 years ago

see #19334 - Use error_prone javac via ivy:cachepath

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