source: josm/trunk/build.xml@ 17513

Last change on this file since 17513 was 17493, checked in by stoecker, 4 years ago

fix #20202 - add parameter for release builds with ant

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