source: josm/trunk/build.xml@ 7001

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

see #8465 - switch core to Java 7

File size: 20.7 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!-- ** build.xml - main ant file for JOSM
3**
4** To build run
5** ant clean
6** ant dist
7** This will create 'josm-custom.jar' in directory 'dist'. See also
8** https://josm.openstreetmap.de/wiki/CreateBuild
9**
10-->
11<project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
12 <property name="test.dir" location="test"/>
13 <property name="src.dir" location="src"/>
14 <property name="build.dir" location="build"/>
15 <property name="javacc.home" location="tools"/>
16 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
17 <!-- build parameter: compression level (ant -Dclevel=N)
18 N ranges from 0 (no compression) to 9 (maximum compression)
19 default: 9 -->
20 <condition property="clevel" value="${clevel}" else="9">
21 <isset property="clevel"/>
22 </condition>
23 <!-- Java classpath addition (all jar files to compile tests with this) -->
24 <path id="classpath">
25 <fileset dir="lib">
26 <include name="**/*.jar"/>
27 </fileset>
28 </path>
29
30 <!--
31 ** Used by Eclipse ant builder for updating
32 ** the REVISION file used by JOSM
33 -->
34 <target name="create-revision-eclipse">
35 <property name="revision.dir" value="bin"/>
36 <antcall target="create-revision"/>
37 </target>
38 <!--
39 ** Initializes the REVISION.XML file from SVN information
40 -->
41 <target name="init-svn-revision-xml">
42 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false" resultproperty="svn.info.result">
43 <env key="LANG" value="C"/>
44 <arg value="info"/>
45 <arg value="--xml"/>
46 <arg value="."/>
47 </exec>
48 <condition property="svn.info.success">
49 <equals arg1="${svn.info.result}" arg2="0" />
50 </condition>
51 </target>
52 <!--
53 ** Initializes the REVISION.XML file from git information
54 -->
55 <target name="init-git-revision-xml" unless="svn.info.success">
56 <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false">
57 <arg value="log"/>
58 <arg value="-1"/>
59 <arg value="--grep=git-svn-id"/>
60 <!--
61 %B: raw body (unwrapped subject and body)
62 %n: new line
63 %ai: author date, ISO 8601 format
64 -->
65 <arg value="--pretty=format:%B%n%ai"/>
66 <arg value="HEAD"/>
67 </exec>
68 <replaceregexp file="REVISION.XML" flags="s"
69 match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
70 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;"/>
71 </target>
72 <!--
73 ** Creates the REVISION file to be included in the distribution
74 -->
75 <target name="create-revision" depends="init-svn-revision-xml, init-git-revision-xml">
76 <property name="revision.dir" value="${build.dir}"/>
77 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
78 <delete file="REVISION.XML"/>
79 <tstamp>
80 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
81 </tstamp>
82 <property name="version.entry.commit.revision" value="UNKNOWN"/>
83 <property name="version.entry.commit.date" value="UNKNOWN"/>
84 <mkdir dir="${revision.dir}"/>
85 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
86 <echo file="${revision.dir}/REVISION">
87# automatically generated by JOSM build.xml - do not edit
88Revision: ${version.entry.commit.revision}
89Is-Local-Build: true
90Build-Date: ${build.tstamp}
91</echo>
92 </target>
93 <!--
94 ** Check internal XML files against their XSD
95 -->
96 <target name="check-schemas">
97 <schemavalidate file="data/defaultpresets.xml" >
98 <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
99 </schemavalidate>
100 <schemavalidate file="styles/standard/elemstyles.xml" >
101 <schema namespace="http://josm.openstreetmap.de/mappaint-style-1.0" file="data/mappaint-style.xsd" />
102 </schemavalidate>
103 </target>
104 <!--
105 ** Main target that builds JOSM and checks XML against schemas
106 -->
107 <target name="dist" depends="compile,create-revision,check-schemas">
108 <echo>Revision ${version.entry.commit.revision}</echo>
109 <copy file="CONTRIBUTION" todir="build"/>
110 <copy file="README" todir="build"/>
111 <copy file="LICENSE" todir="build"/>
112 <!-- create josm-custom.jar -->
113 <delete file="dist/josm-custom.jar"/>
114 <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
115 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
116 <manifest>
117 <attribute name="Main-class" value="JOSM"/>
118 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
119 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
120 <attribute name="Permissions" value="all-permissions"/>
121 <attribute name="Codebase" value="josm.openstreetmap.de"/>
122 <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
123 </manifest>
124 <zipfileset dir="images" prefix="images"/>
125 <zipfileset dir="data" prefix="data"/>
126 <zipfileset dir="styles" prefix="styles"/>
127 <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
128 <!-- All jar files necessary to run only JOSM (no tests) -->
129 <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
130 <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
131 </jar>
132 </target>
133 <!-- Mac OS X target -->
134 <target name="mac">
135 <!-- Using https://bitbucket.org/infinitekind/appbundler to create mac application bundle -->
136 <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="tools/appbundler-1.0ea.jar"/>
137 <!-- create MacOS X application bundle -->
138 <bundleapp outputdirectory="${bundle.outdir}" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
139 mainclassname="org.openstreetmap.josm.gui.MainApplication"
140 copyright="JOSM, and all its integral parts, are released under the GNU General Public License v2 or later"
141 applicationCategory="public.app-category.utilities"
142 shortversion="${version.entry.commit.revision} SVN"
143 version="${version.entry.commit.revision} SVN"
144 icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
145 highResolutionCapable="true">
146
147 <arch name="x86_64"/>
148 <arch name="i386"/>
149
150 <classpath file="${bundle.jar}"/>
151
152 <option value="-Xmx512m"/>
153
154 <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
155 <option value="-Xdock:name=JOSM"/>
156
157 <!-- OSX specific options, optional -->
158 <option value="-Dapple.laf.useScreenMenuBar=true"/>
159 <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
160 <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
161 <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
162 <option value="-Dcom.apple.smallTabs=true"/>
163 </bundleapp>
164
165 <!-- appbundler lacks the possibility of defining our own keys or using a template, so update the .plist manually -->
166 <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="tools/xmltask.jar"/>
167
168 <xmltask source="${bundle.outdir}/JOSM.app/Contents/Info.plist" dest="${bundle.outdir}/JOSM.app/Contents/Info.plist" indent="false">
169 <insert position="before" path="/plist/dict/key[1]"><![CDATA[<key>CFBundleAllowMixedLocalizations</key>
170<string>true</string>
171]]></insert>
172 </xmltask>
173
174 <!-- create ZIP file with MacOS X application bundle -->
175 <zip destfile="${bundle.outdir}/josm-custom-macosx.zip" update="true">
176 <zipfileset dir="." includes="CONTRIBUTION README LICENSE"/>
177 <zipfileset dir="${bundle.outdir}" includes="JOSM.app/**/*" filemode="755" />
178 </zip>
179 </target>
180 <target name="distmac" depends="dist">
181 <antcall target="mac">
182 <param name="bundle.outdir" value="dist"/>
183 <param name="bundle.jar" value="dist/josm-custom.jar"/>
184 </antcall>
185 </target>
186 <target name="javacc" depends="init" unless="javacc.notRequired">
187 <mkdir dir="${mapcss.dir}/parsergen"/>
188 <exec append="false" executable="java" failifexecutionfails="true">
189 <arg value="-cp"/>
190 <arg value="${javacc.home}/javacc.jar"/>
191 <arg value="javacc"/>
192 <arg value="-JDK_VERSION=1.7"/>
193 <arg value="-GRAMMAR_ENCODING=UTF-8"/>
194 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
195 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
196 </exec>
197 </target>
198 <target name="compile" depends="init,javacc">
199 <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" encoding="iso-8859-1"/>
200 <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" encoding="UTF-8">
201 <compilerarg value="-Xlint:deprecation"/>
202 <compilerarg value="-Xlint:unchecked"/>
203 </javac>
204 <copy todir="build" failonerror="no" includeemptydirs="no">
205 <fileset dir="resources"/>
206 </copy>
207 </target>
208 <target name="init">
209 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
210 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
211 </uptodate>
212 <mkdir dir="build"/>
213 <mkdir dir="dist"/>
214 </target>
215 <target name="javadoc">
216 <javadoc destdir="javadoc"
217 sourcepath="src"
218 encoding="UTF-8"
219 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
220 windowtitle="JOSM"
221 use="true"
222 private="true"
223 linksource="true"
224 author="false">
225 <link href="http://docs.oracle.com/javase/7/docs/api"/>
226 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
227 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JOSM</a>]]></bottom>
228 </javadoc>
229 </target>
230 <target name="clean">
231 <delete dir="build"/>
232 <delete dir="dist"/>
233 <delete dir="${mapcss.dir}/parsergen"/>
234 </target>
235 <path id="test.classpath">
236 <fileset dir="${test.dir}/lib">
237 <include name="**/*.jar"/>
238 </fileset>
239 <fileset dir="lib">
240 <include name="**/*.jar"/>
241 </fileset>
242 <pathelement path="dist/josm-custom.jar"/>
243 </path>
244 <target name="test-init">
245 <mkdir dir="${test.dir}/build"/>
246 <mkdir dir="${test.dir}/report"/>
247 </target>
248 <target name="test-clean">
249 <delete dir="${test.dir}/build"/>
250 <delete dir="${test.dir}/report"/>
251 <delete file="${test.dir}/jacoco.exec" />
252 </target>
253 <target name="test-compile" depends="test-init,dist">
254 <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/build" target="1.7" source="1.7" debug="on" includeantruntime="false" encoding="UTF-8">
255 <compilerarg value="-Xlint:deprecation"/>
256 <compilerarg value="-Xlint:unchecked"/>
257 </javac>
258 <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/build" target="1.7" source="1.7" debug="on" includeantruntime="false" encoding="UTF-8">
259 <compilerarg value="-Xlint:deprecation"/>
260 <compilerarg value="-Xlint:unchecked"/>
261 </javac>
262 </target>
263 <target name="test" depends="test-compile">
264 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
265 <jacoco:coverage destfile="${test.dir}/jacoco.exec">
266 <junit printsummary="yes" fork="true" forkmode="once">
267 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
268 <sysproperty key="josm.test.data" value="${test.dir}/data"/>
269 <sysproperty key="java.awt.headless" value="true"/>
270 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
271 <classpath>
272 <path refid="test.classpath"/>
273 <pathelement path="${test.dir}/build"/>
274 <pathelement path="${test.dir}/config"/>
275 </classpath>
276 <formatter type="plain"/>
277 <formatter type="xml"/>
278 <batchtest fork="yes" todir="${test.dir}/report">
279 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
280 </batchtest>
281 </junit>
282 </jacoco:coverage>
283 </target>
284 <target name="test-html" depends="test" description="Generate HTML test reports">
285 <!-- May require additional ant dependencies like ant-trax package -->
286 <junitreport todir="${test.dir}/report">
287 <fileset dir="${test.dir}/report">
288 <include name="TEST-*.xml"/>
289 </fileset>
290 <report todir="${test.dir}/report/html"/>
291 </junitreport>
292 <jacoco:report>
293 <executiondata>
294 <file file="${test.dir}/jacoco.exec"/>
295 </executiondata>
296 <structure name="JOSM Test Coverage">
297 <classfiles>
298 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
299 </classfiles>
300 <sourcefiles encoding="UTF-8">
301 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
302 </sourcefiles>
303 </structure>
304 <html destdir="${test.dir}/report/jacoco"/>
305 </jacoco:report>
306 </target>
307 <target name="dist-optimized" depends="dist">
308 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
309 <proguard>
310 -injars dist/josm-custom.jar
311 -outjars dist/josm-custom-optimized.jar
312
313 -libraryjars ${java.home}/lib/rt.jar
314 -libraryjars ${java.home}/lib/jce.jar
315
316 -dontoptimize
317 -dontobfuscate
318
319 # These options probably are not necessary (and make processing a bit slower)
320 -dontskipnonpubliclibraryclasses
321 -dontskipnonpubliclibraryclassmembers
322
323 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
324 public static void main(java.lang.String[]);
325 }
326 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
327
328 -keep class JOSM
329 -keep class * extends org.openstreetmap.josm.io.FileImporter
330 -keep class * extends org.openstreetmap.josm.io.FileExporter
331 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
332 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
333
334 -keepclassmembers enum * {
335 public static **[] values();
336 public static ** valueOf(java.lang.String);
337 }
338
339 # Keep unused public methods (can be useful for plugins)
340 -keepclassmembers class * {
341 public protected *;
342 }
343
344 # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'. This notes should not be a problem as we don't use obfuscation
345 -dontnote
346 </proguard>
347 </target>
348 <target name="check-plugins" depends="dist-optimized">
349 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
350 <local name="dir"/>
351 <local name="plugins"/>
352 <property name="dir" value="plugin-check"/>
353 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
354 <classpath path="tools/animal-sniffer-ant-tasks-1.8.jar"/>
355 </typedef>
356 <mkdir dir="${dir}"/>
357 <!-- List of deprecated plugins -->
358 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
359 <filterchain>
360 <linecontains>
361 <contains value="new DeprecatedPlugin("/>
362 </linecontains>
363 <tokenfilter>
364 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
365 </tokenfilter>
366 <striplinebreaks/>
367 <tokenfilter>
368 <replaceregex pattern="\|$" replace="" flags="gi"/>
369 </tokenfilter>
370 </filterchain>
371 </loadfile>
372 <!-- Download list of plugins -->
373 <loadresource property="plugins">
374 <url url="https://josm.openstreetmap.de/plugin"/>
375 <filterchain>
376 <linecontainsregexp negate="true">
377 <regexp pattern="^\t.*"/>
378 </linecontainsregexp>
379 <linecontainsregexp negate="true">
380 <regexp pattern="${deprecated-plugins}"/>
381 </linecontainsregexp>
382 <tokenfilter>
383 <replaceregex pattern="^.*;" replace="" flags="gi"/>
384 </tokenfilter>
385 </filterchain>
386 </loadresource>
387 <!-- Delete files that are not in plugin list (like old plugins) -->
388 <loadresource property="file-list">
389 <propertyresource name="plugins"/>
390 <filterchain>
391 <tokenfilter>
392 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
393 </tokenfilter>
394 <striplinebreaks/>
395 <tokenfilter>
396 <replaceregex pattern="\|$" replace="" flags="gi"/>
397 </tokenfilter>
398 </filterchain>
399 </loadresource>
400 <delete>
401 <restrict>
402 <fileset dir="${dir}"/>
403 <not>
404 <name regex="${file-list}"/>
405 </not>
406 </restrict>
407 </delete>
408 <!-- Download plugins -->
409 <copy todir="${dir}" flatten="true">
410 <resourcelist>
411 <string value="${plugins}"/>
412 </resourcelist>
413 </copy>
414 <!-- Check plugins -->
415 <as:build-signatures destfile="${dir}/api.sig">
416 <path>
417 <fileset file="dist/josm-custom-optimized.jar"/>
418 <fileset file="${java.home}/lib/rt.jar"/>
419 <fileset file="${java.home}/lib/jce.jar"/>
420 </path>
421 </as:build-signatures>
422 <as:check-signature signature="${dir}/api.sig">
423 <ignore classname="org.jgraph.*"/>
424 <ignore classname="com.touchgraph.*"/>
425 <ignore classname="com.sun.xml.fastinfoset.*"/>
426 <ignore classname="javax.jms.*"/>
427 <ignore classname="org.jvnet.staxex.*"/>
428 <ignore classname="javax.mail.*"/>
429 <ignore classname="com.sun.jdmk.*"/>
430 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
431 <ignore classname="org.apache.log.*"/>
432 <ignore classname="junit.*"/>
433 <path path="${dir}"/>
434 </as:check-signature>
435 </target>
436
437 <target name="findbugs" depends="dist">
438 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
439 <path id="findbugs-classpath">
440 <fileset dir="tools/findbugs/">
441 <include name="*.jar"/>
442 </fileset>
443 </path>
444 <property name="findbugs-classpath" refid="findbugs-classpath"/>
445 <findbugs output="xml"
446 outputFile="findbugs-josm.xml"
447 classpath="${findbugs-classpath}"
448 pluginList=""
449 excludeFilter="tools/findbugs/josm-filter.xml"
450 effort="max"
451 >
452 <sourcePath path="${basedir}/src" />
453 <class location="${basedir}/dist/josm-custom.jar" />
454 </findbugs>
455 </target>
456 <target name="run" depends="dist">
457 <java jar="dist/josm-custom.jar" fork="true">
458 <arg value="--set=expert=true"/>
459 <arg value="--set=remotecontrol.enabled=true"/>
460 <arg value="--set=debug.edt-checker.enable=false"/>
461 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
462 </java>
463 </target>
464
465</project>
Note: See TracBrowser for help on using the repository browser.