source: josm/trunk/build.xml@ 16167

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

see #16860 - Separate tools/ivy.xml

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