source: josm/trunk/build.xml@ 3185

Last change on this file since 3185 was 3162, checked in by jttt, 14 years ago

Add check-plugins target to build.xml. It will download plugins and check them for binary compatibility

File size: 9.3 KB
RevLine 
[3162]1<!-- ** build.xml - main ant file for JOSM
[2369]2**
3** To build run
4** ant clean
5** ant dist
[3091]6** This will create 'josm-custom.jar' in directory 'dist'. See also
[2369]7** https://josm.openstreetmap.de/wiki/CreateBuild
[3091]8**
9**
[2369]10-->
[3162]11<project name="josm" default="dist" basedir="." xmlns:as="antlib:org.codehaus.mojo.animal_sniffer">
[1751]12 <property name="test.dir" value="test" />
13 <property name="src.dir" value="src" />
14 <property name="build.dir" value="build"/>
[2618]15 <!-- build parameter: compression level (ant -Dclevel=N)
[2507]16 N ranges from 0 (no compression) to 9 (maximum compression)
17 default: 9 -->
[2618]18 <condition property="clevel" value="${clevel}" else="9">
19 <isset property="clevel" />
20 </condition>
[1751]21
22 <!-- Java classpath addition (all jar files to compile tests with this) -->
23 <path id="classpath">
24 <fileset dir="lib">
25 <include name="**/*.jar"/>
26 </fileset>
27 </path>
[2453]28
[2618]29
[2358]30 <!--
[3091]31 ** Used by Eclipse ant builder for updating
[2453]32 ** the REVISION file used by JOSM
[2618]33 -->
[2453]34 <target name="create-revision-eclipse">
35 <property name="revision.dir" value="bin"/>
36 <antcall target="create-revision" />
37 </target>
38
39 <!--
[2358]40 ** Creates the REVISION file to be included in the distribution
[2618]41 -->
[2358]42 <target name="create-revision">
[2453]43 <property name="revision.dir" value="${build.dir}"/>
44 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false">
[2618]45 <env key="LANG" value="C"/>
46 <arg value="info"/>
47 <arg value="--xml"/>
48 <arg value="."/>
[2453]49 </exec>
50 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
51 <delete file="REVISION.XML" />
[2358]52 <tstamp>
[2618]53 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
[2360]54 </tstamp>
[1751]55
[2360]56 <property name="version.entry.commit.revision" value="UNKNOWN"/>
[2453]57 <mkdir dir="${revision.dir}" />
58 <echo file="${revision.dir}/REVISION">
[3091]59# automatically generated by JOSM build.xml - do not edit
[2358]60Revision: ${version.entry.commit.revision}
61Is-Local-Build: true
[3091]62Build-Date: ${build.tstamp}
[2618]63</echo>
[2358]64 </target>
[1751]65
[2618]66
[2358]67 <target name="dist" depends="compile,create-revision">
68
[1751]69 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
70 <env key="LANG" value="C"/>
71 <arg value="info"/>
72 <arg value="--xml"/>
73 <arg value="."/>
74 </exec>
75 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
76 <delete file="REVISION"/>
77 <property name="version.entry.commit.revision" value="UNKNOWN"/>
78 <property name="version.entry.commit.date" value="UNKNOWN"/>
[2618]79 <echo>Revision ${version.entry.commit.revision}</echo>
[1751]80 <copy file="CONTRIBUTION" todir="build"/>
81 <copy file="README" todir="build"/>
82 <copy file="LICENSE" todir="build"/>
83
[2618]84 <!-- styles -->
[2827]85 <copy file="styles/standard/elemstyles.xml" todir="build/data"/>
[1751]86
87 <!-- create josm-custom.jar -->
88 <delete file="dist/josm-custom.jar"/>
[2397]89 <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
[2618]90 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
[1751]91 <manifest>
92 <attribute name="Main-class" value="JOSM" />
93 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
94 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
95 </manifest>
96 <zipfileset dir="images" prefix="images" />
[2507]97 <zipfileset dir="data" prefix="data" />
[1751]98
99 <!-- All jar files necessary to run only JOSM (no tests) -->
100 <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar" />
[2748]101 <zipfileset src="lib/signpost-core-1.1.jar" />
[1751]102 </jar>
103 </target>
104
105 <target name="distmac" depends="dist">
106 <!-- modify MacOS X Info.plist file to hold the SVN version number -->
107 <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/>
108 <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/>
109 <!-- create ZIP file with MacOS X application bundle -->
110 <zip destfile="dist/josm-custom-macosx.zip" update="true">
111 <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
112 <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"/>
113 <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/>
114 <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/>
115 <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/>
116 </zip>
117 </target>
118
119 <target name="compile" depends="init">
120 <javac srcdir="src" classpathref="classpath" destdir="build"
121 target="1.5" source="1.5" debug="on" encoding="UTF-8">
122 <compilerarg value="-Xlint:deprecation"/>
[1941]123 <compilerarg value="-Xlint:unchecked"/>
[1751]124 </javac>
125 </target>
126
127 <target name="init">
128 <mkdir dir="build" />
129 <mkdir dir="dist" />
130 </target>
131
132 <target name="clean">
133 <delete dir="build" />
134 <delete dir="dist" />
135 </target>
136
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 </path>
145
146 <target name="test-init">
147 <mkdir dir="${test.dir}/${build.dir}" />
148 <mkdir dir="${test.dir}/report" />
149 </target>
150
151 <target name="test-clean">
152 <delete dir="${test.dir}/${build.dir}"/>
153 <delete dir="${test.dir}/report"/>
154 </target>
155
156 <target name="test-compile" depends="test-init">
157 <javac srcdir="${src.dir}:${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
158 target="1.5" source="1.5" debug="on" encoding="UTF-8">
159 <compilerarg value="-Xlint:deprecation"/>
[1941]160 <compilerarg value="-Xlint:unchecked"/>
[1751]161 </javac>
[2618]162 <javac srcdir="${src.dir}:${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
163 target="1.5" source="1.5" debug="on" encoding="UTF-8">
164 <compilerarg value="-Xlint:deprecation"/>
165 <compilerarg value="-Xlint:unchecked"/>
166 </javac>
[1751]167 </target>
168
[2618]169 <target name="test" depends="test-compile">
170 <junit printsummary="yes">
171 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
172 <classpath>
173 <path refid="test.classpath"/>
174 <pathelement path="${test.dir}/${build.dir}"/>
175 <pathelement path="${test.dir}/config"/>
176 </classpath>
177 <formatter type="plain"/>
[3026]178 <formatter type="xml"/>
179 <batchtest fork="yes" todir="${test.dir}/report">
[2618]180 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
181 </batchtest>
182 </junit>
183 </target>
[1751]184
[3091]185 <target name="dist-optimized" depends="dist">
186 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar" />
187 <proguard>
188 -injars dist/josm-custom.jar
189 -outjars dist/josm-custom-optimized.jar
190
191 -libraryjars ${java.home}/lib/rt.jar
192 -libraryjars ${java.home}/lib/jce.jar
193
194 -dontoptimize
195 -dontobfuscate
196
197 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
198 public static void main(java.lang.String[]);
199 }
200
201 -keep class JOSM
202 -keep class * extends org.openstreetmap.josm.io.FileImporter
203 -keep class * extends org.openstreetmap.josm.io.FileExporter
204 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
205
206 -keepclassmembers enum * {
207 public static **[] values();
208 public static ** valueOf(java.lang.String);
209 }
210
211 -keepclassmembers class * {
212 public protected *;
213 }
214 </proguard>
215 </target>
216
[3162]217 <target name="check-plugins" depends="dist-optimized">
218 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
219
220 <local name="dir"/>
221 <local name="plugins"/>
222
223 <property name="dir" value="plugin-check"/>
224
225 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
226 <classpath path="tools/animal-sniffer-ant-tasks-1.5.jar" />
227 </typedef>
228
229 <delete dir="${dir}"/>
230
231 <mkdir dir="${dir}"/>
232
233 <as:build-signatures destfile="${dir}/api.sig">
234 <path>
235 <fileset file="dist/josm-custom-optimized.jar" />
236 <fileset file="${java.home}/lib/rt.jar" />
237 </path>
238 </as:build-signatures>
239
240 <!-- Download plugins -->
241 <loadresource property="plugins">
242 <url url="http://josm.openstreetmap.de/plugin"/>
243 <filterchain>
244 <linecontainsregexp negate="true">
245 <regexp pattern="^\t.*"/>
246 </linecontainsregexp>
247 <linecontainsregexp negate="true">
248 <!-- List from PluginHandler.DEPRECATED_PLUGINS -->
249 <regexp pattern="mappaint|unglueplugin|ewmsplugin|ywms|tways-0.2|geotagged|landsat|namefinder|waypoints|slippy_map_chooser|tcx-support|usertools|AgPifoJ|utilsplugin"/>
250 </linecontainsregexp>
251 <tokenfilter>
252 <replaceregex pattern="^.*;" replace="" flags="gi"/>
253 </tokenfilter>
254 </filterchain>
255 </loadresource>
256
257 <copy todir="${dir}" flatten="true">
258 <resourcelist>
259 <string value="${plugins}"/>
260 </resourcelist>
261 </copy>
262
263 <!-- Check plugins -->
264 <as:check-signature signature="${dir}/api.sig">
265 <ignore classname="org.jgraph.*"/>
266 <ignore classname="com.touchgraph.*"/>
267 <ignore classname="com.sun.xml.fastinfoset.*"/>
268 <ignore classname="javax.jms.*"/>
269 <ignore classname="org.jvnet.staxex.*"/>
270 <ignore classname="javax.mail.*"/>
271 <ignore classname="com.sun.jdmk.*"/>
272 <path path="${dir}"/>
273 </as:check-signature>
274
275 </target>
276
277
[1751]278</project>
Note: See TracBrowser for help on using the repository browser.