source: josm/trunk/build.xml@ 5383

Last change on this file since 5383 was 5362, checked in by stoecker, 12 years ago

reintroduce the feature to give the build a name

File size: 15.1 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**
11-->
12<project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" basedir=".">
[4252]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"/>
[4166]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) -->
[4252]25 <path id="classpath">
[4166]26 <fileset dir="lib">
27 <include name="**/*.jar"/>
28 </fileset>
[4252]29 </path>
30
[4166]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}"/>
[5362]57 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
[4166]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) -->
[4231]94 <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
95 <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
[4166]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>
[5323]111 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
112 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
113 </uptodate>
114 <target name="javacc" unless="javacc.notRequired">
[4252]115 <mkdir dir="${mapcss.dir}/parsergen"/>
[4257]116 <exec append="false" executable="java" failifexecutionfails="true">
117 <arg value="-cp"/>
118 <arg value="${javacc.home}/javacc.jar"/>
119 <arg value="javacc"/>
120 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
121 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
122 </exec>
123<!-- <javacc target="${mapcss.dir}/MapCSSParser.jj" javacchome="${javacc.home}" outputdirectory="${mapcss.dir}/parsergen"/>-->
[4252]124 </target>
125 <target name="compile" depends="javacc,init">
126 <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.5" source="1.5" debug="on" encoding="iso-8859-1"/>
[4728]127 <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.5" source="1.5" debug="on" encoding="UTF-8">
[4166]128 <compilerarg value="-Xlint:deprecation"/>
129 <compilerarg value="-Xlint:unchecked"/>
130 </javac>
131 </target>
132 <target name="init">
133 <mkdir dir="build"/>
134 <mkdir dir="dist"/>
135 </target>
[5263]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 linksource="true"
143 author="false">
144 <link href="http://docs.oracle.com/javase/6/docs/api"/>
145 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
146 <bottom><![CDATA[<a href="http://josm.openstreetmap.de/">JOSM</a>]]></bottom>
147 </javadoc>
148 </target>
[4166]149 <target name="clean">
150 <delete dir="build"/>
151 <delete dir="dist"/>
[4252]152 <delete dir="${mapcss.dir}/parsergen"/>
[4166]153 </target>
154 <path id="test.classpath">
155 <fileset dir="${test.dir}/lib">
156 <include name="**/*.jar"/>
157 </fileset>
158 <fileset dir="lib">
159 <include name="**/*.jar"/>
160 </fileset>
161 <pathelement path="dist/josm-custom.jar"/>
162 </path>
163 <target name="test-init">
164 <mkdir dir="${test.dir}/${build.dir}"/>
165 <mkdir dir="${test.dir}/report"/>
166 </target>
167 <target name="test-clean">
168 <delete dir="${test.dir}/${build.dir}"/>
169 <delete dir="${test.dir}/report"/>
170 </target>
171 <target name="test-compile" depends="test-init,dist">
172 <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
173 <compilerarg value="-Xlint:deprecation"/>
174 <compilerarg value="-Xlint:unchecked"/>
175 </javac>
176 <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
177 <compilerarg value="-Xlint:deprecation"/>
178 <compilerarg value="-Xlint:unchecked"/>
179 </javac>
180 </target>
181 <target name="test" depends="test-compile">
182 <junit printsummary="yes">
183 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
184 <sysproperty key="java.awt.headless" value="true"/>
[4837]185 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
[4166]186 <classpath>
187 <path refid="test.classpath"/>
188 <pathelement path="${test.dir}/${build.dir}"/>
189 <pathelement path="${test.dir}/config"/>
190 </classpath>
191 <formatter type="plain"/>
192 <formatter type="xml"/>
193 <batchtest fork="yes" todir="${test.dir}/report">
194 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
195 </batchtest>
196 </junit>
197 </target>
198 <target name="test-html" depends="test" description="Generate HTML test reports">
199 <!-- May require additional ant dependencies like ant-trax package -->
200 <junitreport todir="${test.dir}/report">
201 <fileset dir="${test.dir}/report">
202 <include name="TEST-*.xml"/>
203 </fileset>
204 <report todir="${test.dir}/report/html"/>
205 </junitreport>
206 </target>
207 <target name="dist-optimized" depends="dist">
208 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
209 <proguard>
210 -injars dist/josm-custom.jar
211 -outjars dist/josm-custom-optimized.jar
212
213 -libraryjars ${java.home}/lib/rt.jar
214 -libraryjars ${java.home}/lib/jce.jar
215
216 -dontoptimize
217 -dontobfuscate
218
[4730]219 # These options probably are not necessary (and make processing a bit slower)
[4166]220 -dontskipnonpubliclibraryclasses
[4730]221 -dontskipnonpubliclibraryclassmembers
[4166]222
223 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
224 public static void main(java.lang.String[]);
225 }
[4730]226 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
[4166]227
228 -keep class JOSM
229 -keep class * extends org.openstreetmap.josm.io.FileImporter
230 -keep class * extends org.openstreetmap.josm.io.FileExporter
[4730]231 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
232 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
[4166]233
234 -keepclassmembers enum * {
235 public static **[] values();
236 public static ** valueOf(java.lang.String);
237 }
238
[4730]239 # Keep unused public methods (can be useful for plugins)
[4166]240 -keepclassmembers class * {
241 public protected *;
242 }
[4838]243
[4730]244 # 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
245 -dontnote
[4166]246 </proguard>
247 </target>
248 <target name="check-plugins" depends="dist-optimized">
249 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
250 <local name="dir"/>
251 <local name="plugins"/>
252 <property name="dir" value="plugin-check"/>
253 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
[4783]254 <classpath path="tools/animal-sniffer-ant-tasks-1.7.jar"/>
[4166]255 </typedef>
256 <delete dir="${dir}"/>
257 <mkdir dir="${dir}"/>
258 <as:build-signatures destfile="${dir}/api.sig">
259 <path>
260 <fileset file="dist/josm-custom-optimized.jar"/>
261 <fileset file="${java.home}/lib/rt.jar"/>
262 <fileset file="${java.home}/lib/jce.jar"/>
263 </path>
264 </as:build-signatures>
265 <!-- List of deprecated plugins -->
266 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
267 <filterchain>
268 <linecontains>
269 <contains value="new DeprecatedPlugin("/>
270 </linecontains>
271 <tokenfilter>
272 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
273 </tokenfilter>
274 <striplinebreaks/>
275 <tokenfilter>
276 <replaceregex pattern="\|$" replace="" flags="gi"/>
277 </tokenfilter>
278 </filterchain>
279 </loadfile>
280 <!-- Download plugins -->
281 <loadresource property="plugins">
282 <url url="http://josm.openstreetmap.de/plugin"/>
283 <filterchain>
284 <linecontainsregexp negate="true">
285 <regexp pattern="^\t.*"/>
286 </linecontainsregexp>
287 <linecontainsregexp negate="true">
288 <regexp pattern="${deprecated-plugins}"/>
289 </linecontainsregexp>
290 <tokenfilter>
291 <replaceregex pattern="^.*;" replace="" flags="gi"/>
292 </tokenfilter>
293 </filterchain>
294 </loadresource>
295 <copy todir="${dir}" flatten="true">
296 <resourcelist>
297 <string value="${plugins}"/>
298 </resourcelist>
299 </copy>
300 <!-- Check plugins -->
301 <as:check-signature signature="${dir}/api.sig">
302 <ignore classname="org.jgraph.*"/>
303 <ignore classname="com.touchgraph.*"/>
304 <ignore classname="com.sun.xml.fastinfoset.*"/>
305 <ignore classname="javax.jms.*"/>
306 <ignore classname="org.jvnet.staxex.*"/>
307 <ignore classname="javax.mail.*"/>
308 <ignore classname="com.sun.jdmk.*"/>
309 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
310 <ignore classname="org.apache.log.*"/>
311 <ignore classname="junit.*"/>
312 <path path="${dir}"/>
313 </as:check-signature>
314 </target>
[4838]315
316 <target name="findbugs" depends="dist">
317 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
318 <path id="findbugs-classpath">
319 <fileset dir="tools/findbugs/">
320 <include name="*.jar"/>
321 </fileset>
322 </path>
323 <property name="findbugs-classpath" refid="findbugs-classpath"/>
324 <findbugs output="xml"
325 outputFile="findbugs-josm.xml"
326 classpath="${findbugs-classpath}"
327 pluginList=""
328 excludeFilter="tools/findbugs/josm-filter.xml"
329 effort="max"
330 >
331 <sourcePath path="${basedir}/src" />
332 <class location="${basedir}/dist/josm-custom.jar" />
333 </findbugs>
334 </target>
[5323]335 <target name="run" depends="dist">
336 <java jar="dist/josm-custom.jar" fork="true">
337 <arg value="--set=expert=true"/>
338 <arg value="--set=remotecontrol.enabled=true"/>
339 <arg value="--set=debug.edt-checker.enable=false"/>
340 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
341 </java>
342 </target>
[4838]343
[4166]344</project>
Note: See TracBrowser for help on using the repository browser.