source: josm/trunk/build.xml@ 16603

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

see #16860 - Suppress "bad path element .../xmpcore-6.0.6.jar: no such file or directory" warning

  • Property svn:eol-style set to native
File size: 62.4 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!-- ** build.xml - main ant file for JOSM
3**
4** To build run
5** ant clean
6** ant dist
7** This will create 'josm-custom.jar' in directory 'dist'. See also
8** https://josm.openstreetmap.de/wiki/DevelopersGuide/CreateBuild
9**
10-->
11<project name="josm" default="dist"
12 xmlns:as="antlib:org.codehaus.mojo.animal_sniffer"
13 xmlns:if="ant:if"
14 xmlns:ivy="antlib:org.apache.ivy.ant"
15 xmlns:jacoco="antlib:org.jacoco.ant"
16 xmlns:unless="ant:unless"
17>
18 <target name="init-ivy">
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:-path"/><!-- Suppress "bad path element .../xmpcore-6.0.6.jar: no such file or directory" warning, see https://github.com/drewnoakes/metadata-extractor/pull/483 -->
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.