source: josm/trunk/build.xml@ 16023

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

see #16860 - Resolve org.apache.commons:commons-compress via Apache Ivy

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