source: josm/trunk/build.xml@ 16185

Last change on this file since 16185 was 16183, checked in by simon04, 5 years ago

see #16860 - <get> Apache Ivy, remove ivy.jar from repository

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