source: josm/trunk/build.xml@ 3872

Last change on this file since 3872 was 3864, checked in by bastiK, 14 years ago

change in build: do not copy elemstyles.xml to data folder, but distribute the entire styles folder like it is done with 'images' and 'data' (toplevel) folders

File size: 10.9 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">
[3222]35 <copy file="styles/standard/elemstyles.xml" todir="data"/>
[2453]36 <property name="revision.dir" value="bin"/>
37 <antcall target="create-revision" />
38 </target>
39
40 <!--
[2358]41 ** Creates the REVISION file to be included in the distribution
[2618]42 -->
[2358]43 <target name="create-revision">
[2453]44 <property name="revision.dir" value="${build.dir}"/>
45 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false">
[2618]46 <env key="LANG" value="C"/>
47 <arg value="info"/>
48 <arg value="--xml"/>
49 <arg value="."/>
[2453]50 </exec>
51 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
52 <delete file="REVISION.XML" />
[2358]53 <tstamp>
[2618]54 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
[2360]55 </tstamp>
[1751]56
[2360]57 <property name="version.entry.commit.revision" value="UNKNOWN"/>
[2453]58 <mkdir dir="${revision.dir}" />
59 <echo file="${revision.dir}/REVISION">
[3091]60# automatically generated by JOSM build.xml - do not edit
[2358]61Revision: ${version.entry.commit.revision}
62Is-Local-Build: true
[3091]63Build-Date: ${build.tstamp}
[2618]64</echo>
[2358]65 </target>
[1751]66
[2618]67
[2358]68 <target name="dist" depends="compile,create-revision">
69
[1751]70 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
71 <env key="LANG" value="C"/>
72 <arg value="info"/>
73 <arg value="--xml"/>
74 <arg value="."/>
75 </exec>
76 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
77 <delete file="REVISION"/>
78 <property name="version.entry.commit.revision" value="UNKNOWN"/>
79 <property name="version.entry.commit.date" value="UNKNOWN"/>
[2618]80 <echo>Revision ${version.entry.commit.revision}</echo>
[1751]81 <copy file="CONTRIBUTION" todir="build"/>
82 <copy file="README" todir="build"/>
83 <copy file="LICENSE" todir="build"/>
84
85 <!-- create josm-custom.jar -->
86 <delete file="dist/josm-custom.jar"/>
[2397]87 <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
[2618]88 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
[1751]89 <manifest>
90 <attribute name="Main-class" value="JOSM" />
91 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
92 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
93 </manifest>
94 <zipfileset dir="images" prefix="images" />
[2507]95 <zipfileset dir="data" prefix="data" />
[3864]96 <zipfileset dir="styles" prefix="styles" />
[3744]97 <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images" />
[1751]98
99 <!-- All jar files necessary to run only JOSM (no tests) -->
100 <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar" />
[3425]101 <zipfileset src="lib/signpost-core-1.2.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>
[3579]118
[1751]119 <target name="compile" depends="init">
120 <javac srcdir="src" classpathref="classpath" destdir="build"
[3509]121 target="1.5" source="1.5" debug="on" encoding="UTF-8">
[1751]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>
[3856]136
137 <target name="javacc">
138 <exec executable="javacc">
139 <arg value="-debug_parser=false"/>
140 <arg value="-debug_lookahead=false"/>
141 <arg value="-debug_token_manager=false"/>
142 <arg value="-output_directory=${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss/parser"/>
143 <arg value="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParser.jj"/>
144 </exec>
145 </target>
[1751]146
147 <path id="test.classpath">
148 <fileset dir="${test.dir}/lib">
149 <include name="**/*.jar"/>
150 </fileset>
151 <fileset dir="lib">
152 <include name="**/*.jar"/>
153 </fileset>
[3579]154 <pathelement path="dist/josm-custom.jar"/>
[1751]155 </path>
156
157 <target name="test-init">
158 <mkdir dir="${test.dir}/${build.dir}" />
159 <mkdir dir="${test.dir}/report" />
160 </target>
161
162 <target name="test-clean">
163 <delete dir="${test.dir}/${build.dir}"/>
164 <delete dir="${test.dir}/report"/>
165 </target>
166
[3579]167 <target name="test-compile" depends="test-init,dist">
168 <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
[3509]169 target="1.5" source="1.5" debug="on" encoding="UTF-8">
[1751]170 <compilerarg value="-Xlint:deprecation"/>
[1941]171 <compilerarg value="-Xlint:unchecked"/>
[1751]172 </javac>
[3579]173 <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
[3509]174 target="1.5" source="1.5" debug="on" encoding="UTF-8">
[2618]175 <compilerarg value="-Xlint:deprecation"/>
176 <compilerarg value="-Xlint:unchecked"/>
177 </javac>
[1751]178 </target>
179
[2618]180 <target name="test" depends="test-compile">
181 <junit printsummary="yes">
182 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
[3580]183 <sysproperty key="java.awt.headless" value="true"/>
[2618]184 <classpath>
185 <path refid="test.classpath"/>
186 <pathelement path="${test.dir}/${build.dir}"/>
187 <pathelement path="${test.dir}/config"/>
188 </classpath>
189 <formatter type="plain"/>
[3026]190 <formatter type="xml"/>
191 <batchtest fork="yes" todir="${test.dir}/report">
[2618]192 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
193 </batchtest>
194 </junit>
195 </target>
[1751]196
[3829]197 <target name="test-html" depends="test" description="Generate HTML test reports">
198 <!-- May require additional ant dependencies like ant-trax package -->
199 <junitreport todir="${test.dir}/report">
200 <fileset dir="${test.dir}/report">
201 <include name="TEST-*.xml"/>
202 </fileset>
203 <report todir="${test.dir}/report/html"/>
204 </junitreport>
205 </target>
206
[3091]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
[3579]218
[3442]219 -dontskipnonpubliclibraryclasses
[3091]220
221 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
222 public static void main(java.lang.String[]);
223 }
224
225 -keep class JOSM
226 -keep class * extends org.openstreetmap.josm.io.FileImporter
227 -keep class * extends org.openstreetmap.josm.io.FileExporter
228 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
229
230 -keepclassmembers enum * {
231 public static **[] values();
232 public static ** valueOf(java.lang.String);
233 }
234
235 -keepclassmembers class * {
236 public protected *;
237 }
238 </proguard>
239 </target>
240
[3162]241 <target name="check-plugins" depends="dist-optimized">
242 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
243
244 <local name="dir"/>
245 <local name="plugins"/>
246
247 <property name="dir" value="plugin-check"/>
248
249 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
250 <classpath path="tools/animal-sniffer-ant-tasks-1.5.jar" />
251 </typedef>
252
253 <delete dir="${dir}"/>
254
255 <mkdir dir="${dir}"/>
256
257 <as:build-signatures destfile="${dir}/api.sig">
258 <path>
259 <fileset file="dist/josm-custom-optimized.jar" />
260 <fileset file="${java.home}/lib/rt.jar" />
[3649]261 <fileset file="${java.home}/lib/jce.jar" />
[3162]262 </path>
263 </as:build-signatures>
[3830]264
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\("(.+?)".*' replace="\1|" flags="gi"/>
273 </tokenfilter>
[3833]274 <striplinebreaks/>
275 <tokenfilter>
276 <replaceregex pattern='\|$' replace="" flags="gi"/>
277 </tokenfilter>
[3830]278 </filterchain>
279 </loadfile>
280
[3162]281 <!-- Download plugins -->
282 <loadresource property="plugins">
283 <url url="http://josm.openstreetmap.de/plugin"/>
284 <filterchain>
285 <linecontainsregexp negate="true">
286 <regexp pattern="^\t.*"/>
287 </linecontainsregexp>
288 <linecontainsregexp negate="true">
[3830]289 <regexp pattern="${deprecated-plugins}"/>
[3162]290 </linecontainsregexp>
291 <tokenfilter>
292 <replaceregex pattern="^.*;" replace="" flags="gi"/>
293 </tokenfilter>
294 </filterchain>
295 </loadresource>
296
297 <copy todir="${dir}" flatten="true">
298 <resourcelist>
299 <string value="${plugins}"/>
300 </resourcelist>
301 </copy>
302
303 <!-- Check plugins -->
304 <as:check-signature signature="${dir}/api.sig">
305 <ignore classname="org.jgraph.*"/>
306 <ignore classname="com.touchgraph.*"/>
307 <ignore classname="com.sun.xml.fastinfoset.*"/>
308 <ignore classname="javax.jms.*"/>
309 <ignore classname="org.jvnet.staxex.*"/>
310 <ignore classname="javax.mail.*"/>
311 <ignore classname="com.sun.jdmk.*"/>
[3649]312 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
313 <ignore classname="org.apache.log.*"/>
314 <ignore classname="junit.*"/>
[3162]315 <path path="${dir}"/>
316 </as:check-signature>
317
318 </target>
319
320
[1751]321</project>
Note: See TracBrowser for help on using the repository browser.