source: josm/trunk/build.xml@ 16283

Last change on this file since 16283 was 16243, checked in by simon04, 5 years ago

see #16860 - Apache Ivy: tune logging

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