source: josm/trunk/build.xml@ 9765

Last change on this file since 9765 was 9765, checked in by bastiK, 8 years ago

new setup of the netbeans project

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