source: josm/trunk/build.xml@ 12528

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

update build file

  • Property svn:eol-style set to native
File size: 43.7 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!-- ** build.xml - main ant file for JOSM
3**
4** To build run
5** ant clean
6** ant dist
7** This will create 'josm-custom.jar' in directory 'dist'. See also
8** https://josm.openstreetmap.de/wiki/DevelopersGuide/CreateBuild
9**
10-->
11<project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" xmlns:jacoco="antlib:org.jacoco.ant" xmlns:if="ant:if">
12 <target name="init-properties">
13 <!-- Load properties in a target and not at top level, so this build file can be
14 imported from an IDE ant file (Netbeans) without messing up IDE properties.
15 When imported from another file, ${basedir} will point to the parent directory
16 of the importing ant file. Use ${base.dir} instead, which is always the parent
17 directory of this file. -->
18 <dirname property="base.dir" file="${ant.file.josm}"/>
19 <property name="test.dir" location="${base.dir}/test"/>
20 <property name="src.dir" location="${base.dir}/src"/>
21 <property name="build.dir" location="${base.dir}/build"/>
22 <property name="dist.dir" location="${base.dir}/dist"/>
23 <property name="javacc.home" location="${base.dir}/tools"/>
24 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
25 <property name="proj-build.dir" location="${base.dir}/build2"/>
26 <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/>
27 <property name="groovy.jar" location="${base.dir}/tools/groovy-all.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, functional and performance 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 <call-junit testfamily="performance" coverage="false"/>
493 </target>
494 <target name="test-it" depends="test-compile" unless="test-it.notRequired"
495 description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
496 <call-junit testfamily="unit" testITsuffix="IT"/>
497 <call-junit testfamily="functional" testITsuffix="IT"/>
498 <call-junit testfamily="performance" testITsuffix="IT" coverage="false"/>
499 </target>
500 <target name="test-html" depends="test, test-it" description="Generate HTML test reports">
501 <!-- May require additional ant dependencies like ant-trax package -->
502 <junitreport todir="${test.dir}/report">
503 <fileset dir="${test.dir}/report">
504 <include name="TEST-*.xml"/>
505 </fileset>
506 <report todir="${test.dir}/report/html"/>
507 </junitreport>
508 <jacoco:report>
509 <executiondata>
510 <fileset dir="${test.dir}" includes="*.exec"/>
511 </executiondata>
512 <structure name="JOSM Test Coverage">
513 <classfiles>
514 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
515 </classfiles>
516 <sourcefiles encoding="UTF-8">
517 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
518 </sourcefiles>
519 </structure>
520 <html destdir="${test.dir}/report/jacoco"/>
521 </jacoco:report>
522 </target>
523 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
524 <target name="dist-optimized" depends="dist" unless="isJava9">
525 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
526 <proguard>
527 -injars dist/josm-custom.jar
528 -outjars dist/josm-custom-optimized.jar
529
530 -libraryjars ${java.home}/lib/rt.jar
531 -libraryjars ${java.home}/lib/jce.jar
532 -libraryjars ${java.home}/lib/ext/jfxrt.jar
533
534 -dontoptimize
535 -dontobfuscate
536
537 # These options probably are not necessary (and make processing a bit slower)
538 -dontskipnonpubliclibraryclasses
539 -dontskipnonpubliclibraryclassmembers
540
541 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
542 public static void main(java.lang.String[]);
543 }
544
545 -keep class * extends org.openstreetmap.josm.io.FileImporter
546 -keep class * extends org.openstreetmap.josm.io.FileExporter
547 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
548 -keep class org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory$PseudoClasses {
549 static boolean *(org.openstreetmap.josm.gui.mappaint.Environment);
550 }
551 -keep class org.apache.commons.logging.impl.*
552
553 -keepclassmembers enum * {
554 public static **[] values();
555 public static ** valueOf(java.lang.String);
556 }
557
558 # Keep unused public methods (can be useful for plugins)
559 -keepclassmembers class * {
560 public protected *;
561 }
562
563 # Keep serialization methods
564 -keepclassmembers class * implements java.io.Serializable {
565 private void writeObject(java.io.ObjectOutputStream);
566 private void readObject(java.io.ObjectInputStream);
567 }
568
569 # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
570 # This note should not be a problem as we don't use obfuscation
571 -dontnote
572 </proguard>
573 </target>
574 <!-- Proguard does not support Java 9 : http://sourceforge.net/p/proguard/bugs/551/ -->
575 <target name="dist-optimized-report" depends="dist-optimized" unless="isJava9">
576 <!-- generate difference report between optimized jar and normal one -->
577 <exec executable="perl" dir="${basedir}">
578 <arg value="tools/japicc/japi-compliance-checker.pl"/>
579 <arg value="--lib=JOSM"/>
580 <arg value="--keep-internal"/>
581 <arg value="--v1=${version.entry.commit.revision}"/>
582 <arg value="--v2=${version.entry.commit.revision}-optimized"/>
583 <arg value="--report-path=${dist.dir}/compat_report.html"/>
584 <arg value="${dist.dir}/josm-custom.jar"/>
585 <arg value="${dist.dir}/josm-custom-optimized.jar"/>
586 </exec>
587 </target>
588 <target name="check-plugins" depends="dist-optimized">
589 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
590 <local name="dir"/>
591 <local name="plugins"/>
592 <property name="dir" value="plugin-check"/>
593 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
594 <classpath path="tools/animal-sniffer-ant-tasks-1.15.jar"/>
595 </typedef>
596 <mkdir dir="${dir}"/>
597 <!-- List of deprecated plugins -->
598 <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
599 <filterchain>
600 <linecontains>
601 <contains value="new DeprecatedPlugin("/>
602 </linecontains>
603 <tokenfilter>
604 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
605 </tokenfilter>
606 <striplinebreaks/>
607 <tokenfilter>
608 <replaceregex pattern="\|$" replace="" flags="gi"/>
609 </tokenfilter>
610 </filterchain>
611 </loadfile>
612 <!-- Download list of plugins -->
613 <loadresource property="plugins">
614 <url url="https://josm.openstreetmap.de/plugin"/>
615 <filterchain>
616 <linecontainsregexp negate="true">
617 <regexp pattern="^\t.*"/>
618 </linecontainsregexp>
619 <linecontainsregexp negate="true">
620 <regexp pattern="${deprecated-plugins}"/>
621 </linecontainsregexp>
622 <tokenfilter>
623 <replaceregex pattern="^.*;" replace="" flags="gi"/>
624 </tokenfilter>
625 </filterchain>
626 </loadresource>
627 <!-- Delete files that are not in plugin list (like old plugins) -->
628 <loadresource property="file-list">
629 <propertyresource name="plugins"/>
630 <filterchain>
631 <tokenfilter>
632 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
633 </tokenfilter>
634 <striplinebreaks/>
635 <tokenfilter>
636 <replaceregex pattern="\|$" replace="" flags="gi"/>
637 </tokenfilter>
638 </filterchain>
639 </loadresource>
640 <delete>
641 <restrict>
642 <fileset dir="${dir}"/>
643 <not>
644 <name regex="${file-list}"/>
645 </not>
646 </restrict>
647 </delete>
648 <!-- Download plugins -->
649 <copy todir="${dir}" flatten="true">
650 <resourcelist>
651 <string value="${plugins}"/>
652 </resourcelist>
653 </copy>
654 <!-- Check plugins -->
655 <as:build-signatures destfile="${dir}/api.sig">
656 <path>
657 <fileset file="${dist.dir}/josm-custom-optimized.jar"/>
658 <fileset file="${java.home}/lib/rt.jar"/>
659 <fileset file="${java.home}/lib/jce.jar"/>
660 </path>
661 </as:build-signatures>
662 <as:check-signature signature="${dir}/api.sig">
663 <ignore classname="au.edu.*"/>
664 <ignore classname="au.com.*"/>
665 <ignore classname="com.*"/>
666 <ignore classname="de.miethxml.*"/>
667 <ignore classname="javafx.*"/>
668 <ignore classname="javax.*"/>
669 <ignore classname="jogamp.*"/>
670 <ignore classname="junit.*"/>
671 <ignore classname="net.sf.*"/>
672 <ignore classname="nu.xom.*"/>
673 <ignore classname="org.apache.*"/>
674 <ignore classname="org.codehaus.*"/>
675 <ignore classname="org.dom4j.*"/>
676 <ignore classname="org.hsqldb.*"/>
677 <ignore classname="org.ibex.*"/>
678 <ignore classname="org.iso_relax.*"/>
679 <ignore classname="org.jaitools.*"/>
680 <ignore classname="org.jaxen.*"/>
681 <ignore classname="org.jdom2.*"/>
682 <ignore classname="org.jgraph.*"/>
683 <ignore classname="org.joda.time.*"/>
684 <ignore classname="org.jvnet.staxex.*"/>
685 <ignore classname="org.kxml2.*"/>
686 <ignore classname="org.objectweb.*"/>
687 <ignore classname="org.python.*"/>
688 <ignore classname="org.slf4j.*"/>
689 <!-- plugins used by another ones -->
690 <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
691 <ignore classname="org.openstreetmap.josm.plugins.jna.*"/>
692 <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
693 <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
694 <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
695 <path path="${dir}"/>
696 </as:check-signature>
697 </target>
698
699 <macrodef name="_taginfo">
700 <attribute name="type"/>
701 <attribute name="output"/>
702 <sequential>
703 <echo message="Generating Taginfo for type @{type} to @{output}"/>
704 <groovy src="${taginfoextract}" classpath="${dist.dir}/josm-custom.jar:tools/findbugs/annotations.jar">
705 <arg value="-t"/>
706 <arg value="@{type}"/>
707 <arg value="--noexit"/>
708 <arg value="--svnweb"/>
709 <arg value="--imgurlprefix"/>
710 <arg value="${imgurlprefix}"/>
711 <arg value="-o"/>
712 <arg value="@{output}"/>
713 </groovy>
714 </sequential>
715 </macrodef>
716
717 <target name="taginfo" depends="dist">
718 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
719 <property name="taginfoextract" value="scripts/TagInfoExtract.groovy"/>
720 <property name="imgurlprefix" value="http://josm.openstreetmap.de/download/taginfo/taginfo-img"/>
721 <_taginfo type="mappaint" output="taginfo_style.json"/>
722 <_taginfo type="presets" output="taginfo_presets.json"/>
723 <_taginfo type="external_presets" output="taginfo_external_presets.json"/>
724 </target>
725
726 <target name="imageryindex" depends="init-properties">
727 <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy.jar};tools/commons-cli-1.3.1.jar"/>
728 <echo message="Checking editor imagery difference"/>
729 <groovy src="scripts/SyncEditorLayerIndex.groovy" classpath="${dist.dir}/josm-custom.jar">
730 <arg value="-noeli"/>
731 <arg value="-p"/>
732 <arg value="imagery_eliout.imagery.xml"/>
733 <arg value="-q"/>
734 <arg value="imagery_josmout.imagery.xml"/>
735 </groovy>
736 </target>
737
738 <target name="imageryindexdownload">
739 <exec append="false" executable="wget" failifexecutionfails="true">
740 <arg value="https://josm.openstreetmap.de/maps"/>
741 <arg value="-O"/>
742 <arg value="imagery_josm.imagery.xml"/>
743 <arg value="--unlink"/>
744 </exec>
745 <exec append="false" executable="wget" failifexecutionfails="true">
746 <arg value="https://josm.openstreetmap.de/wiki/ImageryCompareIgnores?format=txt"/>
747 <arg value="-O"/>
748 <arg value="imagery_josm.ignores.txt"/>
749 <arg value="--unlink"/>
750 </exec>
751 <exec append="false" executable="wget" failifexecutionfails="true">
752 <arg value="https://raw.githubusercontent.com/osmlab/editor-layer-index/gh-pages/imagery.geojson"/>
753 <arg value="-O"/>
754 <arg value="imagery_eli.geojson"/>
755 <arg value="--unlink"/>
756 </exec>
757 <antcall target="imageryindex"/>
758 </target>
759
760 <target name="checkstyle" depends="init-properties">
761 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
762 classpath="tools/checkstyle/checkstyle-all.jar"/>
763 <checkstyle config="tools/checkstyle/josm_checks.xml">
764 <fileset dir="${base.dir}/src/org/openstreetmap/josm" includes="**/*.java"
765 excludes="gui/mappaint/mapcss/parsergen/*.java"/>
766 <fileset dir="${base.dir}/test" includes="**/*.java"/>
767 <formatter type="plain"/>
768 <formatter type="xml" toFile="checkstyle-josm.xml"/>
769 </checkstyle>
770 </target>
771
772 <target name="findbugs" depends="dist">
773 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
774 <path id="findbugs-classpath">
775 <fileset dir="${base.dir}/tools/findbugs/">
776 <include name="*.jar"/>
777 </fileset>
778 </path>
779 <property name="findbugs-classpath" refid="findbugs-classpath"/>
780 <findbugs output="xml"
781 outputFile="findbugs-josm.xml"
782 classpath="${findbugs-classpath}"
783 pluginList=""
784 excludeFilter="tools/findbugs/josm-filter.xml"
785 effort="max"
786 reportLevel="low"
787 >
788 <sourcePath path="${base.dir}/src" />
789 <class location="${dist.dir}/josm-custom.jar" />
790 </findbugs>
791 </target>
792
793 <target name="pmd" depends="init-properties">
794 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpath="${toString:pmd.classpath}"/>
795 <pmd shortFilenames="true" encoding="UTF-8">
796 <sourceLanguage name="java" version="1.8" />
797 <ruleset>${base.dir}/tools/pmd/josm-ruleset.xml</ruleset>
798 <formatter type="text" toConsole="true" />
799 <formatter type="xml" toFile="pmd-josm.xml">
800 <param name="encoding" value="UTF-8" />
801 </formatter>
802 <fileset dir="${src.dir}">
803 <include name="org/openstreetmap/josm/**/*.java"/>
804 <exclude name="org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/*.java" />
805 </fileset>
806 </pmd>
807 </target>
808
809 <target name="run" depends="dist">
810 <java jar="${dist.dir}/josm-custom.jar" fork="true">
811 <arg value="--set=expert=true"/>
812 <arg value="--set=remotecontrol.enabled=true"/>
813 <arg value="--set=debug.edt-checker.enable=false"/>
814 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
815 </java>
816 </target>
817 <!--
818 ** Compile build script for generating projection list.
819 -->
820 <target name="epsg-compile" depends="init-properties">
821 <property name="proj-classpath" location="${build.dir}"/>
822 <mkdir dir="${proj-build.dir}"/>
823 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true"
824 destdir="${proj-build.dir}" target="1.8" source="1.8" debug="on"
825 includeantruntime="false" createMissingPackageInfoClass="false"
826 encoding="UTF-8" classpath="${proj-classpath}">
827 </javac>
828 </target>
829 <!--
830 ** generate projection list.
831 -->
832 <target name="epsg" depends="epsg-compile">
833 <touch file="${epsg.output}"/>
834 <java classname="BuildProjectionDefinitions" failonerror="true" fork="true">
835 <sysproperty key="java.awt.headless" value="true"/>
836 <classpath>
837 <pathelement path="${base.dir}"/>
838 <pathelement path="${proj-classpath}"/>
839 <pathelement path="${proj-build.dir}"/>
840 </classpath>
841 <arg value="${base.dir}"/>
842 </java>
843 </target>
844</project>
Note: See TracBrowser for help on using the repository browser.