source: josm/trunk/build.xml@ 11526

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

remove checkstyle version number to easy integration with checkstyle itself - see https://github.com/checkstyle/checkstyle/pull/3783

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