source: josm/trunk/build.xml@ 11713

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

add Ant target to run PMD (only few rules for now), fix violations

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