source: josm/trunk/build.xml@ 6216

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

see #8654 - New target distmac7 to build Mac OS X package for Oracle Java 7

File size: 19.5 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 ** Creates the REVISION file to be included in the distribution
40 -->
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}"/>
56 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
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>
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">
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) -->
101 <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
102 <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
103 </jar>
104 </target>
105 <!-- Compatibility Mac OS X target for Java 6 (incompatible with new on for Java 7, see #8654, #9035) -->
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>
119 <!-- New Mac OS X target for Java 7 -->
120 <target name="distmac7" depends="dist">
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 -->
124 <bundleapp outputdirectory="dist" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
125 mainclassname="org.openstreetmap.josm.gui.MainApplication"
126 applicationCategory="public.app-category.utilities"
127 shortversion="${version.entry.commit.revision} SVN"
128 version="${version.entry.commit.revision} SVN"
129 icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
130 highResolutionCapable="false">
131
132 <arch name="x86_64"/>
133 <arch name="i386"/>
134
135 <classpath file="dist/josm-custom.jar"/>
136
137 <option value="-Xmx512m"/>
138
139 <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
140 <option value="-Xdock:name=JOSM"/>
141
142 <!-- OSX specific options, optional -->
143 <option value="-Dapple.laf.useScreenMenuBar=true"/>
144 <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
145 <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
146 <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
147 <option value="-Dcom.apple.smallTabs=true"/>
148 </bundleapp>
149
150 <!-- create ZIP file with MacOS X application bundle -->
151 <zip destfile="dist/josm-custom-macosx-java7.zip" update="true">
152 <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
153 <zipfileset dir="dist" includes="JOSM.app/**/*" filemode="755" />
154 </zip>
155 </target>
156 <target name="javacc" depends="init" unless="javacc.notRequired">
157 <mkdir dir="${mapcss.dir}/parsergen"/>
158 <exec append="false" executable="java" failifexecutionfails="true">
159 <arg value="-cp"/>
160 <arg value="${javacc.home}/javacc.jar"/>
161 <arg value="javacc"/>
162 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
163 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
164 </exec>
165<!-- <javacc target="${mapcss.dir}/MapCSSParser.jj" javacchome="${javacc.home}" outputdirectory="${mapcss.dir}/parsergen"/>-->
166 </target>
167 <target name="compile" depends="init,javacc">
168 <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"/>
169 <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">
170 <compilerarg value="-Xlint:deprecation"/>
171 <compilerarg value="-Xlint:unchecked"/>
172 </javac>
173 </target>
174 <target name="init">
175 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
176 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
177 </uptodate>
178 <mkdir dir="build"/>
179 <mkdir dir="dist"/>
180 </target>
181 <target name="javadoc">
182 <javadoc destdir="javadoc"
183 sourcepath="src"
184 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
185 windowtitle="JOSM"
186 use="true"
187 private="true"
188 linksource="true"
189 author="false">
190 <link href="http://docs.oracle.com/javase/6/docs/api"/>
191 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
192 <bottom><![CDATA[<a href="http://josm.openstreetmap.de/">JOSM</a>]]></bottom>
193 </javadoc>
194 </target>
195 <target name="clean">
196 <delete dir="build"/>
197 <delete dir="dist"/>
198 <delete dir="${mapcss.dir}/parsergen"/>
199 </target>
200 <path id="test.classpath">
201 <fileset dir="${test.dir}/lib">
202 <include name="**/*.jar"/>
203 </fileset>
204 <fileset dir="lib">
205 <include name="**/*.jar"/>
206 </fileset>
207 <pathelement path="dist/josm-custom.jar"/>
208 </path>
209 <target name="test-init">
210 <mkdir dir="${test.dir}/build"/>
211 <mkdir dir="${test.dir}/report"/>
212 </target>
213 <target name="test-clean">
214 <delete dir="${test.dir}/build"/>
215 <delete dir="${test.dir}/report"/>
216 <delete file="${test.dir}/jacoco.exec" />
217 </target>
218 <target name="test-compile" depends="test-init,dist">
219 <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">
220 <compilerarg value="-Xlint:deprecation"/>
221 <compilerarg value="-Xlint:unchecked"/>
222 </javac>
223 <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">
224 <compilerarg value="-Xlint:deprecation"/>
225 <compilerarg value="-Xlint:unchecked"/>
226 </javac>
227 </target>
228 <target name="test" depends="test-compile">
229 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
230 <jacoco:coverage destfile="${test.dir}/jacoco.exec">
231 <junit printsummary="yes" fork="true" forkmode="once">
232 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
233 <sysproperty key="josm.test.data" value="${test.dir}/data"/>
234 <sysproperty key="java.awt.headless" value="true"/>
235 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
236 <classpath>
237 <path refid="test.classpath"/>
238 <pathelement path="${test.dir}/build"/>
239 <pathelement path="${test.dir}/config"/>
240 </classpath>
241 <formatter type="plain"/>
242 <formatter type="xml"/>
243 <batchtest fork="yes" todir="${test.dir}/report">
244 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
245 </batchtest>
246 </junit>
247 </jacoco:coverage>
248 </target>
249 <target name="test-html" depends="test" description="Generate HTML test reports">
250 <!-- May require additional ant dependencies like ant-trax package -->
251 <junitreport todir="${test.dir}/report">
252 <fileset dir="${test.dir}/report">
253 <include name="TEST-*.xml"/>
254 </fileset>
255 <report todir="${test.dir}/report/html"/>
256 </junitreport>
257 <jacoco:report>
258 <executiondata>
259 <file file="${test.dir}/jacoco.exec"/>
260 </executiondata>
261 <structure name="JOSM Test Coverage">
262 <classfiles>
263 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
264 </classfiles>
265 <sourcefiles encoding="UTF-8">
266 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
267 </sourcefiles>
268 </structure>
269 <html destdir="${test.dir}/report/jacoco"/>
270 </jacoco:report>
271 </target>
272 <target name="dist-optimized" depends="dist">
273 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
274 <proguard>
275 -injars dist/josm-custom.jar
276 -outjars dist/josm-custom-optimized.jar
277
278 -libraryjars ${java.home}/lib/rt.jar
279 -libraryjars ${java.home}/lib/jce.jar
280
281 -dontoptimize
282 -dontobfuscate
283
284 # These options probably are not necessary (and make processing a bit slower)
285 -dontskipnonpubliclibraryclasses
286 -dontskipnonpubliclibraryclassmembers
287
288 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
289 public static void main(java.lang.String[]);
290 }
291 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
292
293 -keep class JOSM
294 -keep class * extends org.openstreetmap.josm.io.FileImporter
295 -keep class * extends org.openstreetmap.josm.io.FileExporter
296 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
297 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
298
299 -keepclassmembers enum * {
300 public static **[] values();
301 public static ** valueOf(java.lang.String);
302 }
303
304 # Keep unused public methods (can be useful for plugins)
305 -keepclassmembers class * {
306 public protected *;
307 }
308
309 # 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
310 -dontnote
311 </proguard>
312 </target>
313 <target name="check-plugins" depends="dist-optimized">
314 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
315 <local name="dir"/>
316 <local name="plugins"/>
317 <property name="dir" value="plugin-check"/>
318 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
319 <classpath path="tools/animal-sniffer-ant-tasks-1.8.jar"/>
320 </typedef>
321 <mkdir dir="${dir}"/>
322 <!-- List of deprecated plugins -->
323 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
324 <filterchain>
325 <linecontains>
326 <contains value="new DeprecatedPlugin("/>
327 </linecontains>
328 <tokenfilter>
329 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
330 </tokenfilter>
331 <striplinebreaks/>
332 <tokenfilter>
333 <replaceregex pattern="\|$" replace="" flags="gi"/>
334 </tokenfilter>
335 </filterchain>
336 </loadfile>
337 <!-- Download list of plugins -->
338 <loadresource property="plugins">
339 <url url="http://josm.openstreetmap.de/plugin"/>
340 <filterchain>
341 <linecontainsregexp negate="true">
342 <regexp pattern="^\t.*"/>
343 </linecontainsregexp>
344 <linecontainsregexp negate="true">
345 <regexp pattern="${deprecated-plugins}"/>
346 </linecontainsregexp>
347 <tokenfilter>
348 <replaceregex pattern="^.*;" replace="" flags="gi"/>
349 </tokenfilter>
350 </filterchain>
351 </loadresource>
352 <!-- Delete files that are not in plugin list (like old plugins) -->
353 <loadresource property="file-list">
354 <propertyresource name="plugins"/>
355 <filterchain>
356 <tokenfilter>
357 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
358 </tokenfilter>
359 <striplinebreaks/>
360 <tokenfilter>
361 <replaceregex pattern="\|$" replace="" flags="gi"/>
362 </tokenfilter>
363 </filterchain>
364 </loadresource>
365 <delete>
366 <restrict>
367 <fileset dir="${dir}"/>
368 <not>
369 <name regex="${file-list}"/>
370 </not>
371 </restrict>
372 </delete>
373 <!-- Download plugins -->
374 <copy todir="${dir}" flatten="true">
375 <resourcelist>
376 <string value="${plugins}"/>
377 </resourcelist>
378 </copy>
379 <!-- Check plugins -->
380 <as:build-signatures destfile="${dir}/api.sig">
381 <path>
382 <fileset file="dist/josm-custom-optimized.jar"/>
383 <fileset file="${java.home}/lib/rt.jar"/>
384 <fileset file="${java.home}/lib/jce.jar"/>
385 </path>
386 </as:build-signatures>
387 <as:check-signature signature="${dir}/api.sig">
388 <ignore classname="org.jgraph.*"/>
389 <ignore classname="com.touchgraph.*"/>
390 <ignore classname="com.sun.xml.fastinfoset.*"/>
391 <ignore classname="javax.jms.*"/>
392 <ignore classname="org.jvnet.staxex.*"/>
393 <ignore classname="javax.mail.*"/>
394 <ignore classname="com.sun.jdmk.*"/>
395 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
396 <ignore classname="org.apache.log.*"/>
397 <ignore classname="junit.*"/>
398 <path path="${dir}"/>
399 </as:check-signature>
400 </target>
401
402 <target name="findbugs" depends="dist">
403 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
404 <path id="findbugs-classpath">
405 <fileset dir="tools/findbugs/">
406 <include name="*.jar"/>
407 </fileset>
408 </path>
409 <property name="findbugs-classpath" refid="findbugs-classpath"/>
410 <findbugs output="xml"
411 outputFile="findbugs-josm.xml"
412 classpath="${findbugs-classpath}"
413 pluginList=""
414 excludeFilter="tools/findbugs/josm-filter.xml"
415 effort="max"
416 >
417 <sourcePath path="${basedir}/src" />
418 <class location="${basedir}/dist/josm-custom.jar" />
419 </findbugs>
420 </target>
421 <target name="run" depends="dist">
422 <java jar="dist/josm-custom.jar" fork="true">
423 <arg value="--set=expert=true"/>
424 <arg value="--set=remotecontrol.enabled=true"/>
425 <arg value="--set=debug.edt-checker.enable=false"/>
426 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
427 </java>
428 </target>
429
430</project>
Note: See TracBrowser for help on using the repository browser.