source: josm/trunk/build.xml@ 6452

Last change on this file since 6452 was 6446, checked in by Don-vip, 11 years ago

javaCC tuning

File size: 20.4 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<project xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" name="josm" default="dist" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
12 <property name="test.dir" location="test"/>
13 <property name="src.dir" location="src"/>
14 <property name="build.dir" location="build"/>
15 <property name="javacc.home" location="tools"/>
16 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
17 <!-- build parameter: compression level (ant -Dclevel=N)
18 N ranges from 0 (no compression) to 9 (maximum compression)
19 default: 9 -->
20 <condition property="clevel" value="${clevel}" else="9">
21 <isset property="clevel"/>
22 </condition>
23 <!-- Java classpath addition (all jar files to compile tests with this) -->
24 <path id="classpath">
25 <fileset dir="lib">
26 <include name="**/*.jar"/>
27 </fileset>
28 </path>
29
30 <!--
31 ** Used by Eclipse ant builder for updating
32 ** the REVISION file used by JOSM
33 -->
34 <target name="create-revision-eclipse">
35 <property name="revision.dir" value="bin"/>
36 <antcall target="create-revision"/>
37 </target>
38 <!--
39 ** Creates the REVISION file to be included in the distribution
40 -->
41 <target name="create-revision">
42 <property name="revision.dir" value="${build.dir}"/>
43 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false">
44 <env key="LANG" value="C"/>
45 <arg value="info"/>
46 <arg value="--xml"/>
47 <arg value="."/>
48 </exec>
49 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
50 <delete file="REVISION.XML"/>
51 <tstamp>
52 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
53 </tstamp>
54 <property name="version.entry.commit.revision" value="UNKNOWN"/>
55 <mkdir dir="${revision.dir}"/>
56 <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
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="check-schemas">
65 <schemavalidate file="data/defaultpresets.xml" >
66 <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
67 </schemavalidate>
68 <schemavalidate file="styles/standard/elemstyles.xml" >
69 <schema namespace="http://josm.openstreetmap.de/mappaint-style-1.0" file="data/mappaint-style.xsd" />
70 </schemavalidate>
71 </target>
72 <target name="dist" depends="compile,create-revision,check-schemas">
73 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
74 <env key="LANG" value="C"/>
75 <arg value="info"/>
76 <arg value="--xml"/>
77 <arg value="."/>
78 </exec>
79 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
80 <delete file="REVISION"/>
81 <property name="version.entry.commit.revision" value="UNKNOWN"/>
82 <property name="version.entry.commit.date" value="UNKNOWN"/>
83 <echo>Revision ${version.entry.commit.revision}</echo>
84 <copy file="CONTRIBUTION" todir="build"/>
85 <copy file="README" todir="build"/>
86 <copy file="LICENSE" todir="build"/>
87 <!-- create josm-custom.jar -->
88 <delete file="dist/josm-custom.jar"/>
89 <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
90 <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
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 <attribute name="Permissions" value="all-permissions"/>
96 <attribute name="Codebase" value="josm.openstreetmap.de"/>
97 <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
98 </manifest>
99 <zipfileset dir="images" prefix="images"/>
100 <zipfileset dir="data" prefix="data"/>
101 <zipfileset dir="styles" prefix="styles"/>
102 <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
103 <!-- All jar files necessary to run only JOSM (no tests) -->
104 <!-- <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar"/> -->
105 <!-- <zipfileset src="lib/signpost-core-1.2.1.1.jar"/> -->
106 </jar>
107 </target>
108 <!-- Compatibility Mac OS X target for Java 6 (incompatible with new on for Java 7, see #8654, #9035) -->
109 <target name="distmac" depends="dist">
110 <!-- modify MacOS X Info.plist file to hold the SVN version number -->
111 <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/>
112 <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/>
113 <!-- create ZIP file with MacOS X application bundle -->
114 <zip destfile="dist/josm-custom-macosx.zip" update="true">
115 <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
116 <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"/>
117 <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/>
118 <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/>
119 <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/>
120 </zip>
121 </target>
122 <!-- New Mac OS X target for Java 7 -->
123 <target name="distmac7" depends="dist">
124 <!-- Using https://bitbucket.org/infinitekind/appbundler to create mac application bundle -->
125 <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="tools/appbundler-1.0ea.jar"/>
126 <!-- create MacOS X application bundle -->
127 <bundleapp outputdirectory="dist" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
128 mainclassname="org.openstreetmap.josm.gui.MainApplication"
129 copyright="JOSM, and all its integral parts, are released under the GNU General Public License v2 or later"
130 applicationCategory="public.app-category.utilities"
131 shortversion="${version.entry.commit.revision} SVN"
132 version="${version.entry.commit.revision} SVN"
133 icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
134 highResolutionCapable="true">
135
136 <arch name="x86_64"/>
137 <arch name="i386"/>
138
139 <classpath file="dist/josm-custom.jar"/>
140
141 <option value="-Xmx512m"/>
142
143 <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
144 <option value="-Xdock:name=JOSM"/>
145
146 <!-- OSX specific options, optional -->
147 <option value="-Dapple.laf.useScreenMenuBar=true"/>
148 <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
149 <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
150 <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
151 <option value="-Dcom.apple.smallTabs=true"/>
152 </bundleapp>
153
154 <!-- appbundler lacks the possibility of defining our own keys or using a template, so update the .plist manually -->
155 <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="tools/xmltask.jar"/>
156
157 <xmltask source="dist/JOSM.app/Contents/Info.plist" dest="dist/JOSM.app/Contents/Info.plist" indent="false">
158 <insert position="before" path="/plist/dict/key[1]"><![CDATA[<key>CFBundleAllowMixedLocalizations</key>
159<string>true</string>
160]]></insert>
161 </xmltask>
162
163 <!-- create ZIP file with MacOS X application bundle -->
164 <zip destfile="dist/josm-custom-macosx-java7.zip" update="true">
165 <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
166 <zipfileset dir="dist" includes="JOSM.app/**/*" filemode="755" />
167 </zip>
168 </target>
169 <target name="javacc" depends="init" unless="javacc.notRequired">
170 <mkdir dir="${mapcss.dir}/parsergen"/>
171 <exec append="false" executable="java" failifexecutionfails="true">
172 <arg value="-cp"/>
173 <arg value="${javacc.home}/javacc.jar"/>
174 <arg value="javacc"/>
175 <arg value="-JDK_VERSION=1.6"/>
176 <arg value="-GRAMMAR_ENCODING=UTF-8"/>
177 <arg value="-UNICODE_INPUT"/>
178 <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
179 <arg value="${mapcss.dir}/MapCSSParser.jj"/>
180 </exec>
181 </target>
182 <target name="compile" depends="init,javacc">
183 <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="iso-8859-1"/>
184 <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="UTF-8">
185 <compilerarg value="-Xlint:deprecation"/>
186 <compilerarg value="-Xlint:unchecked"/>
187 </javac>
188 </target>
189 <target name="init">
190 <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
191 <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
192 </uptodate>
193 <mkdir dir="build"/>
194 <mkdir dir="dist"/>
195 </target>
196 <target name="javadoc">
197 <javadoc destdir="javadoc"
198 sourcepath="src"
199 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
200 windowtitle="JOSM"
201 use="true"
202 private="true"
203 linksource="true"
204 author="false">
205 <link href="http://docs.oracle.com/javase/6/docs/api"/>
206 <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
207 <bottom><![CDATA[<a href="http://josm.openstreetmap.de/">JOSM</a>]]></bottom>
208 </javadoc>
209 </target>
210 <target name="clean">
211 <delete dir="build"/>
212 <delete dir="dist"/>
213 <delete dir="${mapcss.dir}/parsergen"/>
214 </target>
215 <path id="test.classpath">
216 <fileset dir="${test.dir}/lib">
217 <include name="**/*.jar"/>
218 </fileset>
219 <fileset dir="lib">
220 <include name="**/*.jar"/>
221 </fileset>
222 <pathelement path="dist/josm-custom.jar"/>
223 </path>
224 <target name="test-init">
225 <mkdir dir="${test.dir}/build"/>
226 <mkdir dir="${test.dir}/report"/>
227 </target>
228 <target name="test-clean">
229 <delete dir="${test.dir}/build"/>
230 <delete dir="${test.dir}/report"/>
231 <delete file="${test.dir}/jacoco.exec" />
232 </target>
233 <target name="test-compile" depends="test-init,dist">
234 <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="UTF-8">
235 <compilerarg value="-Xlint:deprecation"/>
236 <compilerarg value="-Xlint:unchecked"/>
237 </javac>
238 <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/build" target="1.6" source="1.6" debug="on" includeantruntime="false" encoding="UTF-8">
239 <compilerarg value="-Xlint:deprecation"/>
240 <compilerarg value="-Xlint:unchecked"/>
241 </javac>
242 </target>
243 <target name="test" depends="test-compile">
244 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
245 <jacoco:coverage destfile="${test.dir}/jacoco.exec">
246 <junit printsummary="yes" fork="true" forkmode="once">
247 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
248 <sysproperty key="josm.test.data" value="${test.dir}/data"/>
249 <sysproperty key="java.awt.headless" value="true"/>
250 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
251 <classpath>
252 <path refid="test.classpath"/>
253 <pathelement path="${test.dir}/build"/>
254 <pathelement path="${test.dir}/config"/>
255 </classpath>
256 <formatter type="plain"/>
257 <formatter type="xml"/>
258 <batchtest fork="yes" todir="${test.dir}/report">
259 <fileset dir="${test.dir}/unit" includes="**/*.java"/>
260 </batchtest>
261 </junit>
262 </jacoco:coverage>
263 </target>
264 <target name="test-html" depends="test" description="Generate HTML test reports">
265 <!-- May require additional ant dependencies like ant-trax package -->
266 <junitreport todir="${test.dir}/report">
267 <fileset dir="${test.dir}/report">
268 <include name="TEST-*.xml"/>
269 </fileset>
270 <report todir="${test.dir}/report/html"/>
271 </junitreport>
272 <jacoco:report>
273 <executiondata>
274 <file file="${test.dir}/jacoco.exec"/>
275 </executiondata>
276 <structure name="JOSM Test Coverage">
277 <classfiles>
278 <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
279 </classfiles>
280 <sourcefiles encoding="UTF-8">
281 <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
282 </sourcefiles>
283 </structure>
284 <html destdir="${test.dir}/report/jacoco"/>
285 </jacoco:report>
286 </target>
287 <target name="dist-optimized" depends="dist">
288 <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
289 <proguard>
290 -injars dist/josm-custom.jar
291 -outjars dist/josm-custom-optimized.jar
292
293 -libraryjars ${java.home}/lib/rt.jar
294 -libraryjars ${java.home}/lib/jce.jar
295
296 -dontoptimize
297 -dontobfuscate
298
299 # These options probably are not necessary (and make processing a bit slower)
300 -dontskipnonpubliclibraryclasses
301 -dontskipnonpubliclibraryclassmembers
302
303 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
304 public static void main(java.lang.String[]);
305 }
306 -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
307
308 -keep class JOSM
309 -keep class * extends org.openstreetmap.josm.io.FileImporter
310 -keep class * extends org.openstreetmap.josm.io.FileExporter
311 -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
312 -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
313
314 -keepclassmembers enum * {
315 public static **[] values();
316 public static ** valueOf(java.lang.String);
317 }
318
319 # Keep unused public methods (can be useful for plugins)
320 -keepclassmembers class * {
321 public protected *;
322 }
323
324 # 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
325 -dontnote
326 </proguard>
327 </target>
328 <target name="check-plugins" depends="dist-optimized">
329 <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
330 <local name="dir"/>
331 <local name="plugins"/>
332 <property name="dir" value="plugin-check"/>
333 <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
334 <classpath path="tools/animal-sniffer-ant-tasks-1.8.jar"/>
335 </typedef>
336 <mkdir dir="${dir}"/>
337 <!-- List of deprecated plugins -->
338 <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
339 <filterchain>
340 <linecontains>
341 <contains value="new DeprecatedPlugin("/>
342 </linecontains>
343 <tokenfilter>
344 <replaceregex pattern=".*new DeprecatedPlugin\(&quot;(.+?)&quot;.*" replace="\1|" flags="gi"/>
345 </tokenfilter>
346 <striplinebreaks/>
347 <tokenfilter>
348 <replaceregex pattern="\|$" replace="" flags="gi"/>
349 </tokenfilter>
350 </filterchain>
351 </loadfile>
352 <!-- Download list of plugins -->
353 <loadresource property="plugins">
354 <url url="http://josm.openstreetmap.de/plugin"/>
355 <filterchain>
356 <linecontainsregexp negate="true">
357 <regexp pattern="^\t.*"/>
358 </linecontainsregexp>
359 <linecontainsregexp negate="true">
360 <regexp pattern="${deprecated-plugins}"/>
361 </linecontainsregexp>
362 <tokenfilter>
363 <replaceregex pattern="^.*;" replace="" flags="gi"/>
364 </tokenfilter>
365 </filterchain>
366 </loadresource>
367 <!-- Delete files that are not in plugin list (like old plugins) -->
368 <loadresource property="file-list">
369 <propertyresource name="plugins"/>
370 <filterchain>
371 <tokenfilter>
372 <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
373 </tokenfilter>
374 <striplinebreaks/>
375 <tokenfilter>
376 <replaceregex pattern="\|$" replace="" flags="gi"/>
377 </tokenfilter>
378 </filterchain>
379 </loadresource>
380 <delete>
381 <restrict>
382 <fileset dir="${dir}"/>
383 <not>
384 <name regex="${file-list}"/>
385 </not>
386 </restrict>
387 </delete>
388 <!-- Download plugins -->
389 <copy todir="${dir}" flatten="true">
390 <resourcelist>
391 <string value="${plugins}"/>
392 </resourcelist>
393 </copy>
394 <!-- Check plugins -->
395 <as:build-signatures destfile="${dir}/api.sig">
396 <path>
397 <fileset file="dist/josm-custom-optimized.jar"/>
398 <fileset file="${java.home}/lib/rt.jar"/>
399 <fileset file="${java.home}/lib/jce.jar"/>
400 </path>
401 </as:build-signatures>
402 <as:check-signature signature="${dir}/api.sig">
403 <ignore classname="org.jgraph.*"/>
404 <ignore classname="com.touchgraph.*"/>
405 <ignore classname="com.sun.xml.fastinfoset.*"/>
406 <ignore classname="javax.jms.*"/>
407 <ignore classname="org.jvnet.staxex.*"/>
408 <ignore classname="javax.mail.*"/>
409 <ignore classname="com.sun.jdmk.*"/>
410 <ignore classname="org.apache.avalon.framework.logger.Logger"/>
411 <ignore classname="org.apache.log.*"/>
412 <ignore classname="junit.*"/>
413 <path path="${dir}"/>
414 </as:check-signature>
415 </target>
416
417 <target name="findbugs" depends="dist">
418 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
419 <path id="findbugs-classpath">
420 <fileset dir="tools/findbugs/">
421 <include name="*.jar"/>
422 </fileset>
423 </path>
424 <property name="findbugs-classpath" refid="findbugs-classpath"/>
425 <findbugs output="xml"
426 outputFile="findbugs-josm.xml"
427 classpath="${findbugs-classpath}"
428 pluginList=""
429 excludeFilter="tools/findbugs/josm-filter.xml"
430 effort="max"
431 >
432 <sourcePath path="${basedir}/src" />
433 <class location="${basedir}/dist/josm-custom.jar" />
434 </findbugs>
435 </target>
436 <target name="run" depends="dist">
437 <java jar="dist/josm-custom.jar" fork="true">
438 <arg value="--set=expert=true"/>
439 <arg value="--set=remotecontrol.enabled=true"/>
440 <arg value="--set=debug.edt-checker.enable=false"/>
441 <jvmarg value="-Djosm.home=/tmp/.josm/"/>
442 </java>
443 </target>
444
445</project>
Note: See TracBrowser for help on using the repository browser.