source: josm/trunk/build.xml@ 6286

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

see #8654 - Make Mac OS X Java 7 package closer to former package

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