source: josm/trunk/build.xml@ 16474

Last change on this file since 16474 was 16408, checked in by simon04, 5 years ago

see #16860 - build.xml: remove leftovers of org.apache.commons.logging

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