source: josm/trunk/build.xml@ 10833

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

see #13232 - cleanup classpath/build: exclude unneeded Commons JCS classes

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