source: josm/trunk/build.xml@ 5513

Last change on this file since 5513 was 5502, checked in by Don-vip, 12 years ago

fix some compilation warnings

File size: 15.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/CreateBuild
9**
10**
11-->
12<project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" basedir=".">
13 <property name="test.dir" location="test"/>
14 <property name="src.dir" location="src"/>
15 <property name="build.dir" location="build"/>
16 <property name="javacc.home" location="tools"/>
17 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
18 <!-- build parameter: compression level (ant -Dclevel=N)
19 N ranges from 0 (no compression) to 9 (maximum compression)
20 default: 9 -->
21 <condition property="clevel" value="${clevel}" else="9">
22 <isset property="clevel"/>
23 </condition>
24 <!-- Java classpath addition (all jar files to compile tests with this) -->
25 <path id="classpath">
26 <fileset dir="lib">
27 <include name="**/*.jar"/>
28 </fileset>
29 </path>
30
31 <!--
32 ** Used by Eclipse ant builder for updating
33 ** the REVISION file used by JOSM
34 -->
35 <target name="create-revision-eclipse">
36 <property name="revision.dir" value="bin"/>
37 <antcall target="create-revision"/>
38 </target>
39 <!--
40 ** Creates the REVISION file to be included in the distribution
41 -->
42 <target name="create-revision">
43 <property name="revision.dir" value="${build.dir}"/>
44 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false">
45 <env key="LANG" value="C"/>
46 <arg value="info"/>
47 <arg value="--xml"/>
48 <arg value="."/>
49 </exec>
50 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
51 <delete file="REVISION.XML"/>
52 <tstamp>
53 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
54 </tstamp>
55 <property name="version.entry.commit.revision" value="UNKNOWN"/>
56 <mkdir dir="${revision.dir}"/>
57 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
58 <echo file="${revision.dir}/REVISION">
59# automatically generated by JOSM build.xml - do not edit
60Revision: ${version.entry.commit.revision}
61Is-Local-Build: true
62Build-Date: ${build.tstamp}
63</echo>
64 </target>
65 <target name="dist" depends="compile,create-revision">
66 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
67 <env key="LANG" value="C"/>
68 <arg value="info"/>
69 <arg value="--xml"/>
70 <arg value="."/>
71 </exec>
72 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
73 <delete file="REVISION"/>
74 <property name="version.entry.commit.revision" value="UNKNOWN"/>
75 <property name="version.entry.commit.date" value="UNKNOWN"/>
76 <echo>Revision ${version.entry.commit.revision}</echo>
77 <copy file="CONTRIBUTION" todir="build"/>
78 <copy file="README" todir="build"/>
79 <copy file="LICENSE" todir="build"/>
80 <!-- create josm-custom.jar -->
81 <delete file="dist/josm-custom.jar"/>
82 <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
83 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
84 <manifest>
85 <attribute name="Main-class" value="JOSM"/>
86 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
87 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
88 </manifest>
89 <zipfileset dir="images" prefix="images"/>
90 <zipfileset dir="data" prefix="data"/>
91 <zipfileset dir="styles" prefix="styles"/>
92 <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
93 <!-- All jar files necessary to run only JOSM (no tests) -->
94 <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
95 <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
96 </jar>
97 </target>
98 <target name="distmac" depends="dist">
99 <!-- modify MacOS X Info.plist file to hold the SVN version number -->
100 <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/>
101 <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/>
102 <!-- create ZIP file with MacOS X application bundle -->
103 <zip destfile="dist/josm-custom-macosx.zip" update="true">
104 <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
105 <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"/>
106 <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/>
107 <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/>
108 <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/>
109 </zip>
110 </target>
111 <target name="javacc" depends="init" unless="javacc.notRequired">
112 <mkdir dir="${mapcss.dir}/parsergen"/>
113 <exec append="false" executable="java" failifexecutionfails="true">
114 <arg value="-cp"/>
115 <arg value="${javacc.home}/javacc.jar"/>
116 <arg value="javacc"/>
117 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
118 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
119 </exec>
120<!-- <javacc target="${mapcss.dir}/MapCSSParser.jj" javacchome="${javacc.home}" outputdirectory="${mapcss.dir}/parsergen"/>-->
121 </target>
122 <target name="compile" depends="init,javacc">
123 <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"/>
124 <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">
125 <compilerarg value="-Xlint:deprecation"/>
126 <compilerarg value="-Xlint:unchecked"/>
127 </javac>
128 </target>
129 <target name="init">
130 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
131 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
132 </uptodate>
133 <mkdir dir="build"/>
134 <mkdir dir="dist"/>
135 </target>
136 <target name="javadoc">
137 <javadoc destdir="javadoc"
138 sourcepath="src"
139 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
140 windowtitle="JOSM"
141 use="true"
142 private="true"
143 linksource="true"
144 author="false">
145 <link href="http://docs.oracle.com/javase/6/docs/api"/>
146 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
147 <bottom><![CDATA[<a href="http://josm.openstreetmap.de/">JOSM</a>]]></bottom>
148 </javadoc>
149 </target>
150 <target name="clean">
151 <delete dir="build"/>
152 <delete dir="dist"/>
153 <delete dir="${mapcss.dir}/parsergen"/>
154 </target>
155 <path id="test.classpath">
156 <fileset dir="${test.dir}/lib">
157 <include name="**/*.jar"/>
158 </fileset>
159 <fileset dir="lib">
160 <include name="**/*.jar"/>
161 </fileset>
162 <pathelement path="dist/josm-custom.jar"/>
163 </path>
164 <target name="test-init">
165 <mkdir dir="${test.dir}/${build.dir}"/>
166 <mkdir dir="${test.dir}/report"/>
167 </target>
168 <target name="test-clean">
169 <delete dir="${test.dir}/${build.dir}"/>
170 <delete dir="${test.dir}/report"/>
171 </target>
172 <target name="test-compile" depends="test-init,dist">
173 <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
174 <compilerarg value="-Xlint:deprecation"/>
175 <compilerarg value="-Xlint:unchecked"/>
176 </javac>
177 <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
178 <compilerarg value="-Xlint:deprecation"/>
179 <compilerarg value="-Xlint:unchecked"/>
180 </javac>
181 </target>
182 <target name="test" depends="test-compile">
183 <junit printsummary="yes">
184 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
185 <sysproperty key="java.awt.headless" value="true"/>
186 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
187 <classpath>
188 <path refid="test.classpath"/>
189 <pathelement path="${test.dir}/${build.dir}"/>
190 <pathelement path="${test.dir}/config"/>
191 </classpath>
192 <formatter type="plain"/>
193 <formatter type="xml"/>
194 <batchtest fork="yes" todir="${test.dir}/report">
195 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
196 </batchtest>
197 </junit>
198 </target>
199 <target name="test-html" depends="test" description="Generate HTML test reports">
200 <!-- May require additional ant dependencies like ant-trax package -->
201 <junitreport todir="${test.dir}/report">
202 <fileset dir="${test.dir}/report">
203 <include name="TEST-*.xml"/>
204 </fileset>
205 <report todir="${test.dir}/report/html"/>
206 </junitreport>
207 </target>
208 <target name="dist-optimized" depends="dist">
209 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
210 <proguard>
211 -injars dist/josm-custom.jar
212 -outjars dist/josm-custom-optimized.jar
213
214 -libraryjars ${java.home}/lib/rt.jar
215 -libraryjars ${java.home}/lib/jce.jar
216
217 -dontoptimize
218 -dontobfuscate
219
220 # These options probably are not necessary (and make processing a bit slower)
221 -dontskipnonpubliclibraryclasses
222 -dontskipnonpubliclibraryclassmembers
223
224 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
225 public static void main(java.lang.String[]);
226 }
227 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
228
229 -keep class JOSM
230 -keep class * extends org.openstreetmap.josm.io.FileImporter
231 -keep class * extends org.openstreetmap.josm.io.FileExporter
232 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
233 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
234
235 -keepclassmembers enum * {
236 public static **[] values();
237 public static ** valueOf(java.lang.String);
238 }
239
240 # Keep unused public methods (can be useful for plugins)
241 -keepclassmembers class * {
242 public protected *;
243 }
244
245 # 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
246 -dontnote
247 </proguard>
248 </target>
249 <target name="check-plugins" depends="dist-optimized">
250 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
251 <local name="dir"/>
252 <local name="plugins"/>
253 <property name="dir" value="plugin-check"/>
254 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
255 <classpath path="tools/animal-sniffer-ant-tasks-1.8.jar"/>
256 </typedef>
257 <mkdir dir="${dir}"/>
258 <!-- List of deprecated plugins -->
259 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
260 <filterchain>
261 <linecontains>
262 <contains value="new DeprecatedPlugin("/>
263 </linecontains>
264 <tokenfilter>
265 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
266 </tokenfilter>
267 <striplinebreaks/>
268 <tokenfilter>
269 <replaceregex pattern="\|$" replace="" flags="gi"/>
270 </tokenfilter>
271 </filterchain>
272 </loadfile>
273 <!-- Download list of plugins -->
274 <loadresource property="plugins">
275 <url url="http://josm.openstreetmap.de/plugin"/>
276 <filterchain>
277 <linecontainsregexp negate="true">
278 <regexp pattern="^\t.*"/>
279 </linecontainsregexp>
280 <linecontainsregexp negate="true">
281 <regexp pattern="${deprecated-plugins}"/>
282 </linecontainsregexp>
283 <tokenfilter>
284 <replaceregex pattern="^.*;" replace="" flags="gi"/>
285 </tokenfilter>
286 </filterchain>
287 </loadresource>
288 <!-- Delete files that are not in plugin list (like old plugins) -->
289 <loadresource property="file-list">
290 <propertyresource name="plugins"/>
291 <filterchain>
292 <tokenfilter>
293 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
294 </tokenfilter>
295 <striplinebreaks/>
296 <tokenfilter>
297 <replaceregex pattern="\|$" replace="" flags="gi"/>
298 </tokenfilter>
299 </filterchain>
300 </loadresource>
301 <delete>
302 <restrict>
303 <fileset dir="${dir}"/>
304 <not>
305 <name regex="${file-list}"/>
306 </not>
307 </restrict>
308 </delete>
309 <!-- Download plugins -->
310 <copy todir="${dir}" flatten="true">
311 <resourcelist>
312 <string value="${plugins}"/>
313 </resourcelist>
314 </copy>
315 <!-- Check plugins -->
316 <as:build-signatures destfile="${dir}/api.sig">
317 <path>
318 <fileset file="dist/josm-custom-optimized.jar"/>
319 <fileset file="${java.home}/lib/rt.jar"/>
320 <fileset file="${java.home}/lib/jce.jar"/>
321 </path>
322 </as:build-signatures>
323 <as:check-signature signature="${dir}/api.sig">
324 <ignore classname="org.jgraph.*"/>
325 <ignore classname="com.touchgraph.*"/>
326 <ignore classname="com.sun.xml.fastinfoset.*"/>
327 <ignore classname="javax.jms.*"/>
328 <ignore classname="org.jvnet.staxex.*"/>
329 <ignore classname="javax.mail.*"/>
330 <ignore classname="com.sun.jdmk.*"/>
331 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
332 <ignore classname="org.apache.log.*"/>
333 <ignore classname="junit.*"/>
334 <path path="${dir}"/>
335 </as:check-signature>
336 </target>
337
338 <target name="findbugs" depends="dist">
339 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
340 <path id="findbugs-classpath">
341 <fileset dir="tools/findbugs/">
342 <include name="*.jar"/>
343 </fileset>
344 </path>
345 <property name="findbugs-classpath" refid="findbugs-classpath"/>
346 <findbugs output="xml"
347 outputFile="findbugs-josm.xml"
348 classpath="${findbugs-classpath}"
349 pluginList=""
350 excludeFilter="tools/findbugs/josm-filter.xml"
351 effort="max"
352 >
353 <sourcePath path="${basedir}/src" />
354 <class location="${basedir}/dist/josm-custom.jar" />
355 </findbugs>
356 </target>
357 <target name="run" depends="dist">
358 <java jar="dist/josm-custom.jar" fork="true">
359 <arg value="--set=expert=true"/>
360 <arg value="--set=remotecontrol.enabled=true"/>
361 <arg value="--set=debug.edt-checker.enable=false"/>
362 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
363 </java>
364 </target>
365
366</project>
Note: See TracBrowser for help on using the repository browser.