source: josm/trunk/build.xml@ 16002

Last change on this file since 16002 was 16002, checked in by Don-vip, 5 years ago

see #18140 - refactor build

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