source: josm/trunk/build.xml@ 4257

Last change on this file since 4257 was 4257, checked in by stoecker, 13 years ago

fix #6603 - don't use optional javacc ant task

File size: 12.6 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 <classpath>
169 <path refid="test.classpath"/>
170 <pathelement path="${test.dir}/${build.dir}"/>
171 <pathelement path="${test.dir}/config"/>
172 </classpath>
173 <formatter type="plain"/>
174 <formatter type="xml"/>
175 <batchtest fork="yes" todir="${test.dir}/report">
176 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
177 </batchtest>
178 </junit>
179 </target>
180 <target name="test-html" depends="test" description="Generate HTML test reports">
181 <!-- May require additional ant dependencies like ant-trax package -->
182 <junitreport todir="${test.dir}/report">
183 <fileset dir="${test.dir}/report">
184 <include name="TEST-*.xml"/>
185 </fileset>
186 <report todir="${test.dir}/report/html"/>
187 </junitreport>
188 </target>
189 <target name="dist-optimized" depends="dist">
190 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
191 <proguard>
192 -injars dist/josm-custom.jar
193 -outjars dist/josm-custom-optimized.jar
194
195 -libraryjars ${java.home}/lib/rt.jar
196 -libraryjars ${java.home}/lib/jce.jar
197
198 -dontoptimize
199 -dontobfuscate
200
201 -dontskipnonpubliclibraryclasses
202
203 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
204 public static void main(java.lang.String[]);
205 }
206
207 -keep class JOSM
208 -keep class * extends org.openstreetmap.josm.io.FileImporter
209 -keep class * extends org.openstreetmap.josm.io.FileExporter
210 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
211
212 -keepclassmembers enum * {
213 public static **[] values();
214 public static ** valueOf(java.lang.String);
215 }
216
217 -keepclassmembers class * {
218 public protected *;
219 }
220 </proguard>
221 </target>
222 <target name="check-plugins" depends="dist-optimized">
223 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
224 <local name="dir"/>
225 <local name="plugins"/>
226 <property name="dir" value="plugin-check"/>
227 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
228 <classpath path="tools/animal-sniffer-ant-tasks-1.5.jar"/>
229 </typedef>
230 <delete dir="${dir}"/>
231 <mkdir dir="${dir}"/>
232 <as:build-signatures destfile="${dir}/api.sig">
233 <path>
234 <fileset file="dist/josm-custom-optimized.jar"/>
235 <fileset file="${java.home}/lib/rt.jar"/>
236 <fileset file="${java.home}/lib/jce.jar"/>
237 </path>
238 </as:build-signatures>
239 <!-- List of deprecated plugins -->
240 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
241 <filterchain>
242 <linecontains>
243 <contains value="new DeprecatedPlugin("/>
244 </linecontains>
245 <tokenfilter>
246 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
247 </tokenfilter>
248 <striplinebreaks/>
249 <tokenfilter>
250 <replaceregex pattern="\|$" replace="" flags="gi"/>
251 </tokenfilter>
252 </filterchain>
253 </loadfile>
254 <!-- Download plugins -->
255 <loadresource property="plugins">
256 <url url="http://josm.openstreetmap.de/plugin"/>
257 <filterchain>
258 <linecontainsregexp negate="true">
259 <regexp pattern="^\t.*"/>
260 </linecontainsregexp>
261 <linecontainsregexp negate="true">
262 <regexp pattern="${deprecated-plugins}"/>
263 </linecontainsregexp>
264 <tokenfilter>
265 <replaceregex pattern="^.*;" replace="" flags="gi"/>
266 </tokenfilter>
267 </filterchain>
268 </loadresource>
269 <copy todir="${dir}" flatten="true">
270 <resourcelist>
271 <string value="${plugins}"/>
272 </resourcelist>
273 </copy>
274 <!-- Check plugins -->
275 <as:check-signature signature="${dir}/api.sig">
276 <ignore classname="org.jgraph.*"/>
277 <ignore classname="com.touchgraph.*"/>
278 <ignore classname="com.sun.xml.fastinfoset.*"/>
279 <ignore classname="javax.jms.*"/>
280 <ignore classname="org.jvnet.staxex.*"/>
281 <ignore classname="javax.mail.*"/>
282 <ignore classname="com.sun.jdmk.*"/>
283 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
284 <ignore classname="org.apache.log.*"/>
285 <ignore classname="junit.*"/>
286 <path path="${dir}"/>
287 </as:check-signature>
288 </target>
289</project>
Note: See TracBrowser for help on using the repository browser.