source: josm/trunk/build.xml@ 17659

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

see #20632, #20635 - Tag2Link: exclude unused META-INF/resources

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