source: josm/trunk/build.xml@ 17717

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

fix #20510 - Default maximum memory setting -Xmx for distribution packages

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