source: josm/trunk/build.xml@ 14655

Last change on this file since 14655 was 14638, checked in by simon04, 5 years ago

Run PMD on scripts/ and apply fixes

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