source: josm/trunk/build.xml@ 16140

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

see #18140 - build.xml: use ${resources.dir}

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