source: josm/trunk/build.xml@ 12198

Last change on this file since 12198 was 12039, checked in by bastiK, 8 years ago

fix ant compile (update in apache commons compress)

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