source: josm/trunk/build.xml@ 16556

Last change on this file since 16556 was 16556, checked in by Don-vip, 4 years ago

fix #19334 - Upgrade to error_prone 2.4.0

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