source: josm/trunk/build.xml@ 11682

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

remove tab

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