source: josm/trunk/build.xml@ 12579

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

new ant target for performance tests

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