source: josm/trunk/build.xml@ 5186

Last change on this file since 5186 was 4838, checked in by jttt, 13 years ago

Add findbugs ant target

File size: 14.0 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 <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="dist" depends="compile,create-revision">
65 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
66 <env key="LANG" value="C"/>
67 <arg value="info"/>
68 <arg value="--xml"/>
69 <arg value="."/>
70 </exec>
71 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
72 <delete file="REVISION"/>
73 <property name="version.entry.commit.revision" value="UNKNOWN"/>
74 <property name="version.entry.commit.date" value="UNKNOWN"/>
75 <echo>Revision ${version.entry.commit.revision}</echo>
76 <copy file="CONTRIBUTION" todir="build"/>
77 <copy file="README" todir="build"/>
78 <copy file="LICENSE" todir="build"/>
79 <!-- create josm-custom.jar -->
80 <delete file="dist/josm-custom.jar"/>
81 <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
82 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
83 <manifest>
84 <attribute name="Main-class" value="JOSM"/>
85 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
86 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
87 </manifest>
88 <zipfileset dir="images" prefix="images"/>
89 <zipfileset dir="data" prefix="data"/>
90 <zipfileset dir="styles" prefix="styles"/>
91 <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
92 <!-- All jar files necessary to run only JOSM (no tests) -->
93 <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
94 <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
95 </jar>
96 </target>
97 <target name="distmac" depends="dist">
98 <!-- modify MacOS X Info.plist file to hold the SVN version number -->
99 <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/>
100 <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/>
101 <!-- create ZIP file with MacOS X application bundle -->
102 <zip destfile="dist/josm-custom-macosx.zip" update="true">
103 <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
104 <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"/>
105 <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/>
106 <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/>
107 <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/>
108 </zip>
109 </target>
110 <target name="javacc">
111 <mkdir dir="${mapcss.dir}/parsergen"/>
112 <exec append="false" executable="java" failifexecutionfails="true">
113 <arg value="-cp"/>
114 <arg value="${javacc.home}/javacc.jar"/>
115 <arg value="javacc"/>
116 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
117 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
118 </exec>
119<!-- <javacc target="${mapcss.dir}/MapCSSParser.jj" javacchome="${javacc.home}" outputdirectory="${mapcss.dir}/parsergen"/>-->
120 </target>
121 <target name="compile" depends="javacc,init">
122 <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.5" source="1.5" debug="on" encoding="iso-8859-1"/>
123 <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.5" source="1.5" debug="on" encoding="UTF-8">
124 <compilerarg value="-Xlint:deprecation"/>
125 <compilerarg value="-Xlint:unchecked"/>
126 </javac>
127 </target>
128 <target name="init">
129 <mkdir dir="build"/>
130 <mkdir dir="dist"/>
131 </target>
132 <target name="clean">
133 <delete dir="build"/>
134 <delete dir="dist"/>
135 <delete dir="${mapcss.dir}/parsergen"/>
136 </target>
137 <path id="test.classpath">
138 <fileset dir="${test.dir}/lib">
139 <include name="**/*.jar"/>
140 </fileset>
141 <fileset dir="lib">
142 <include name="**/*.jar"/>
143 </fileset>
144 <pathelement path="dist/josm-custom.jar"/>
145 </path>
146 <target name="test-init">
147 <mkdir dir="${test.dir}/${build.dir}"/>
148 <mkdir dir="${test.dir}/report"/>
149 </target>
150 <target name="test-clean">
151 <delete dir="${test.dir}/${build.dir}"/>
152 <delete dir="${test.dir}/report"/>
153 </target>
154 <target name="test-compile" depends="test-init,dist">
155 <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
156 <compilerarg value="-Xlint:deprecation"/>
157 <compilerarg value="-Xlint:unchecked"/>
158 </javac>
159 <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
160 <compilerarg value="-Xlint:deprecation"/>
161 <compilerarg value="-Xlint:unchecked"/>
162 </javac>
163 </target>
164 <target name="test" depends="test-compile">
165 <junit printsummary="yes">
166 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
167 <sysproperty key="java.awt.headless" value="true"/>
168 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
169 <classpath>
170 <path refid="test.classpath"/>
171 <pathelement path="${test.dir}/${build.dir}"/>
172 <pathelement path="${test.dir}/config"/>
173 </classpath>
174 <formatter type="plain"/>
175 <formatter type="xml"/>
176 <batchtest fork="yes" todir="${test.dir}/report">
177 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
178 </batchtest>
179 </junit>
180 </target>
181 <target name="test-html" depends="test" description="Generate HTML test reports">
182 <!-- May require additional ant dependencies like ant-trax package -->
183 <junitreport todir="${test.dir}/report">
184 <fileset dir="${test.dir}/report">
185 <include name="TEST-*.xml"/>
186 </fileset>
187 <report todir="${test.dir}/report/html"/>
188 </junitreport>
189 </target>
190 <target name="dist-optimized" depends="dist">
191 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
192 <proguard>
193 -injars dist/josm-custom.jar
194 -outjars dist/josm-custom-optimized.jar
195
196 -libraryjars ${java.home}/lib/rt.jar
197 -libraryjars ${java.home}/lib/jce.jar
198
199 -dontoptimize
200 -dontobfuscate
201
202 # These options probably are not necessary (and make processing a bit slower)
203 -dontskipnonpubliclibraryclasses
204 -dontskipnonpubliclibraryclassmembers
205
206 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
207 public static void main(java.lang.String[]);
208 }
209 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
210
211 -keep class JOSM
212 -keep class * extends org.openstreetmap.josm.io.FileImporter
213 -keep class * extends org.openstreetmap.josm.io.FileExporter
214 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
215 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
216
217 -keepclassmembers enum * {
218 public static **[] values();
219 public static ** valueOf(java.lang.String);
220 }
221
222 # Keep unused public methods (can be useful for plugins)
223 -keepclassmembers class * {
224 public protected *;
225 }
226
227 # 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
228 -dontnote
229 </proguard>
230 </target>
231 <target name="check-plugins" depends="dist-optimized">
232 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
233 <local name="dir"/>
234 <local name="plugins"/>
235 <property name="dir" value="plugin-check"/>
236 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
237 <classpath path="tools/animal-sniffer-ant-tasks-1.7.jar"/>
238 </typedef>
239 <delete dir="${dir}"/>
240 <mkdir dir="${dir}"/>
241 <as:build-signatures destfile="${dir}/api.sig">
242 <path>
243 <fileset file="dist/josm-custom-optimized.jar"/>
244 <fileset file="${java.home}/lib/rt.jar"/>
245 <fileset file="${java.home}/lib/jce.jar"/>
246 </path>
247 </as:build-signatures>
248 <!-- List of deprecated plugins -->
249 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
250 <filterchain>
251 <linecontains>
252 <contains value="new DeprecatedPlugin("/>
253 </linecontains>
254 <tokenfilter>
255 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
256 </tokenfilter>
257 <striplinebreaks/>
258 <tokenfilter>
259 <replaceregex pattern="\|$" replace="" flags="gi"/>
260 </tokenfilter>
261 </filterchain>
262 </loadfile>
263 <!-- Download plugins -->
264 <loadresource property="plugins">
265 <url url="http://josm.openstreetmap.de/plugin"/>
266 <filterchain>
267 <linecontainsregexp negate="true">
268 <regexp pattern="^\t.*"/>
269 </linecontainsregexp>
270 <linecontainsregexp negate="true">
271 <regexp pattern="${deprecated-plugins}"/>
272 </linecontainsregexp>
273 <tokenfilter>
274 <replaceregex pattern="^.*;" replace="" flags="gi"/>
275 </tokenfilter>
276 </filterchain>
277 </loadresource>
278 <copy todir="${dir}" flatten="true">
279 <resourcelist>
280 <string value="${plugins}"/>
281 </resourcelist>
282 </copy>
283 <!-- Check plugins -->
284 <as:check-signature signature="${dir}/api.sig">
285 <ignore classname="org.jgraph.*"/>
286 <ignore classname="com.touchgraph.*"/>
287 <ignore classname="com.sun.xml.fastinfoset.*"/>
288 <ignore classname="javax.jms.*"/>
289 <ignore classname="org.jvnet.staxex.*"/>
290 <ignore classname="javax.mail.*"/>
291 <ignore classname="com.sun.jdmk.*"/>
292 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
293 <ignore classname="org.apache.log.*"/>
294 <ignore classname="junit.*"/>
295 <path path="${dir}"/>
296 </as:check-signature>
297 </target>
298
299 <target name="findbugs" depends="dist">
300 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
301 <path id="findbugs-classpath">
302 <fileset dir="tools/findbugs/">
303 <include name="*.jar"/>
304 </fileset>
305 </path>
306 <property name="findbugs-classpath" refid="findbugs-classpath"/>
307 <findbugs output="xml"
308 outputFile="findbugs-josm.xml"
309 classpath="${findbugs-classpath}"
310 pluginList=""
311 excludeFilter="tools/findbugs/josm-filter.xml"
312 effort="max"
313 >
314 <sourcePath path="${basedir}/src" />
315 <class location="${basedir}/dist/josm-custom.jar" />
316 </findbugs>
317 </target>
318
319</project>
Note: See TracBrowser for help on using the repository browser.