source: josm/trunk/build.xml@ 12426

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

see #2089 - add missing jdk9 exports directives

  • Property svn:eol-style set to native
File size: 43.5 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 javafx.graphics/com.sun.javafx.application 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 <arg value="--add-exports" if:set="isJava9" />
359 <arg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" />
360 </javadoc>
361 </target>
362 <target name="clean" depends="init-properties">
363 <delete dir="${build.dir}"/>
364 <delete dir="${proj-build.dir}"/>
365 <delete dir="${dist.dir}"/>
366 <delete dir="${mapcss.dir}/parsergen"/>
367 <delete file="${src.dir}/org/w3/_2001/xmlschema/Adapter1.java"/>
368 <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
369 <delete file="${epsg.output}"/>
370 </target>
371 <macrodef name="init-test-preferences">
372 <attribute name="testfamily"/>
373 <sequential>
374 <copy file="${test.dir}/config/preferences.template.xml" tofile="${test.dir}/config/@{testfamily}-josm.home/preferences.xml"/>
375 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
376 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
377 </sequential>
378 </macrodef>
379 <target name="test-init" depends="init-properties">
380 <mkdir dir="${test.dir}/build"/>
381 <mkdir dir="${test.dir}/build/unit"/>
382 <mkdir dir="${test.dir}/build/functional"/>
383 <mkdir dir="${test.dir}/build/performance"/>
384 <mkdir dir="${test.dir}/report"/>
385 <init-test-preferences testfamily="unit"/>
386 <init-test-preferences testfamily="functional"/>
387 <init-test-preferences testfamily="performance"/>
388 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
389 </target>
390 <target name="test-clean" depends="init-properties">
391 <delete dir="${test.dir}/build"/>
392 <delete dir="${test.dir}/report"/>
393 <delete file="${test.dir}/jacoco.exec" />
394 <delete file="${test.dir}/jacocoIT.exec" />
395 <delete file="${test.dir}/config/unit-josm.home" failonerror="false"/>
396 <delete file="${test.dir}/config/functional-josm.home" failonerror="false"/>
397 <delete file="${test.dir}/config/performance-josm.home" failonerror="false"/>
398 </target>
399 <macrodef name="call-groovyc">
400 <attribute name="testfamily"/>
401 <element name="cp-elements"/>
402 <sequential>
403 <groovyc srcdir="${test.dir}/@{testfamily}" destdir="${test.dir}/build/@{testfamily}" encoding="UTF-8">
404 <classpath>
405 <cp-elements/>
406 </classpath>
407 <javac target="1.8" source="1.8" debug="on" encoding="UTF-8">
408 <compilerarg value="-Xlint:all"/>
409 <compilerarg value="-Xlint:-serial"/>
410 </javac>
411 </groovyc>
412 </sequential>
413 </macrodef>
414 <target name="test-compile" depends="test-init,dist">
415 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${groovy.jar}"/>
416 <call-groovyc testfamily="unit">
417 <cp-elements>
418 <path refid="test.classpath"/>
419 </cp-elements>
420 </call-groovyc>
421 <call-groovyc testfamily="functional">
422 <cp-elements>
423 <path refid="test.classpath"/>
424 <pathelement path="${test.dir}/build/unit"/>
425 </cp-elements>
426 </call-groovyc>
427 <call-groovyc testfamily="performance">
428 <cp-elements>
429 <path refid="test.classpath"/>
430 <pathelement path="${test.dir}/build/unit"/>
431 </cp-elements>
432 </call-groovyc>
433 </target>
434 <macrodef name="call-junit">
435 <attribute name="testfamily"/>
436 <attribute name="testITsuffix" default=""/>
437 <attribute name="coverage" default="true"/>
438 <sequential>
439 <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/>
440 <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="org.openstreetmap.josm.*">
441 <junit printsummary="yes" fork="true" forkmode="once">
442 <jvmarg value="-Dfile.encoding=UTF-8"/>
443 <jvmarg value="--add-modules" if:set="isJava9" />
444 <jvmarg value="java.se.ee" if:set="isJava9" />
445 <jvmarg value="--add-exports" if:set="isJava9" />
446 <jvmarg value="java.base/sun.security.util=ALL-UNNAMED" if:set="isJava9" />
447 <jvmarg value="--add-opens" if:set="isJava9" />
448 <jvmarg value="java.base/sun.security.x509=ALL-UNNAMED" if:set="isJava9" />
449 <jvmarg value="--add-exports" if:set="isJava9" />
450 <jvmarg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" />
451 <jvmarg value="--add-exports" if:set="isJava9" />
452 <jvmarg value="jdk.deploy/com.sun.deploy.config=ALL-UNNAMED" if:set="isJava9" />
453 <jvmarg value="--add-opens" if:set="isJava9" />
454 <jvmarg value="java.base/java.io=ALL-UNNAMED" if:set="isJava9" />
455 <jvmarg value="--add-opens" if:set="isJava9" />
456 <jvmarg value="java.base/java.lang=ALL-UNNAMED" if:set="isJava9" />
457 <jvmarg value="--add-opens" if:set="isJava9" />
458 <jvmarg value="java.base/java.text=ALL-UNNAMED" if:set="isJava9" />
459 <jvmarg value="--add-opens" if:set="isJava9" />
460 <jvmarg value="java.base/java.util=ALL-UNNAMED" if:set="isJava9" />
461 <jvmarg value="--add-opens" if:set="isJava9" />
462 <jvmarg value="java.desktop/java.awt=ALL-UNNAMED" if:set="isJava9" />
463 <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
464 <sysproperty key="josm.test.data" value="${test.dir}/data"/>
465 <sysproperty key="java.awt.headless" value="true"/>
466 <sysproperty key="glass.platform" value="Monocle"/>
467 <sysproperty key="monocle.platform" value="Headless"/>
468 <sysproperty key="prism.order" value="sw"/>
469 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
470 <classpath>
471 <path refid="test.classpath"/>
472 <pathelement path="${test.dir}/build/unit"/>
473 <pathelement path="${test.dir}/build/@{testfamily}"/>
474 <pathelement path="${test.dir}/config"/>
475 </classpath>
476 <formatter type="plain"/>
477 <formatter type="xml"/>
478 <batchtest fork="yes" todir="${test.dir}/report">
479 <fileset dir="${test.dir}/build/@{testfamily}" includes="**/*Test@{testITsuffix}.class"/>
480 </batchtest>
481 </junit>
482 </jacoco:coverage>
483 </sequential>
484 </macrodef>
485 <target name="test" depends="test-compile" unless="test.notRequired"
486 description="Run unit, functional and performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
487 <call-junit testfamily="unit"/>
488 <call-junit testfamily="functional"/>
489 <call-junit testfamily="performance" coverage="false"/>
490 </target>
491 <target name="test-it" depends="test-compile" unless="test-it.notRequired"
492 description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
493 <call-junit testfamily="unit" testITsuffix="IT"/>
494 <call-junit testfamily="functional" testITsuffix="IT"/>
495 <call-junit testfamily="performance" testITsuffix="IT" coverage="false"/>
496 </target>
497 <target name="test-html" depends="test, test-it" description="Generate HTML test reports">
498 <!-- May require additional ant dependencies like ant-trax package -->
499 <junitreport todir="${test.dir}/report">
500 <fileset dir="${test.dir}/report">
501 <include name="TEST-*.xml"/>
502 </fileset>
503 <report todir="${test.dir}/report/html"/>
504 </junitreport>
505 <jacoco:report>
506 <executiondata>
507 <fileset dir="${test.dir}" includes="*.exec"/>
508 </executiondata>
509 <structure name="JOSM Test Coverage">
510 <classfiles>
511 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
512 </classfiles>
513 <sourcefiles encoding="UTF-8">
514 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
515 </sourcefiles>
516 </structure>
517 <html destdir="${test.dir}/report/jacoco"/>
518 </jacoco:report>
519 </target>
520 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
521 <target name="dist-optimized" depends="dist" unless="isJava9">
522 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
523 <proguard>
524 -injars dist/josm-custom.jar
525 -outjars dist/josm-custom-optimized.jar
526
527 -libraryjars ${java.home}/lib/rt.jar
528 -libraryjars ${java.home}/lib/jce.jar
529 -libraryjars ${java.home}/lib/ext/jfxrt.jar
530
531 -dontoptimize
532 -dontobfuscate
533
534 # These options probably are not necessary (and make processing a bit slower)
535 -dontskipnonpubliclibraryclasses
536 -dontskipnonpubliclibraryclassmembers
537
538 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
539 public static void main(java.lang.String[]);
540 }
541
542 -keep class * extends org.openstreetmap.josm.io.FileImporter
543 -keep class * extends org.openstreetmap.josm.io.FileExporter
544 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
545 -keep class org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory$PseudoClasses {
546 static boolean *(org.openstreetmap.josm.gui.mappaint.Environment);
547 }
548 -keep class org.apache.commons.logging.impl.*
549
550 -keepclassmembers enum * {
551 public static **[] values();
552 public static ** valueOf(java.lang.String);
553 }
554
555 # Keep unused public methods (can be useful for plugins)
556 -keepclassmembers class * {
557 public protected *;
558 }
559
560 # Keep serialization methods
561 -keepclassmembers class * implements java.io.Serializable {
562 private void writeObject(java.io.ObjectOutputStream);
563 private void readObject(java.io.ObjectInputStream);
564 }
565
566 # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
567 # This note should not be a problem as we don't use obfuscation
568 -dontnote
569 </proguard>
570 </target>
571 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
572 <target name="dist-optimized-report" depends="dist-optimized" unless="isJava9">
573 <!-- generate difference report between optimized jar and normal one -->
574 <exec executable="perl" dir="${basedir}">
575 <arg value="tools/japicc/japi-compliance-checker.pl"/>
576 <arg value="--lib=JOSM"/>
577 <arg value="--keep-internal"/>
578 <arg value="--v1=${version.entry.commit.revision}"/>
579 <arg value="--v2=${version.entry.commit.revision}-optimized"/>
580 <arg value="--report-path=${dist.dir}/compat_report.html"/>
581 <arg value="${dist.dir}/josm-custom.jar"/>
582 <arg value="${dist.dir}/josm-custom-optimized.jar"/>
583 </exec>
584 </target>
585 <target name="check-plugins" depends="dist-optimized">
586 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
587 <local name="dir"/>
588 <local name="plugins"/>
589 <property name="dir" value="plugin-check"/>
590 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
591 <classpath path="tools/animal-sniffer-ant-tasks-1.15.jar"/>
592 </typedef>
593 <mkdir dir="${dir}"/>
594 <!-- List of deprecated plugins -->
595 <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
596 <filterchain>
597 <linecontains>
598 <contains value="new DeprecatedPlugin("/>
599 </linecontains>
600 <tokenfilter>
601 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
602 </tokenfilter>
603 <striplinebreaks/>
604 <tokenfilter>
605 <replaceregex pattern="\|$" replace="" flags="gi"/>
606 </tokenfilter>
607 </filterchain>
608 </loadfile>
609 <!-- Download list of plugins -->
610 <loadresource property="plugins">
611 <url url="https://josm.openstreetmap.de/plugin"/>
612 <filterchain>
613 <linecontainsregexp negate="true">
614 <regexp pattern="^\t.*"/>
615 </linecontainsregexp>
616 <linecontainsregexp negate="true">
617 <regexp pattern="${deprecated-plugins}"/>
618 </linecontainsregexp>
619 <tokenfilter>
620 <replaceregex pattern="^.*;" replace="" flags="gi"/>
621 </tokenfilter>
622 </filterchain>
623 </loadresource>
624 <!-- Delete files that are not in plugin list (like old plugins) -->
625 <loadresource property="file-list">
626 <propertyresource name="plugins"/>
627 <filterchain>
628 <tokenfilter>
629 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
630 </tokenfilter>
631 <striplinebreaks/>
632 <tokenfilter>
633 <replaceregex pattern="\|$" replace="" flags="gi"/>
634 </tokenfilter>
635 </filterchain>
636 </loadresource>
637 <delete>
638 <restrict>
639 <fileset dir="${dir}"/>
640 <not>
641 <name regex="${file-list}"/>
642 </not>
643 </restrict>
644 </delete>
645 <!-- Download plugins -->
646 <copy todir="${dir}" flatten="true">
647 <resourcelist>
648 <string value="${plugins}"/>
649 </resourcelist>
650 </copy>
651 <!-- Check plugins -->
652 <as:build-signatures destfile="${dir}/api.sig">
653 <path>
654 <fileset file="${dist.dir}/josm-custom-optimized.jar"/>
655 <fileset file="${java.home}/lib/rt.jar"/>
656 <fileset file="${java.home}/lib/jce.jar"/>
657 </path>
658 </as:build-signatures>
659 <as:check-signature signature="${dir}/api.sig">
660 <ignore classname="au.edu.*"/>
661 <ignore classname="au.com.*"/>
662 <ignore classname="com.*"/>
663 <ignore classname="de.miethxml.*"/>
664 <ignore classname="javafx.*"/>
665 <ignore classname="javax.*"/>
666 <ignore classname="jogamp.*"/>
667 <ignore classname="junit.*"/>
668 <ignore classname="net.sf.*"/>
669 <ignore classname="nu.xom.*"/>
670 <ignore classname="org.apache.*"/>
671 <ignore classname="org.codehaus.*"/>
672 <ignore classname="org.dom4j.*"/>
673 <ignore classname="org.hsqldb.*"/>
674 <ignore classname="org.ibex.*"/>
675 <ignore classname="org.iso_relax.*"/>
676 <ignore classname="org.jaitools.*"/>
677 <ignore classname="org.jaxen.*"/>
678 <ignore classname="org.jdom2.*"/>
679 <ignore classname="org.jgraph.*"/>
680 <ignore classname="org.joda.time.*"/>
681 <ignore classname="org.jvnet.staxex.*"/>
682 <ignore classname="org.kxml2.*"/>
683 <ignore classname="org.objectweb.*"/>
684 <ignore classname="org.python.*"/>
685 <ignore classname="org.slf4j.*"/>
686 <!-- plugins used by another ones -->
687 <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
688 <ignore classname="org.openstreetmap.josm.plugins.jna.*"/>
689 <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
690 <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
691 <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
692 <path path="${dir}"/>
693 </as:check-signature>
694 </target>
695
696 <macrodef name="_taginfo">
697 <attribute name="type"/>
698 <attribute name="output"/>
699 <sequential>
700 <echo message="Generating Taginfo for type @{type} to @{output}"/>
701 <groovy src="${taginfoextract}" classpath="${dist.dir}/josm-custom.jar:tools/findbugs/annotations.jar">
702 <arg value="-t"/>
703 <arg value="@{type}"/>
704 <arg value="--noexit"/>
705 <arg value="--svnweb"/>
706 <arg value="--imgurlprefix"/>
707 <arg value="${imgurlprefix}"/>
708 <arg value="-o"/>
709 <arg value="@{output}"/>
710 </groovy>
711 </sequential>
712 </macrodef>
713
714 <target name="taginfo" depends="dist">
715 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
716 <property name="taginfoextract" value="scripts/TagInfoExtract.groovy"/>
717 <property name="imgurlprefix" value="http://josm.openstreetmap.de/download/taginfo/taginfo-img"/>
718 <_taginfo type="mappaint" output="taginfo_style.json"/>
719 <_taginfo type="presets" output="taginfo_presets.json"/>
720 <_taginfo type="external_presets" output="taginfo_external_presets.json"/>
721 </target>
722
723 <target name="imageryindex" depends="init-properties">
724 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
725 <echo message="Checking editor imagery difference"/>
726 <groovy src="scripts/SyncEditorLayerIndex.groovy" classpath="${dist.dir}/josm-custom.jar">
727 <arg value="-noeli"/>
728 <arg value="-p"/>
729 <arg value="imagery_eliout.imagery.xml"/>
730 <arg value="-q"/>
731 <arg value="imagery_josmout.imagery.xml"/>
732 </groovy>
733 </target>
734
735 <target name="imageryindexdownload">
736 <exec append="false" executable="wget" failifexecutionfails="true">
737 <arg value="https://josm.openstreetmap.de/maps"/>
738 <arg value="-O"/>
739 <arg value="imagery_josm.imagery.xml"/>
740 <arg value="--unlink"/>
741 </exec>
742 <exec append="false" executable="wget" failifexecutionfails="true">
743 <arg value="https://josm.openstreetmap.de/wiki/ImageryCompareIgnores?format=txt"/>
744 <arg value="-O"/>
745 <arg value="imagery_josm.ignores.txt"/>
746 <arg value="--unlink"/>
747 </exec>
748 <exec append="false" executable="wget" failifexecutionfails="true">
749 <arg value="https://raw.githubusercontent.com/osmlab/editor-layer-index/gh-pages/imagery.geojson"/>
750 <arg value="-O"/>
751 <arg value="imagery_eli.geojson"/>
752 <arg value="--unlink"/>
753 </exec>
754 <antcall target="imageryindex"/>
755 </target>
756
757 <target name="checkstyle" depends="init-properties">
758 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
759 classpath="tools/checkstyle/checkstyle-all.jar"/>
760 <checkstyle config="tools/checkstyle/josm_checks.xml">
761 <fileset dir="${base.dir}/src/org/openstreetmap/josm" includes="**/*.java"
762 excludes="gui/mappaint/mapcss/parsergen/*.java"/>
763 <fileset dir="${base.dir}/test" includes="**/*.java"/>
764 <formatter type="plain"/>
765 <formatter type="xml" toFile="checkstyle-josm.xml"/>
766 </checkstyle>
767 </target>
768
769 <target name="findbugs" depends="dist">
770 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
771 <path id="findbugs-classpath">
772 <fileset dir="${base.dir}/tools/findbugs/">
773 <include name="*.jar"/>
774 </fileset>
775 </path>
776 <property name="findbugs-classpath" refid="findbugs-classpath"/>
777 <findbugs output="xml"
778 outputFile="findbugs-josm.xml"
779 classpath="${findbugs-classpath}"
780 pluginList=""
781 excludeFilter="tools/findbugs/josm-filter.xml"
782 effort="max"
783 reportLevel="low"
784 >
785 <sourcePath path="${base.dir}/src" />
786 <class location="${dist.dir}/josm-custom.jar" />
787 </findbugs>
788 </target>
789
790 <target name="pmd" depends="init-properties">
791 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpath="${toString:pmd.classpath}"/>
792 <pmd shortFilenames="true" encoding="UTF-8">
793 <sourceLanguage name="java" version="1.8" />
794 <ruleset>${base.dir}/tools/pmd/josm-ruleset.xml</ruleset>
795 <formatter type="text" toConsole="true" />
796 <formatter type="xml" toFile="pmd-josm.xml">
797 <param name="encoding" value="UTF-8" />
798 </formatter>
799 <fileset dir="${src.dir}">
800 <include name="org/openstreetmap/josm/**/*.java"/>
801 <exclude name="org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/*.java" />
802 </fileset>
803 </pmd>
804 </target>
805
806 <target name="run" depends="dist">
807 <java jar="${dist.dir}/josm-custom.jar" fork="true">
808 <arg value="--set=expert=true"/>
809 <arg value="--set=remotecontrol.enabled=true"/>
810 <arg value="--set=debug.edt-checker.enable=false"/>
811 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
812 </java>
813 </target>
814 <!--
815 ** Compile build script for generating projection list.
816 -->
817 <target name="epsg-compile" depends="init-properties">
818 <property name="proj-classpath" location="${build.dir}"/>
819 <mkdir dir="${proj-build.dir}"/>
820 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true"
821 destdir="${proj-build.dir}" target="1.8" source="1.8" debug="on"
822 includeantruntime="false" createMissingPackageInfoClass="false"
823 encoding="UTF-8" classpath="${proj-classpath}">
824 </javac>
825 </target>
826 <!--
827 ** generate projection list.
828 -->
829 <target name="epsg" depends="epsg-compile">
830 <touch file="${epsg.output}"/>
831 <java classname="BuildProjectionDefinitions" failonerror="true" fork="true">
832 <sysproperty key="java.awt.headless" value="true"/>
833 <classpath>
834 <pathelement path="${base.dir}"/>
835 <pathelement path="${proj-classpath}"/>
836 <pathelement path="${proj-build.dir}"/>
837 </classpath>
838 <arg value="${base.dir}"/>
839 </java>
840 </target>
841</project>
Note: See TracBrowser for help on using the repository browser.