source: josm/trunk/build.xml@ 12369

Last change on this file since 12369 was 12331, checked in by Don-vip, 7 years ago

see #2089 - include jfxrt.jar in ProGuard classpath

  • Property svn:eol-style set to native
File size: 43.1 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">
12 <target name="init-properties">
13 <!-- Load properties in a target and not at top level, so this build file can be
14 imported from an IDE ant file (Netbeans) without messing up IDE properties.
15 When imported from another file, ${basedir} will point to the parent directory
16 of the importing ant file. Use ${base.dir} instead, which is always the parent
17 directory of this file. -->
18 <dirname property="base.dir" file="${ant.file.josm}"/>
19 <property name="test.dir" location="${base.dir}/test"/>
20 <property name="src.dir" location="${base.dir}/src"/>
21 <property name="build.dir" location="${base.dir}/build"/>
22 <property name="dist.dir" location="${base.dir}/dist"/>
23 <property name="javacc.home" location="${base.dir}/tools"/>
24 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
25 <property name="proj-build.dir" location="${base.dir}/build2"/>
26 <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/>
27 <property name="groovy.jar" location="${base.dir}/tools/groovy-all-2.4.11.jar"/>
28 <property name="error_prone_ant.jar" location="${base.dir}/tools/error_prone_ant.jar"/>
29 <property name="javac.compiler" value="com.google.errorprone.ErrorProneAntCompilerAdapter" />
30 <!-- build parameter: compression level (ant -Dclevel=N)
31 N ranges from 0 (no compression) to 9 (maximum compression)
32 default: 9 -->
33 <condition property="clevel" value="${clevel}" else="9">
34 <isset property="clevel"/>
35 </condition>
36 <!-- For Java9-specific stuff -->
37 <condition property="isJava9">
38 <equals arg1="${ant.java.version}" arg2="1.9" />
39 </condition>
40 <path id="test.classpath">
41 <fileset dir="${test.dir}/lib">
42 <include name="**/*.jar"/>
43 </fileset>
44 <pathelement path="${dist.dir}/josm-custom.jar"/>
45 <pathelement path="${groovy.jar}"/>
46 <pathelement path="tools/findbugs/annotations.jar"/>
47 </path>
48 <path id="pmd.classpath">
49 <fileset dir="${base.dir}/tools/pmd/">
50 <include name="*.jar"/>
51 </fileset>
52 </path>
53 </target>
54
55 <!--
56 ** Used by Eclipse ant builder for updating
57 ** the REVISION file used by JOSM
58 -->
59 <target name="create-revision-eclipse">
60 <property name="revision.dir" value="bin"/>
61 <antcall target="create-revision"/>
62 </target>
63 <!--
64 ** Initializes the REVISION.XML file from SVN information
65 -->
66 <target name="init-svn-revision-xml" depends="init-properties">
67 <exec append="false" output="${base.dir}/REVISION.XML" executable="svn" dir="${base.dir}" failifexecutionfails="false" resultproperty="svn.info.result">
68 <env key="LANG" value="C"/>
69 <arg value="info"/>
70 <arg value="--xml"/>
71 <arg value="."/>
72 </exec>
73 <condition property="svn.info.success">
74 <equals arg1="${svn.info.result}" arg2="0" />
75 </condition>
76 </target>
77 <!--
78 ** Initializes the REVISION.XML file from git information
79 -->
80 <target name="init-git-revision-xml" unless="svn.info.success" depends="init-properties">
81 <exec append="false" output="${base.dir}/REVISION.XML" executable="git" dir="${base.dir}" failifexecutionfails="false">
82 <arg value="log"/>
83 <arg value="-1"/>
84 <arg value="--grep=git-svn-id"/>
85 <!--
86 %B: raw body (unwrapped subject and body)
87 %n: new line
88 %ai: author date, ISO 8601 format
89 -->
90 <arg value="--pretty=format:%B%n%ai"/>
91 <arg value="HEAD"/>
92 </exec>
93 <replaceregexp file="${base.dir}/REVISION.XML" flags="s"
94 match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
95 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;"/>
96 </target>
97 <!--
98 ** Creates the REVISION file to be included in the distribution
99 -->
100 <target name="create-revision" depends="init-properties,init-svn-revision-xml,init-git-revision-xml">
101 <property name="revision.dir" value="${build.dir}"/>
102 <xmlproperty file="${base.dir}/REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
103 <delete file="${base.dir}/REVISION.XML"/>
104 <tstamp>
105 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
106 </tstamp>
107 <property name="version.entry.commit.revision" value="UNKNOWN"/>
108 <property name="version.entry.commit.date" value="UNKNOWN"/>
109 <mkdir dir="${revision.dir}"/>
110 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
111 <echo file="${revision.dir}/REVISION">
112# automatically generated by JOSM build.xml - do not edit
113Revision: ${version.entry.commit.revision}
114Is-Local-Build: true
115Build-Date: ${build.tstamp}
116</echo>
117 </target>
118 <!--
119 ** Check internal XML files against their XSD
120 -->
121 <target name="check-schemas" unless="check-schemas.notRequired" depends="init-properties">
122 <schemavalidate file="data/defaultpresets.xml" >
123 <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
124 </schemavalidate>
125 </target>
126 <!--
127 ** Main target that builds JOSM and checks XML against schemas
128 -->
129 <target name="dist" depends="compile,create-revision,check-schemas,epsg">
130 <echo>Revision ${version.entry.commit.revision}</echo>
131 <copy file="CONTRIBUTION" todir="build"/>
132 <copy file="README" todir="build"/>
133 <copy file="LICENSE" todir="build"/>
134 <!-- create josm-custom.jar -->
135 <delete file="${dist.dir}/josm-custom.jar"/>
136 <jar destfile="${dist.dir}/josm-custom.jar" basedir="${build.dir}" level="${clevel}">
137 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
138 <manifest>
139 <attribute name="Main-class" value="org.openstreetmap.josm.gui.MainApplication"/>
140 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
141 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
142 <attribute name="Permissions" value="all-permissions"/>
143 <attribute name="Codebase" value="josm.openstreetmap.de"/>
144 <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
145 <!-- Java 9 stuff. Entries are safely ignored by Java 8 -->
146 <attribute name="Add-Exports" value="java.base/sun.security.util java.desktop/com.apple.eawt java.desktop/com.sun.imageio.spi jdk.deploy/com.sun.deploy.config" />
147 <attribute name="Add-Opens" value="java.base/java.lang java.base/jdk.internal.loader java.base/sun.security.x509 java.desktop/javax.imageio.spi java.desktop/javax.swing.text.html java.prefs/java.util.prefs" />
148 </manifest>
149 <zipfileset dir="images" prefix="images"/>
150 <zipfileset dir="data" prefix="data"/>
151 <zipfileset dir="styles" prefix="styles"/>
152 <zipfileset dir="${src.dir}/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
153 </jar>
154 </target>
155 <!-- Mac OS X target -->
156 <target name="mac" depends="init-properties">
157 <!-- Using https://bitbucket.org/infinitekind/appbundler to create mac application bundle -->
158 <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="tools/appbundler-1.0ea.jar"/>
159 <!-- create MacOS X application bundle -->
160 <bundleapp outputdirectory="${bundle.outdir}" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
161 mainclassname="org.openstreetmap.josm.gui.MainApplication"
162 copyright="JOSM, and all its integral parts, are released under the GNU General Public License v2 or later"
163 applicationCategory="public.app-category.utilities"
164 shortversion="${version.entry.commit.revision} SVN"
165 version="${version.entry.commit.revision} SVN"
166 icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
167 highResolutionCapable="true">
168
169 <arch name="x86_64"/>
170 <arch name="i386"/>
171
172 <classpath file="${bundle.jar}"/>
173
174 <option value="-Xmx1024m"/>
175
176 <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
177 <option value="-Xdock:name=JOSM"/>
178
179 <!-- OSX specific options, optional -->
180 <option value="-Dapple.laf.useScreenMenuBar=true"/>
181 <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
182 <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
183 <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
184 <option value="-Dcom.apple.smallTabs=true"/>
185 </bundleapp>
186
187 <!-- appbundler lacks the possibility of defining our own keys or using a template, so update the .plist manually -->
188 <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="tools/xmltask.jar"/>
189
190 <xmltask source="${bundle.outdir}/JOSM.app/Contents/Info.plist" dest="${bundle.outdir}/JOSM.app/Contents/Info.plist" indent="false">
191 <!-- remove empty CFBundleDocumentTypes definition -->
192 <remove path="/plist/dict/key[text()='CFBundleDocumentTypes']|/plist/dict/key[text()='CFBundleDocumentTypes']/following-sibling::array[1]"/>
193 <!-- insert our own keys -->
194 <insert position="before" path="/plist/dict/key[1]" file="macosx/JOSM.app/Contents/Info.plist_template.xml" />
195 </xmltask>
196
197 <!-- create ZIP file with MacOS X application bundle -->
198 <zip destfile="${bundle.outdir}/josm-custom-macosx.zip" update="true">
199 <zipfileset dir="." includes="CONTRIBUTION README LICENSE"/>
200 <zipfileset dir="${bundle.outdir}" includes="JOSM.app/**/*" filemode="755" />
201 </zip>
202 </target>
203 <target name="distmac" depends="dist">
204 <antcall target="mac">
205 <param name="bundle.outdir" value="${dist.dir}"/>
206 <param name="bundle.jar" value="${dist.dir}/josm-custom.jar"/>
207 </antcall>
208 </target>
209 <!-- Windows target -->
210 <target name="distwin" depends="dist">
211 <exec dir="windows" executable="./josm-setup-unix.sh">
212 <arg value="${version.entry.commit.revision}"/>
213 <arg value="../dist/josm-custom.jar"/>
214 </exec>
215 </target>
216 <target name="javacc" depends="init" unless="javacc.notRequired">
217 <mkdir dir="${mapcss.dir}/parsergen"/>
218 <java classname="javacc" fork="true" failonerror="true">
219 <classpath path="${javacc.home}/javacc.jar"/>
220 <arg value="-DEBUG_PARSER=false"/>
221 <arg value="-DEBUG_TOKEN_MANAGER=false"/>
222 <arg value="-JDK_VERSION=1.8"/>
223 <arg value="-GRAMMAR_ENCODING=UTF-8"/>
224 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
225 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
226 </java>
227 </target>
228 <target name="compile" depends="init,javacc">
229 <!-- COTS -->
230 <javac srcdir="${src.dir}" includes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**" nowarn="on" encoding="iso-8859-1"
231 destdir="build" target="1.8" source="1.8" debug="on" includeAntRuntime="false" createMissingPackageInfoClass="false">
232 <!-- get rid of "internal proprietary API" warning -->
233 <compilerarg value="-XDignore.symbol.file"/>
234 <exclude name="org/apache/commons/compress/compressors/bzip2/BZip2Utils.java"/>
235 <exclude name="org/apache/commons/compress/compressors/brotli/**"/>
236 <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
237 <exclude name="org/apache/commons/compress/compressors/xz/**"/>
238 <exclude name="org/apache/commons/compress/compressors/CompressorStreamFactory.java"/>
239 <exclude name="org/apache/commons/compress/compressors/CompressorStreamProvider.java"/>
240 <exclude name="org/apache/commons/compress/compressors/CompressorException.java"/>
241 <exclude name="org/apache/commons/compress/compressors/FileNameUtil.java"/>
242 <exclude name="org/apache/commons/compress/compressors/deflate/**"/>
243 <exclude name="org/apache/commons/compress/compressors/gzip/**"/>
244 <exclude name="org/apache/commons/compress/compressors/lz4/**"/>
245 <exclude name="org/apache/commons/compress/compressors/lz77support/**"/>
246 <exclude name="org/apache/commons/compress/compressors/lzw/**"/>
247 <exclude name="org/apache/commons/compress/compressors/pack200/**"/>
248 <exclude name="org/apache/commons/compress/compressors/snappy/**"/>
249 <exclude name="org/apache/commons/compress/compressors/z/**"/>
250 <exclude name="org/apache/commons/compress/utils/ArchiveUtils.java"/>
251 <exclude name="org/apache/commons/jcs/JCS.java"/>
252 <exclude name="org/apache/commons/jcs/access/GroupCacheAccess.java"/>
253 <exclude name="org/apache/commons/jcs/access/PartitionedCacheAccess.java"/>
254 <exclude name="org/apache/commons/jcs/access/behavior/IGroupCacheAccess.java"/>
255 <exclude name="org/apache/commons/jcs/access/exception/InvalidGroupException.java"/>
256 <exclude name="org/apache/commons/jcs/admin/servlet/**"/>
257 <exclude name="org/apache/commons/jcs/auxiliary/AbstractAuxiliaryCacheMonitor.java"/>
258 <exclude name="org/apache/commons/jcs/auxiliary/disk/jdbc/**"/>
259 <exclude name="org/apache/commons/jcs/auxiliary/lateral/**"/>
260 <exclude name="org/apache/commons/jcs/auxiliary/remote/**"/>
261 <exclude name="org/apache/commons/jcs/engine/CacheAdaptor.java"/>
262 <exclude name="org/apache/commons/jcs/engine/CacheGroup.java"/>
263 <exclude name="org/apache/commons/jcs/engine/CacheWatchRepairable.java"/>
264 <exclude name="org/apache/commons/jcs/engine/Zombie*.java"/>
265 <exclude name="org/apache/commons/jcs/engine/logging/CacheEventLoggerDebugLogger.java"/>
266 <exclude name="org/apache/commons/jcs/utils/access/**"/>
267 <exclude name="org/apache/commons/jcs/utils/discovery/**"/>
268 <exclude name="org/apache/commons/jcs/utils/net/**"/>
269 <exclude name="org/apache/commons/jcs/utils/props/**"/>
270 <exclude name="org/apache/commons/jcs/utils/servlet/**"/>
271 <exclude name="org/apache/commons/logging/impl/AvalonLogger.java"/>
272 <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"/>
273 <exclude name="org/apache/commons/logging/impl/Log4JLogger.java"/>
274 <exclude name="org/apache/commons/logging/impl/LogKitLogger.java"/>
275 <exclude name="org/apache/commons/logging/impl/ServletContextCleaner.java"/>
276 </javac>
277 <!-- JMapViewer -->
278 <javac compiler="${javac.compiler}" sourcepath="" srcdir="${src.dir}"
279 excludes="com/**,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/**,gnu/**"
280 destdir="build" target="1.8" source="1.8" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
281 <compilerclasspath>
282 <pathelement location="${error_prone_ant.jar}"/>
283 </compilerclasspath>
284 <compilerarg value="-Xlint:cast"/>
285 <compilerarg value="-Xlint:deprecation"/>
286 <compilerarg value="-Xlint:dep-ann"/>
287 <compilerarg value="-Xlint:divzero"/>
288 <compilerarg value="-Xlint:empty"/>
289 <compilerarg value="-Xlint:finally"/>
290 <compilerarg value="-Xlint:overrides"/>
291 <!--<compilerarg value="-Xlint:rawtypes"/>-->
292 <compilerarg value="-Xlint:static"/>
293 <compilerarg value="-Xlint:try"/>
294 <compilerarg value="-Xlint:unchecked"/>
295 <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
296 <compilerarg value="-XDignore.symbol.file"/>
297 <compilerarg value="-Xep:ReferenceEquality:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
298 <compilerarg line="-Xmaxwarns 1000"/>
299 </javac>
300 <!-- JOSM -->
301 <javac compiler="${javac.compiler}" sourcepath="" srcdir="${src.dir}"
302 excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/**"
303 destdir="build" target="1.8" source="1.8" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
304 <compilerclasspath>
305 <pathelement location="${error_prone_ant.jar}"/>
306 </compilerclasspath>
307 <compilerarg value="-Xlint:cast"/>
308 <compilerarg value="-Xlint:deprecation"/>
309 <compilerarg value="-Xlint:dep-ann"/>
310 <compilerarg value="-Xlint:divzero"/>
311 <compilerarg value="-Xlint:empty"/>
312 <compilerarg value="-Xlint:finally"/>
313 <compilerarg value="-Xlint:overrides"/>
314 <!--<compilerarg value="-Xlint:rawtypes"/>-->
315 <compilerarg value="-Xlint:static"/>
316 <compilerarg value="-Xlint:try"/>
317 <compilerarg value="-Xlint:unchecked"/>
318 <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
319 <compilerarg value="-XDignore.symbol.file"/>
320 <compilerarg value="-Xep:ReferenceEquality:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
321 <compilerarg value="-Xep:ImmutableEnumChecker:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
322 <compilerarg value="-Xep:FutureReturnValueIgnored:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
323 <compilerarg value="-Xep:FloatingPointLiteralPrecision:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
324 <compilerarg value="-Xep:ShortCircuitBoolean:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
325 <compilerarg value="-Xep:LiteralClassName:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
326 <compilerarg line="-Xmaxwarns 1000"/>
327 </javac>
328
329 <copy todir="build" failonerror="no" includeemptydirs="no">
330 <fileset dir="resources"/>
331 </copy>
332 </target>
333 <target name="init" depends="init-properties">
334 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
335 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
336 </uptodate>
337 <mkdir dir="${build.dir}"/>
338 <mkdir dir="${dist.dir}"/>
339 </target>
340 <target name="javadoc" depends="init-properties">
341 <javadoc destdir="javadoc"
342 sourcepath="${src.dir}"
343 encoding="UTF-8"
344 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
345 excludepackagenames="org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.*"
346 windowtitle="JOSM"
347 use="true"
348 private="true"
349 linksource="true"
350 author="false">
351 <link href="http://docs.oracle.com/javase/8/docs/api"/>
352 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
353 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JOSM</a>]]></bottom>
354 <arg value="--add-exports" if:set="isJava9" />
355 <arg value="java.base/sun.security.util=ALL-UNNAMED" if:set="isJava9" />
356 <arg value="--add-exports" if:set="isJava9" />
357 <arg value="java.base/sun.security.x509=ALL-UNNAMED" if:set="isJava9" />
358 </javadoc>
359 </target>
360 <target name="clean" depends="init-properties">
361 <delete dir="${build.dir}"/>
362 <delete dir="${proj-build.dir}"/>
363 <delete dir="${dist.dir}"/>
364 <delete dir="${mapcss.dir}/parsergen"/>
365 <delete file="${src.dir}/org/w3/_2001/xmlschema/Adapter1.java"/>
366 <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
367 <delete file="${epsg.output}"/>
368 </target>
369 <macrodef name="init-test-preferences">
370 <attribute name="testfamily"/>
371 <sequential>
372 <copy file="${test.dir}/config/preferences.template.xml" tofile="${test.dir}/config/@{testfamily}-josm.home/preferences.xml"/>
373 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
374 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
375 </sequential>
376 </macrodef>
377 <target name="test-init" depends="init-properties">
378 <mkdir dir="${test.dir}/build"/>
379 <mkdir dir="${test.dir}/build/unit"/>
380 <mkdir dir="${test.dir}/build/functional"/>
381 <mkdir dir="${test.dir}/build/performance"/>
382 <mkdir dir="${test.dir}/report"/>
383 <init-test-preferences testfamily="unit"/>
384 <init-test-preferences testfamily="functional"/>
385 <init-test-preferences testfamily="performance"/>
386 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
387 </target>
388 <target name="test-clean" depends="init-properties">
389 <delete dir="${test.dir}/build"/>
390 <delete dir="${test.dir}/report"/>
391 <delete file="${test.dir}/jacoco.exec" />
392 <delete file="${test.dir}/jacocoIT.exec" />
393 <delete file="${test.dir}/config/unit-josm.home" failonerror="false"/>
394 <delete file="${test.dir}/config/functional-josm.home" failonerror="false"/>
395 <delete file="${test.dir}/config/performance-josm.home" failonerror="false"/>
396 </target>
397 <macrodef name="call-groovyc">
398 <attribute name="testfamily"/>
399 <element name="cp-elements"/>
400 <sequential>
401 <groovyc srcdir="${test.dir}/@{testfamily}" destdir="${test.dir}/build/@{testfamily}" encoding="UTF-8">
402 <classpath>
403 <cp-elements/>
404 </classpath>
405 <javac target="1.8" source="1.8" debug="on" encoding="UTF-8">
406 <compilerarg value="-Xlint:all"/>
407 <compilerarg value="-Xlint:-serial"/>
408 </javac>
409 </groovyc>
410 </sequential>
411 </macrodef>
412 <target name="test-compile" depends="test-init,dist">
413 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${groovy.jar}"/>
414 <call-groovyc testfamily="unit">
415 <cp-elements>
416 <path refid="test.classpath"/>
417 </cp-elements>
418 </call-groovyc>
419 <call-groovyc testfamily="functional">
420 <cp-elements>
421 <path refid="test.classpath"/>
422 <pathelement path="${test.dir}/build/unit"/>
423 </cp-elements>
424 </call-groovyc>
425 <call-groovyc testfamily="performance">
426 <cp-elements>
427 <path refid="test.classpath"/>
428 <pathelement path="${test.dir}/build/unit"/>
429 </cp-elements>
430 </call-groovyc>
431 </target>
432 <macrodef name="call-junit">
433 <attribute name="testfamily"/>
434 <attribute name="testITsuffix" default=""/>
435 <attribute name="coverage" default="true"/>
436 <sequential>
437 <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/>
438 <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="org.openstreetmap.josm.*">
439 <junit printsummary="yes" fork="true" forkmode="once">
440 <jvmarg value="-Dfile.encoding=UTF-8"/>
441 <jvmarg value="--add-modules" if:set="isJava9" />
442 <jvmarg value="java.se.ee" if:set="isJava9" />
443 <jvmarg value="--add-exports" if:set="isJava9" />
444 <jvmarg value="java.base/sun.security.util=ALL-UNNAMED" if:set="isJava9" />
445 <jvmarg value="--add-opens" if:set="isJava9" />
446 <jvmarg value="java.base/sun.security.x509=ALL-UNNAMED" if:set="isJava9" />
447 <jvmarg value="--add-exports" if:set="isJava9" />
448 <jvmarg value="jdk.deploy/com.sun.deploy.config=ALL-UNNAMED" if:set="isJava9" />
449 <jvmarg value="--add-opens" if:set="isJava9" />
450 <jvmarg value="java.base/java.io=ALL-UNNAMED" if:set="isJava9" />
451 <jvmarg value="--add-opens" if:set="isJava9" />
452 <jvmarg value="java.base/java.lang=ALL-UNNAMED" if:set="isJava9" />
453 <jvmarg value="--add-opens" if:set="isJava9" />
454 <jvmarg value="java.base/java.text=ALL-UNNAMED" if:set="isJava9" />
455 <jvmarg value="--add-opens" if:set="isJava9" />
456 <jvmarg value="java.base/java.util=ALL-UNNAMED" if:set="isJava9" />
457 <jvmarg value="--add-opens" if:set="isJava9" />
458 <jvmarg value="java.desktop/java.awt=ALL-UNNAMED" if:set="isJava9" />
459 <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
460 <sysproperty key="josm.test.data" value="${test.dir}/data"/>
461 <sysproperty key="java.awt.headless" value="true"/>
462 <sysproperty key="glass.platform" value="Monocle"/>
463 <sysproperty key="monocle.platform" value="Headless"/>
464 <sysproperty key="prism.order" value="sw"/>
465 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
466 <classpath>
467 <path refid="test.classpath"/>
468 <pathelement path="${test.dir}/build/unit"/>
469 <pathelement path="${test.dir}/build/@{testfamily}"/>
470 <pathelement path="${test.dir}/config"/>
471 </classpath>
472 <formatter type="plain"/>
473 <formatter type="xml"/>
474 <batchtest fork="yes" todir="${test.dir}/report">
475 <fileset dir="${test.dir}/build/@{testfamily}" includes="**/*Test@{testITsuffix}.class"/>
476 </batchtest>
477 </junit>
478 </jacoco:coverage>
479 </sequential>
480 </macrodef>
481 <target name="test" depends="test-compile" unless="test.notRequired"
482 description="Run unit, functional and performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
483 <call-junit testfamily="unit"/>
484 <call-junit testfamily="functional"/>
485 <call-junit testfamily="performance" coverage="false"/>
486 </target>
487 <target name="test-it" depends="test-compile" unless="test-it.notRequired"
488 description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
489 <call-junit testfamily="unit" testITsuffix="IT"/>
490 <call-junit testfamily="functional" testITsuffix="IT"/>
491 <call-junit testfamily="performance" testITsuffix="IT" coverage="false"/>
492 </target>
493 <target name="test-html" depends="test, test-it" description="Generate HTML test reports">
494 <!-- May require additional ant dependencies like ant-trax package -->
495 <junitreport todir="${test.dir}/report">
496 <fileset dir="${test.dir}/report">
497 <include name="TEST-*.xml"/>
498 </fileset>
499 <report todir="${test.dir}/report/html"/>
500 </junitreport>
501 <jacoco:report>
502 <executiondata>
503 <fileset dir="${test.dir}" includes="*.exec"/>
504 </executiondata>
505 <structure name="JOSM Test Coverage">
506 <classfiles>
507 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
508 </classfiles>
509 <sourcefiles encoding="UTF-8">
510 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
511 </sourcefiles>
512 </structure>
513 <html destdir="${test.dir}/report/jacoco"/>
514 </jacoco:report>
515 </target>
516 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
517 <target name="dist-optimized" depends="dist" unless="isJava9">
518 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
519 <proguard>
520 -injars dist/josm-custom.jar
521 -outjars dist/josm-custom-optimized.jar
522
523 -libraryjars ${java.home}/lib/rt.jar
524 -libraryjars ${java.home}/lib/jce.jar
525 -libraryjars ${java.home}/lib/ext/jfxrt.jar
526
527 -dontoptimize
528 -dontobfuscate
529
530 # These options probably are not necessary (and make processing a bit slower)
531 -dontskipnonpubliclibraryclasses
532 -dontskipnonpubliclibraryclassmembers
533
534 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
535 public static void main(java.lang.String[]);
536 }
537
538 -keep class * extends org.openstreetmap.josm.io.FileImporter
539 -keep class * extends org.openstreetmap.josm.io.FileExporter
540 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
541 -keep class org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory$PseudoClasses {
542 static boolean *(org.openstreetmap.josm.gui.mappaint.Environment);
543 }
544 -keep class org.apache.commons.logging.impl.*
545
546 -keepclassmembers enum * {
547 public static **[] values();
548 public static ** valueOf(java.lang.String);
549 }
550
551 # Keep unused public methods (can be useful for plugins)
552 -keepclassmembers class * {
553 public protected *;
554 }
555
556 # Keep serialization methods
557 -keepclassmembers class * implements java.io.Serializable {
558 private void writeObject(java.io.ObjectOutputStream);
559 private void readObject(java.io.ObjectInputStream);
560 }
561
562 # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
563 # This note should not be a problem as we don't use obfuscation
564 -dontnote
565 </proguard>
566 </target>
567 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
568 <target name="dist-optimized-report" depends="dist-optimized" unless="isJava9">
569 <!-- generate difference report between optimized jar and normal one -->
570 <exec executable="perl" dir="${basedir}">
571 <arg value="tools/japicc/japi-compliance-checker.pl"/>
572 <arg value="--lib=JOSM"/>
573 <arg value="--keep-internal"/>
574 <arg value="--v1=${version.entry.commit.revision}"/>
575 <arg value="--v2=${version.entry.commit.revision}-optimized"/>
576 <arg value="--report-path=${dist.dir}/compat_report.html"/>
577 <arg value="${dist.dir}/josm-custom.jar"/>
578 <arg value="${dist.dir}/josm-custom-optimized.jar"/>
579 </exec>
580 </target>
581 <target name="check-plugins" depends="dist-optimized">
582 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
583 <local name="dir"/>
584 <local name="plugins"/>
585 <property name="dir" value="plugin-check"/>
586 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
587 <classpath path="tools/animal-sniffer-ant-tasks-1.15.jar"/>
588 </typedef>
589 <mkdir dir="${dir}"/>
590 <!-- List of deprecated plugins -->
591 <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
592 <filterchain>
593 <linecontains>
594 <contains value="new DeprecatedPlugin("/>
595 </linecontains>
596 <tokenfilter>
597 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
598 </tokenfilter>
599 <striplinebreaks/>
600 <tokenfilter>
601 <replaceregex pattern="\|$" replace="" flags="gi"/>
602 </tokenfilter>
603 </filterchain>
604 </loadfile>
605 <!-- Download list of plugins -->
606 <loadresource property="plugins">
607 <url url="https://josm.openstreetmap.de/plugin"/>
608 <filterchain>
609 <linecontainsregexp negate="true">
610 <regexp pattern="^\t.*"/>
611 </linecontainsregexp>
612 <linecontainsregexp negate="true">
613 <regexp pattern="${deprecated-plugins}"/>
614 </linecontainsregexp>
615 <tokenfilter>
616 <replaceregex pattern="^.*;" replace="" flags="gi"/>
617 </tokenfilter>
618 </filterchain>
619 </loadresource>
620 <!-- Delete files that are not in plugin list (like old plugins) -->
621 <loadresource property="file-list">
622 <propertyresource name="plugins"/>
623 <filterchain>
624 <tokenfilter>
625 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
626 </tokenfilter>
627 <striplinebreaks/>
628 <tokenfilter>
629 <replaceregex pattern="\|$" replace="" flags="gi"/>
630 </tokenfilter>
631 </filterchain>
632 </loadresource>
633 <delete>
634 <restrict>
635 <fileset dir="${dir}"/>
636 <not>
637 <name regex="${file-list}"/>
638 </not>
639 </restrict>
640 </delete>
641 <!-- Download plugins -->
642 <copy todir="${dir}" flatten="true">
643 <resourcelist>
644 <string value="${plugins}"/>
645 </resourcelist>
646 </copy>
647 <!-- Check plugins -->
648 <as:build-signatures destfile="${dir}/api.sig">
649 <path>
650 <fileset file="${dist.dir}/josm-custom-optimized.jar"/>
651 <fileset file="${java.home}/lib/rt.jar"/>
652 <fileset file="${java.home}/lib/jce.jar"/>
653 </path>
654 </as:build-signatures>
655 <as:check-signature signature="${dir}/api.sig">
656 <ignore classname="au.edu.*"/>
657 <ignore classname="au.com.*"/>
658 <ignore classname="com.*"/>
659 <ignore classname="de.miethxml.*"/>
660 <ignore classname="javafx.*"/>
661 <ignore classname="javax.*"/>
662 <ignore classname="jogamp.*"/>
663 <ignore classname="junit.*"/>
664 <ignore classname="net.sf.*"/>
665 <ignore classname="nu.xom.*"/>
666 <ignore classname="org.apache.*"/>
667 <ignore classname="org.codehaus.*"/>
668 <ignore classname="org.dom4j.*"/>
669 <ignore classname="org.hsqldb.*"/>
670 <ignore classname="org.ibex.*"/>
671 <ignore classname="org.iso_relax.*"/>
672 <ignore classname="org.jaitools.*"/>
673 <ignore classname="org.jaxen.*"/>
674 <ignore classname="org.jdom2.*"/>
675 <ignore classname="org.jgraph.*"/>
676 <ignore classname="org.joda.time.*"/>
677 <ignore classname="org.jvnet.staxex.*"/>
678 <ignore classname="org.kxml2.*"/>
679 <ignore classname="org.objectweb.*"/>
680 <ignore classname="org.python.*"/>
681 <ignore classname="org.slf4j.*"/>
682 <!-- plugins used by another ones -->
683 <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
684 <ignore classname="org.openstreetmap.josm.plugins.jna.*"/>
685 <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
686 <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
687 <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
688 <path path="${dir}"/>
689 </as:check-signature>
690 </target>
691
692 <macrodef name="_taginfo">
693 <attribute name="type"/>
694 <attribute name="output"/>
695 <sequential>
696 <echo message="Generating Taginfo for type @{type} to @{output}"/>
697 <groovy src="${taginfoextract}" classpath="${dist.dir}/josm-custom.jar:tools/findbugs/annotations.jar">
698 <arg value="-t"/>
699 <arg value="@{type}"/>
700 <arg value="--noexit"/>
701 <arg value="--svnweb"/>
702 <arg value="--imgurlprefix"/>
703 <arg value="${imgurlprefix}"/>
704 <arg value="-o"/>
705 <arg value="@{output}"/>
706 </groovy>
707 </sequential>
708 </macrodef>
709
710 <target name="taginfo" depends="dist">
711 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
712 <property name="taginfoextract" value="scripts/TagInfoExtract.groovy"/>
713 <property name="imgurlprefix" value="http://josm.openstreetmap.de/download/taginfo/taginfo-img"/>
714 <_taginfo type="mappaint" output="taginfo_style.json"/>
715 <_taginfo type="presets" output="taginfo_presets.json"/>
716 <_taginfo type="external_presets" output="taginfo_external_presets.json"/>
717 </target>
718
719 <target name="imageryindex" depends="init-properties">
720 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
721 <echo message="Checking editor imagery difference"/>
722 <groovy src="scripts/SyncEditorLayerIndex.groovy" classpath="${dist.dir}/josm-custom.jar">
723 <arg value="-noeli"/>
724 <arg value="-p"/>
725 <arg value="imagery_eliout.imagery.xml"/>
726 <arg value="-q"/>
727 <arg value="imagery_josmout.imagery.xml"/>
728 </groovy>
729 </target>
730
731 <target name="imageryindexdownload">
732 <exec append="false" executable="wget" failifexecutionfails="true">
733 <arg value="https://josm.openstreetmap.de/maps"/>
734 <arg value="-O"/>
735 <arg value="imagery_josm.imagery.xml"/>
736 <arg value="--unlink"/>
737 </exec>
738 <exec append="false" executable="wget" failifexecutionfails="true">
739 <arg value="https://josm.openstreetmap.de/wiki/ImageryCompareIgnores?format=txt"/>
740 <arg value="-O"/>
741 <arg value="imagery_josm.ignores.txt"/>
742 <arg value="--unlink"/>
743 </exec>
744 <exec append="false" executable="wget" failifexecutionfails="true">
745 <arg value="https://raw.githubusercontent.com/osmlab/editor-layer-index/gh-pages/imagery.geojson"/>
746 <arg value="-O"/>
747 <arg value="imagery_eli.geojson"/>
748 <arg value="--unlink"/>
749 </exec>
750 <antcall target="imageryindex"/>
751 </target>
752
753 <target name="checkstyle" depends="init-properties">
754 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
755 classpath="tools/checkstyle/checkstyle-all.jar"/>
756 <checkstyle config="tools/checkstyle/josm_checks.xml">
757 <fileset dir="${base.dir}/src/org/openstreetmap/josm" includes="**/*.java"
758 excludes="gui/mappaint/mapcss/parsergen/*.java"/>
759 <fileset dir="${base.dir}/test" includes="**/*.java"/>
760 <formatter type="plain"/>
761 <formatter type="xml" toFile="checkstyle-josm.xml"/>
762 </checkstyle>
763 </target>
764
765 <target name="findbugs" depends="dist">
766 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
767 <path id="findbugs-classpath">
768 <fileset dir="${base.dir}/tools/findbugs/">
769 <include name="*.jar"/>
770 </fileset>
771 </path>
772 <property name="findbugs-classpath" refid="findbugs-classpath"/>
773 <findbugs output="xml"
774 outputFile="findbugs-josm.xml"
775 classpath="${findbugs-classpath}"
776 pluginList=""
777 excludeFilter="tools/findbugs/josm-filter.xml"
778 effort="max"
779 reportLevel="low"
780 >
781 <sourcePath path="${base.dir}/src" />
782 <class location="${dist.dir}/josm-custom.jar" />
783 </findbugs>
784 </target>
785
786 <target name="pmd" depends="init-properties">
787 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpath="${toString:pmd.classpath}"/>
788 <pmd shortFilenames="true" encoding="UTF-8">
789 <sourceLanguage name="java" version="1.8" />
790 <ruleset>${base.dir}/tools/pmd/josm-ruleset.xml</ruleset>
791 <formatter type="text" toConsole="true" />
792 <formatter type="xml" toFile="pmd-josm.xml">
793 <param name="encoding" value="UTF-8" />
794 </formatter>
795 <fileset dir="${src.dir}">
796 <include name="org/openstreetmap/josm/**/*.java"/>
797 <exclude name="org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/*.java" />
798 </fileset>
799 </pmd>
800 </target>
801
802 <target name="run" depends="dist">
803 <java jar="${dist.dir}/josm-custom.jar" fork="true">
804 <arg value="--set=expert=true"/>
805 <arg value="--set=remotecontrol.enabled=true"/>
806 <arg value="--set=debug.edt-checker.enable=false"/>
807 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
808 </java>
809 </target>
810 <!--
811 ** Compile build script for generating projection list.
812 -->
813 <target name="epsg-compile" depends="init-properties">
814 <property name="proj-classpath" location="${build.dir}"/>
815 <mkdir dir="${proj-build.dir}"/>
816 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true"
817 destdir="${proj-build.dir}" target="1.8" source="1.8" debug="on"
818 includeantruntime="false" createMissingPackageInfoClass="false"
819 encoding="UTF-8" classpath="${proj-classpath}">
820 </javac>
821 </target>
822 <!--
823 ** generate projection list.
824 -->
825 <target name="epsg" depends="epsg-compile">
826 <touch file="${epsg.output}"/>
827 <java classname="BuildProjectionDefinitions" failonerror="true" fork="true">
828 <sysproperty key="java.awt.headless" value="true"/>
829 <classpath>
830 <pathelement path="${base.dir}"/>
831 <pathelement path="${proj-classpath}"/>
832 <pathelement path="${proj-build.dir}"/>
833 </classpath>
834 <arg value="${base.dir}"/>
835 </java>
836 </target>
837</project>
Note: See TracBrowser for help on using the repository browser.