source: josm/trunk/build.xml@ 11993

Last change on this file since 11993 was 11965, checked in by stoecker, 8 years ago

ELI sync - unify filenames (also support loading in imagery index plugin)

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