source: josm/trunk/build.xml@ 4730

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

New proguard, update proguard configuration

File size: 13.1 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 # These options probably are not necessary (and make processing a bit slower)
202 -dontskipnonpubliclibraryclasses
203 -dontskipnonpubliclibraryclassmembers
204
205 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
206 public static void main(java.lang.String[]);
207 }
208 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
209
210 -keep class JOSM
211 -keep class * extends org.openstreetmap.josm.io.FileImporter
212 -keep class * extends org.openstreetmap.josm.io.FileExporter
213 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
214 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
215
216 -keepclassmembers enum * {
217 public static **[] values();
218 public static ** valueOf(java.lang.String);
219 }
220
221 # Keep unused public methods (can be useful for plugins)
222 -keepclassmembers class * {
223 public protected *;
224 }
225
226 # 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
227 -dontnote
228 </proguard>
229 </target>
230 <target name="check-plugins" depends="dist-optimized">
231 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
232 <local name="dir"/>
233 <local name="plugins"/>
234 <property name="dir" value="plugin-check"/>
235 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
236 <classpath path="tools/animal-sniffer-ant-tasks-1.5.jar"/>
237 </typedef>
238 <delete dir="${dir}"/>
239 <mkdir dir="${dir}"/>
240 <as:build-signatures destfile="${dir}/api.sig">
241 <path>
242 <fileset file="dist/josm-custom-optimized.jar"/>
243 <fileset file="${java.home}/lib/rt.jar"/>
244 <fileset file="${java.home}/lib/jce.jar"/>
245 </path>
246 </as:build-signatures>
247 <!-- List of deprecated plugins -->
248 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
249 <filterchain>
250 <linecontains>
251 <contains value="new DeprecatedPlugin("/>
252 </linecontains>
253 <tokenfilter>
254 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
255 </tokenfilter>
256 <striplinebreaks/>
257 <tokenfilter>
258 <replaceregex pattern="\|$" replace="" flags="gi"/>
259 </tokenfilter>
260 </filterchain>
261 </loadfile>
262 <!-- Download plugins -->
263 <loadresource property="plugins">
264 <url url="http://josm.openstreetmap.de/plugin"/>
265 <filterchain>
266 <linecontainsregexp negate="true">
267 <regexp pattern="^\t.*"/>
268 </linecontainsregexp>
269 <linecontainsregexp negate="true">
270 <regexp pattern="${deprecated-plugins}"/>
271 </linecontainsregexp>
272 <tokenfilter>
273 <replaceregex pattern="^.*;" replace="" flags="gi"/>
274 </tokenfilter>
275 </filterchain>
276 </loadresource>
277 <copy todir="${dir}" flatten="true">
278 <resourcelist>
279 <string value="${plugins}"/>
280 </resourcelist>
281 </copy>
282 <!-- Check plugins -->
283 <as:check-signature signature="${dir}/api.sig">
284 <ignore classname="org.jgraph.*"/>
285 <ignore classname="com.touchgraph.*"/>
286 <ignore classname="com.sun.xml.fastinfoset.*"/>
287 <ignore classname="javax.jms.*"/>
288 <ignore classname="org.jvnet.staxex.*"/>
289 <ignore classname="javax.mail.*"/>
290 <ignore classname="com.sun.jdmk.*"/>
291 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
292 <ignore classname="org.apache.log.*"/>
293 <ignore classname="junit.*"/>
294 <path path="${dir}"/>
295 </as:check-signature>
296 </target>
297</project>
Note: See TracBrowser for help on using the repository browser.