source: josm/trunk/build.xml@ 16896

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

see #19117 - ant test-unit-hardfail depends on resolve

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