source: josm/trunk/build.xml@ 12212

Last change on this file since 12212 was 12205, checked in by Don-vip, 8 years ago

see #11924 - add Add-Exports / Add-Opens manifest entries so the corresponding command line arguments (--add-exports / --add-opens) are not needed anymore

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