source: josm/trunk/build.xml@ 16219

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

see #16860 - Apache Ivy: exclude various commons-jcs classes from inclusion

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