source: josm/trunk/build.xml@ 16397

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

fix #19173 - JCS LogManager needs META-INF/services/org.apache.commons.jcs.log.LogFactory

org.apache.commons.jcs.log.JulLogFactory is loaded using ServiceLoader and needs to be registered in the META-INF/services file.

  • Property svn:eol-style set to native
File size: 63.3 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 -keep class org.apache.commons.logging.impl.*
607
608 -keepclassmembers enum * {
609 public static **[] values();
610 public static ** valueOf(java.lang.String);
611 }
612
613 # Keep unused public classes and methods (needed for plugins)
614 -keep public class * {
615 public protected *;
616 }
617
618 # Keep serialization code
619 -keepclassmembers class * implements java.io.Serializable {
620 static final long serialVersionUID;
621 private static final java.io.ObjectStreamField[] serialPersistentFields;
622 private void writeObject(java.io.ObjectOutputStream);
623 private void readObject(java.io.ObjectInputStream);
624 java.lang.Object writeReplace();
625 java.lang.Object readResolve();
626 }
627
628 # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
629 # This note should not be a problem as we don't use obfuscation
630 -dontnote
631 </proguard>
632 </target>
633 <target name="dist-optimized-report" depends="dist-optimized">
634 <!-- generate difference report between optimized jar and normal one -->
635 <exec executable="perl" dir="${basedir}">
636 <arg value="${tools.dir}/japicc/japi-compliance-checker.pl"/>
637 <arg value="--lib=JOSM"/>
638 <arg value="--keep-internal"/>
639 <arg value="--v1=${version.entry.commit.revision}"/>
640 <arg value="--v2=${version.entry.commit.revision}-optimized"/>
641 <arg value="--report-path=${dist.dir}/compat_report.html"/>
642 <arg value="${dist.jar}"/>
643 <arg value="${dist-optimized.jar}"/>
644 </exec>
645 </target>
646 <target name="check-plugins" depends="dist-optimized" description="Check of plugins binary compatibility" unless="isJava11">
647 <local name="dir"/>
648 <local name="plugins"/>
649 <property name="dir" value="plugin-check"/>
650 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
651 <classpath path="${tools.dir}/animal-sniffer-ant-tasks.jar"/>
652 </typedef>
653 <delete dir="${dir}" failonerror="false"/>
654 <mkdir dir="${dir}"/>
655 <!-- List of deprecated plugins -->
656 <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
657 <filterchain>
658 <linecontains>
659 <contains value="new DeprecatedPlugin("/>
660 </linecontains>
661 <tokenfilter>
662 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
663 </tokenfilter>
664 <striplinebreaks/>
665 <tokenfilter>
666 <replaceregex pattern="\|$" replace="" flags="gi"/>
667 </tokenfilter>
668 </filterchain>
669 </loadfile>
670 <!-- Download list of plugins -->
671 <loadresource property="plugins">
672 <url url="https://josm.openstreetmap.de/plugin"/>
673 <filterchain>
674 <linecontainsregexp negate="true">
675 <regexp pattern="^\t.*"/>
676 </linecontainsregexp>
677 <linecontainsregexp negate="true">
678 <regexp pattern="${deprecated-plugins}"/>
679 </linecontainsregexp>
680 <linecontainsregexp negate="true" unless:set="isJava10">
681 <!-- Skip javafx on Java 8/9, built for Java 10+ only -->
682 <regexp pattern="javafx.*"/>
683 </linecontainsregexp>
684 <linecontainsregexp negate="true" unless:set="isJava11">
685 <!-- Skip http2 on Java 8/9/10, built for Java 11+ only -->
686 <regexp pattern="http2.*"/>
687 </linecontainsregexp>
688 <tokenfilter>
689 <replaceregex pattern="^.*;" replace="" flags="gi"/>
690 </tokenfilter>
691 </filterchain>
692 </loadresource>
693 <!-- Delete files that are not in plugin list (like old plugins) -->
694 <loadresource property="file-list">
695 <propertyresource name="plugins"/>
696 <filterchain>
697 <tokenfilter>
698 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
699 </tokenfilter>
700 <striplinebreaks/>
701 <tokenfilter>
702 <replaceregex pattern="\|$" replace="" flags="gi"/>
703 </tokenfilter>
704 </filterchain>
705 </loadresource>
706 <delete>
707 <restrict>
708 <fileset dir="${dir}"/>
709 <not>
710 <name regex="${file-list}"/>
711 </not>
712 </restrict>
713 </delete>
714 <!-- Download plugins -->
715 <copy todir="${dir}" flatten="true" verbose="true" failonerror="false">
716 <resourcelist>
717 <string value="${plugins}"/>
718 </resourcelist>
719 </copy>
720 <!-- Check plugins -->
721 <as:build-signatures destfile="${dir}/api.sig">
722 <path>
723 <fileset file="${dist-optimized.jar}"/>
724 <fileset file="${java.home}/lib/rt.jar" unless:set="isJava9"/>
725 <fileset file="${java.home}/lib/jce.jar" unless:set="isJava9"/>
726 <fileset file="${java.home}/lib/ext/jfxrt.jar" unless:set="isJava9"/>
727 <fileset dir="${java.home}/jmods" if:set="isJava9"/>
728 <fileset dir="/usr/share/openjfx/lib" unless:set="isJava9"/>
729 </path>
730 </as:build-signatures>
731 <as:check-signature signature="${dir}/api.sig" failonerror="false">
732 <ignore classname="afu.*"/>
733 <ignore classname="android.*"/>
734 <ignore classname="au.*"/>
735 <ignore classname="com.*"/>
736 <ignore classname="de.*"/>
737 <ignore classname="edu.*"/>
738 <ignore classname="groovy.*"/>
739 <ignore classname="io.*"/>
740 <ignore classname="it.*"/>
741 <ignore classname="java.lang.invoke.MethodHandle"/>
742 <ignore classname="java.nio.ByteBuffer"/>
743 <ignore classname="java.nio.FloatBuffer"/>
744 <ignore classname="java.util.list.kotlin.*"/>
745 <ignore classname="javax.*"/>
746 <ignore classname="jdk.swing.interop.*"/>
747 <ignore classname="jogamp.*"/>
748 <ignore classname="junit.*"/>
749 <ignore classname="kdu_jni.*"/>
750 <ignore classname="kotlin.*"/>
751 <ignore classname="net.*"/>
752 <ignore classname="netscape.*"/>
753 <ignore classname="nu.*"/>
754 <ignore classname="oracle.*"/>
755 <ignore classname="org.apache.*"/>
756 <ignore classname="org.bouncycastle.*"/>
757 <ignore classname="org.checkerframework.*"/>
758 <ignore classname="org.codehaus.*"/>
759 <ignore classname="org.conscrypt.*"/>
760 <ignore classname="org.dom4j.*"/>
761 <ignore classname="org.eclipse.*"/>
762 <ignore classname="org.ejml.*"/>
763 <ignore classname="org.fusesource.*"/>
764 <ignore classname="org.gdal.*"/>
765 <ignore classname="org.geotools.data.h2.*"/>
766 <ignore classname="org.geotools.gce.imagemosaic.*"/>
767 <ignore classname="org.hibernate.*"/>
768 <ignore classname="org.hsqldb.*"/>
769 <ignore classname="org.ibex.*"/>
770 <ignore classname="org.iso_relax.*"/>
771 <ignore classname="org.jaitools.*"/>
772 <ignore classname="org.jaxen.*"/>
773 <ignore classname="org.jboss.*"/>
774 <ignore classname="org.jctools.*"/>
775 <ignore classname="org.jdom.*"/>
776 <ignore classname="org.jdom2.*"/>
777 <ignore classname="org.jfree.*"/>
778 <ignore classname="org.jgraph.*"/>
779 <ignore classname="org.joda.*"/>
780 <ignore classname="org.json.*"/>
781 <ignore classname="org.junit.*"/>
782 <ignore classname="org.jvnet.*"/>
783 <ignore classname="org.kxml2.*"/>
784 <ignore classname="org.locationtech.*"/>
785 <ignore classname="org.mozilla.*"/>
786 <ignore classname="org.objectweb.*"/>
787 <ignore classname="org.opentest4j.*"/>
788 <ignore classname="org.osgi.*"/>
789 <ignore classname="org.postgresql.*"/>
790 <ignore classname="org.python.*"/>
791 <ignore classname="org.seasar.*"/>
792 <ignore classname="org.slf4j.*"/>
793 <ignore classname="org.springframework.*"/>
794 <ignore classname="org.testng.*"/>
795 <ignore classname="org.w3c.*"/>
796 <ignore classname="org.zeromq.*"/>
797 <ignore classname="waffle.*"/>
798 <!-- plugins used by another ones -->
799 <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
800 <ignore classname="org.openstreetmap.josm.plugins.jaxb.*"/>
801 <ignore classname="org.openstreetmap.josm.plugins.jna.*"/>
802 <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
803 <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
804 <ignore classname="org.openstreetmap.josm.plugins.openjfx.*"/>
805 <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
806 <ignore classname="sun.*"/>
807 <path path="${dir}"/>
808 </as:check-signature>
809 </target>
810
811 <target name="script-compile" depends="test-compile" description="Compiles all scripts">
812 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true" includes="*.java"
813 destdir="${script-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
814 includeantruntime="false" encoding="UTF-8">
815 <classpath>
816 <pathelement path="${build.dir}"/>
817 <pathelement path="${test.dir}/build/unit"/>
818 <pathelement path="${commons-lang3.jar}"/>
819 </classpath>
820 </javac>
821 </target>
822
823 <macrodef name="_taginfo">
824 <attribute name="type"/>
825 <attribute name="output"/>
826 <sequential>
827 <echo message="Generating Taginfo for type @{type} to @{output}"/>
828 <java classname="TagInfoExtract" failonerror="true" fork="false">
829 <sysproperty key="java.awt.headless" value="true"/>
830 <classpath>
831 <pathelement path="${build.dir}"/>
832 <pathelement path="${script-build.dir}"/>
833 <pathelement path="${commons-lang3.jar}"/>
834 </classpath>
835 <arg value="--type"/>
836 <arg value="@{type}"/>
837 <arg value="--noexit"/>
838 <arg value="--imgurlprefix"/>
839 <arg value="http://josm.openstreetmap.de/download/taginfo/taginfo-img"/>
840 <arg value="--output"/>
841 <arg value="@{output}"/>
842 </java>
843 </sequential>
844 </macrodef>
845
846 <target name="taginfo" depends="script-compile">
847 <_taginfo type="mappaint" output="taginfo_style.json"/>
848 <_taginfo type="presets" output="taginfo_presets.json"/>
849 <_taginfo type="external_presets" output="taginfo_external_presets.json"/>
850 </target>
851
852 <target name="imageryindex" depends="init-properties,script-compile">
853 <echo message="Checking editor imagery difference"/>
854 <java classname="SyncEditorLayerIndex" failonerror="true" fork="false">
855 <classpath>
856 <pathelement path="${build.dir}"/>
857 <pathelement path="${script-build.dir}"/>
858 <pathelement path="${commons-lang3.jar}"/>
859 </classpath>
860 <arg value="--noeli"/>
861 <arg value="-p"/>
862 <arg value="imagery_eliout.imagery.xml"/>
863 <arg value="-q"/>
864 <arg value="imagery_josmout.imagery.xml"/>
865 </java>
866 </target>
867
868 <target name="imageryindexdownload">
869 <exec append="false" executable="wget" failifexecutionfails="true">
870 <arg value="https://josm.openstreetmap.de/maps"/>
871 <arg value="-O"/>
872 <arg value="imagery_josm.imagery.xml"/>
873 <arg value="--unlink"/>
874 </exec>
875 <exec append="false" executable="wget" failifexecutionfails="true">
876 <arg value="https://josm.openstreetmap.de/wiki/ImageryCompareIgnores?format=txt"/>
877 <arg value="-O"/>
878 <arg value="imagery_josm.ignores.txt"/>
879 <arg value="--unlink"/>
880 </exec>
881 <exec append="false" executable="wget" failifexecutionfails="true">
882 <arg value="https://raw.githubusercontent.com/osmlab/editor-layer-index/gh-pages/imagery.geojson"/>
883 <arg value="-O"/>
884 <arg value="imagery_eli.geojson"/>
885 <arg value="--unlink"/>
886 </exec>
887 <antcall target="imageryindex"/>
888 </target>
889
890 <target name="checkstyle-compile" depends="init-properties">
891 <ivy:cachepath log="download-only" file="${tools.ivy}" pathid="checkstyle.classpath" conf="checkstyle"/>
892 <mkdir dir="${checkstyle-build.dir}"/>
893 <javac sourcepath="" srcdir="${checkstyle.dir}/src" failonerror="true"
894 destdir="${checkstyle-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
895 includeantruntime="false"
896 encoding="UTF-8" classpathref="checkstyle.classpath">
897 </javac>
898 </target>
899 <target name="checkstyle-changed" depends="checkstyle-compile">
900 <exec append="false" osfamily="unix" executable="bash" failifexecutionfails="true">
901 <arg value="-c"/>
902 <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:'"/>
903 </exec>
904 <exec append="false" osfamily="windows" executable="powershell" failifexecutionfails="true">
905 <arg value="/c"/>
906 <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]}"/>
907 </exec>
908 </target>
909 <target name="checkstyle" depends="checkstyle-compile">
910 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
911 <classpath refid="checkstyle.classpath"/>
912 <classpath path="${checkstyle-build.dir}"/>
913 </taskdef>
914 <checkstyle config="${checkstyle.dir}/josm_checks.xml">
915 <fileset dir="${base.dir}/src/org/openstreetmap/josm" includes="**/*.java"
916 excludes="gui/mappaint/mapcss/parsergen/*.java"/>
917 <fileset dir="${base.dir}/test" includes="**/*.java"/>
918 <fileset dir="${base.dir}/scripts" includes="**/*.java"/>
919 <formatter type="plain"/>
920 <formatter type="xml" toFile="checkstyle-josm.xml"/>
921 </checkstyle>
922 </target>
923
924 <target name="spotbugs" depends="dist">
925 <ivy:cachepath log="download-only" file="${tools.ivy}" pathid="spotbugs.classpath" conf="spotbugs"/>
926 <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="spotbugs.classpath"/>
927 <spotbugs output="xml"
928 outputFile="spotbugs-josm.xml"
929 classpath="${toString:spotbugs.classpath}"
930 pluginList=""
931 excludeFilter="${spotbugs.dir}/josm-filter.xml"
932 onlyAnalyze="org.openstreetmap.josm.-"
933 effort="max"
934 reportLevel="low"
935 >
936 <class location="${dist.jar}" />
937 </spotbugs>
938 </target>
939
940 <target name="pmd" depends="init-properties">
941 <ivy:cachepath log="download-only" file="${tools.ivy}" pathid="pmd.classpath" conf="pmd"/>
942 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
943 <pmd shortFilenames="true" cacheLocation="${pmd.dir}/cache" encoding="UTF-8">
944 <sourceLanguage name="java" version="${java.lang.version}" />
945 <ruleset>${pmd.dir}/josm-ruleset.xml</ruleset>
946 <formatter type="text" toConsole="true" />
947 <formatter type="xml" toFile="pmd-josm.xml">
948 <param name="encoding" value="UTF-8" />
949 </formatter>
950 <fileset dir="${src.dir}">
951 <include name="org/openstreetmap/josm/**/*.java"/>
952 <exclude name="org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/*.java" />
953 </fileset>
954 <fileset dir="${base.dir}/scripts" includes="**/*.java"/>
955 </pmd>
956 </target>
957
958 <target name="run" depends="dist">
959 <java jar="${dist.jar}" fork="true">
960 <arg value="--set=expert=true"/>
961 <arg value="--set=iso.dates=true"/>
962 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
963 </java>
964 </target>
965 <!--
966 ** Compile build script for generating projection list.
967 -->
968 <target name="epsg-compile" depends="init-properties">
969 <property name="proj-classpath" location="${build.dir}"/>
970 <mkdir dir="${proj-build.dir}"/>
971 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true" includes="BuildProjectionDefinitions.java"
972 destdir="${proj-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
973 includeantruntime="false"
974 encoding="UTF-8" classpath="${proj-classpath}">
975 </javac>
976 </target>
977 <!--
978 ** generate projection list.
979 -->
980 <target name="epsg" unless="epsg.notRequired" depends="epsg-compile">
981 <touch file="${epsg.output}" mkdirs="true"/>
982 <java classname="BuildProjectionDefinitions" failonerror="true" fork="true">
983 <sysproperty key="java.awt.headless" value="true"/>
984 <classpath>
985 <pathelement path="${resources.dir}"/>
986 <pathelement path="${proj-classpath}"/>
987 <pathelement path="${proj-build.dir}"/>
988 </classpath>
989 <arg value="${base.dir}"/>
990 </java>
991 </target>
992 <!--
993 ** update projection test files after an update of projection definitions
994 -->
995 <target name="update-proj-files" depends="test-compile">
996 <java classname="org.openstreetmap.josm.data.projection.ProjectionRefTest" failonerror="true" fork="true">
997 <classpath>
998 <path refid="test.classpath"/>
999 <pathelement path="${test.dir}/build/unit"/>
1000 </classpath>
1001 </java>
1002 <java classname="org.openstreetmap.josm.data.projection.ProjectionRegressionTest" failonerror="true" fork="true">
1003 <classpath>
1004 <path refid="test.classpath"/>
1005 <pathelement path="${test.dir}/build/unit"/>
1006 </classpath>
1007 </java>
1008 </target>
1009 <!--
1010 ** generate jdeps dependency graph
1011 -->
1012 <target name="jdeps" depends="compile">
1013 <delete dir="${modules.dir}"/>
1014 <mkdir dir="${modules.dir}"/>
1015 <!-- JOSM only -->
1016 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-actions.jar" includes="org/openstreetmap/josm/actions/**/*.class"/>
1017 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-cli.jar" includes="org/openstreetmap/josm/cli/**/*.class"/>
1018 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-command.jar" includes="org/openstreetmap/josm/command/**/*.class"/>
1019 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-data.jar" includes="org/openstreetmap/josm/data/**/*.class"/>
1020 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-gui.jar" includes="org/openstreetmap/josm/gui/**/*.class"/>
1021 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-io.jar" includes="org/openstreetmap/josm/io/**/*.class"/>
1022 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-plugins.jar" includes="org/openstreetmap/josm/plugins/**/*.class"/>
1023 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-spi.jar" includes="org/openstreetmap/josm/spi/**/*.class"/>
1024 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/josm-tools.jar" includes="org/openstreetmap/josm/tools/**/*.class"/>
1025 <exec executable="jdeps" dir="${modules.dir}">
1026 <arg line="-f 'java.*|org.xml.*|org.w3c.*|sun.*|com.*|oauth.*|org.apache.*|org.glassfish.*|org.openstreetmap.gui.*'"/>
1027 <arg line="-dotoutput dots *.jar"/>
1028 </exec>
1029 <exec executable="dot" dir="${modules.dir}/dots">
1030 <arg line="-O -Tpng summary.dot"/>
1031 </exec>
1032 <move file="${modules.dir}/dots/summary.dot.png" tofile="${modules.dir}/josm-without-dependencies.png"/>
1033 <!-- Direct dependencies -->
1034 <copy todir="${modules.dir}" flatten="true">
1035 <fileset refid="runtime.fileset" />
1036 </copy>
1037 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/svgSalamander.jar" includes="com/kitfox/**/*.class"/>
1038 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/oauth-signpost.jar" includes="oauth/**/*.class"/>
1039 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/commons-jcs.jar" includes="org/apache/commons/jcs/**/*.class"/>
1040 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/jmapviewer.jar" includes="org/openstreetmap/gui/**/*.class"/>
1041 <exec executable="jdeps" dir="${modules.dir}">
1042 <arg line="-f 'java.*|org.xml.*|org.w3c.*|sun.*|com.sun.*|com.google.*|org.tukaani.*|org.apache.commons.logging.*'"/>
1043 <arg line="-dotoutput dots *.jar"/>
1044 </exec>
1045 <exec executable="dot" dir="${modules.dir}/dots">
1046 <arg line="-O -Tpng summary.dot"/>
1047 </exec>
1048 <move file="${modules.dir}/dots/summary.dot.png" tofile="${modules.dir}/josm-with-direct-dependencies.png"/>
1049 <!-- All dependencies -->
1050 <jar basedir="${build.dir}" level="${clevel}" destfile="${modules.dir}/google-gdata.jar" includes="com/google/**/*.class"/>
1051 <exec executable="jdeps" dir="${modules.dir}">
1052 <arg line="-dotoutput dots *.jar"/>
1053 </exec>
1054 <exec executable="dot" dir="${modules.dir}/dots">
1055 <arg line="-O -Tpng summary.dot"/>
1056 </exec>
1057 <move file="${modules.dir}/dots/summary.dot.png" tofile="${modules.dir}/josm-with-all-dependencies.png"/>
1058 </target>
1059 <target name="resolve" depends="init-ivy" unless="resolve.notRequired" description="Resolve Ivy dependencies">
1060 <ivy:settings file="${base.dir}/ivysettings.xml"/>
1061 <ivy:resolve log="download-only" file="${base.dir}/ivy.xml" keep="true"/>
1062 <ivy:cachepath log="download-only" pathid="compile.path" conf="compile"/>
1063 <ivy:cachepath log="download-only" pathid="runtime.path" conf="runtime"/>
1064 <ivy:cachefileset log="download-only" setid="runtime.fileset" conf="runtime"/>
1065 <ivy:cachepath log="download-only" pathid="test.path" conf="test"/>
1066 </target>
1067 <target name="extract-libraries" depends="resolve" description="extract libraries to build dir">
1068 <unzip dest="${build.dir}">
1069 <fileset refid="runtime.fileset"/>
1070 <patternset>
1071 <exclude name="META-INF/*"/>
1072 <exclude name="META-INF/maven/**"/>
1073 <exclude name="META-INF/versions/**"/>
1074 <exclude name="*"/>
1075 <exclude name="org/openstreetmap/gui/jmapviewer/Demo*"/>
1076 <exclude name="com/drew/imaging/FileTypeDetector*"/>
1077 <exclude name="com/drew/imaging/ImageMetadataReader*"/>
1078 <exclude name="com/drew/imaging/avi/**"/>
1079 <exclude name="com/drew/imaging/bmp/**"/>
1080 <exclude name="com/drew/imaging/eps/**"/>
1081 <exclude name="com/drew/imaging/gif/**"/>
1082 <exclude name="com/drew/imaging/heif/**"/>
1083 <exclude name="com/drew/imaging/ico/**"/>
1084 <exclude name="com/drew/imaging/mp3/**"/>
1085 <exclude name="com/drew/imaging/mp4/**"/>
1086 <exclude name="com/drew/imaging/pcx/**"/>
1087 <exclude name="com/drew/imaging/png/**"/>
1088 <exclude name="com/drew/imaging/psd/**"/>
1089 <exclude name="com/drew/imaging/quicktime/**"/>
1090 <exclude name="com/drew/imaging/raf/**"/>
1091 <exclude name="com/drew/imaging/riff/**"/>
1092 <exclude name="com/drew/imaging/wav/**"/>
1093 <exclude name="com/drew/imaging/webp/**"/>
1094 <exclude name="com/drew/metadata/avi/**"/>
1095 <exclude name="com/drew/metadata/bmp/**"/>
1096 <exclude name="com/drew/metadata/eps/**"/>
1097 <exclude name="com/drew/metadata/gif/**"/>
1098 <exclude name="com/drew/metadata/heif/**"/>
1099 <exclude name="com/drew/metadata/ico/**"/>
1100 <exclude name="com/drew/metadata/mov/**"/>
1101 <exclude name="com/drew/metadata/mp3/**"/>
1102 <exclude name="com/drew/metadata/mp4/**"/>
1103 <exclude name="com/drew/metadata/pcx/**"/>
1104 <exclude name="com/drew/metadata/png/**"/>
1105 <exclude name="com/drew/metadata/wav/**"/>
1106 <exclude name="com/drew/metadata/webp/**"/>
1107 <exclude name="com/drew/tools/**"/>
1108 <exclude name="org/apache/commons/compress/PasswordRequiredException*"/>
1109 <exclude name="org/apache/commons/compress/archivers/**"/>
1110 <exclude name="org/apache/commons/compress/changes/**"/>
1111 <exclude name="org/apache/commons/compress/compressors/bzip2/BZip2Utils*"/>
1112 <exclude name="org/apache/commons/compress/compressors/brotli/**"/>
1113 <exclude name="org/apache/commons/compress/compressors/CompressorStreamFactory*"/>
1114 <exclude name="org/apache/commons/compress/compressors/CompressorStreamProvider*"/>
1115 <exclude name="org/apache/commons/compress/compressors/CompressorException*"/>
1116 <exclude name="org/apache/commons/compress/compressors/FileNameUtil*"/>
1117 <exclude name="org/apache/commons/compress/compressors/deflate/**"/>
1118 <exclude name="org/apache/commons/compress/compressors/gzip/**"/>
1119 <exclude name="org/apache/commons/compress/compressors/lz4/**"/>
1120 <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
1121 <exclude name="org/apache/commons/compress/compressors/lz77support/**"/>
1122 <exclude name="org/apache/commons/compress/compressors/pack200/**"/>
1123 <exclude name="org/apache/commons/compress/compressors/snappy/**"/>
1124 <exclude name="org/apache/commons/compress/compressors/xz/XZUtils*"/>
1125 <exclude name="org/apache/commons/compress/compressors/z/**"/>
1126 <exclude name="org/apache/commons/compress/compressors/zstandard/**"/>
1127 <exclude name="org/apache/commons/compress/parallel/**"/>
1128 <exclude name="org/apache/commons/compress/utils/ArchiveUtils*"/>
1129 <exclude name="org/apache/commons/logging/impl/AvalonLogger*"/>
1130 <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger*"/>
1131 <exclude name="org/apache/commons/logging/impl/Log4JLogger*"/>
1132 <exclude name="org/apache/commons/logging/impl/LogKitLogger*"/>
1133 <exclude name="org/apache/commons/logging/impl/ServletContextCleaner*"/>
1134 <exclude name="org/apache/commons/jcs/auxiliary/disk/jdbc/**"/>
1135 <exclude name="org/apache/commons/jcs/auxiliary/remote/http/client/**"/>
1136 <exclude name="org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet*"/>
1137 <exclude name="org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet*"/>
1138 <exclude name="org/apache/commons/jcs/utils/servlet/**"/>
1139 </patternset>
1140 </unzip>
1141 </target>
1142 <target name="sources" description="Generates jar file of JOSM source files and its dependencies" depends="init,epsg,resolve">
1143 <ivy:cachefileset log="download-only" setid="sources.fileset" conf="sources"/>
1144 <jar destfile="${dist-sources.jar}" level="${clevel}">
1145 <zipgroupfileset refid="sources.fileset"/>
1146 <fileset dir="${src.dir}"/>
1147 <fileset dir="${resources.dir}"/>
1148 </jar>
1149 </target>
1150 <target name="bootstrap-workspace" description="Copy libraries from ivy cache to workspace folders for IDE" depends="resolve">
1151 <delete dir="${lib.dir}"/>
1152 <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type].[ext]" conf="compile,runtime,sources,test"/>
1153 <ivy:retrieve pattern="${lib.dir}/tools/[artifact]-[type].[ext]" conf="javacc,checkstyle,pmd,spotbugs" file="${tools.ivy}"/>
1154 </target>
1155 <target name="ivy-report" description="Generates Ivy reports of dependency resolving" depends="resolve">
1156 <ivy:report todir="${tools.dir}/ivy-report" graph="false"/>
1157 </target>
1158 <target name="api-dependency-tree" description="Displays Ivy dependency tree for JOSM API" depends="resolve">
1159 <ivy:dependencytree conf="api"/>
1160 </target>
1161 <target name="test-dependency-tree" description="Displays Ivy dependency tree for JOSM tests" depends="resolve">
1162 <ivy:dependencytree conf="test"/>
1163 </target>
1164</project>
Note: See TracBrowser for help on using the repository browser.