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
|
---|
59 | Revision: ${version.entry.commit.revision}
|
---|
60 | Is-Local-Build: true
|
---|
61 | Build-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 | <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
|
---|
111 | <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
|
---|
112 | </uptodate>
|
---|
113 | <target name="javacc" unless="javacc.notRequired">
|
---|
114 | <mkdir dir="${mapcss.dir}/parsergen"/>
|
---|
115 | <exec append="false" executable="java" failifexecutionfails="true">
|
---|
116 | <arg value="-cp"/>
|
---|
117 | <arg value="${javacc.home}/javacc.jar"/>
|
---|
118 | <arg value="javacc"/>
|
---|
119 | <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
|
---|
120 | <arg value="${mapcss.dir}/MapCSSParser.jj"/>
|
---|
121 | </exec>
|
---|
122 | <!-- <javacc target="${mapcss.dir}/MapCSSParser.jj" javacchome="${javacc.home}" outputdirectory="${mapcss.dir}/parsergen"/>-->
|
---|
123 | </target>
|
---|
124 | <target name="compile" depends="javacc,init">
|
---|
125 | <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.5" source="1.5" debug="on" encoding="iso-8859-1"/>
|
---|
126 | <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**" destdir="build" target="1.5" source="1.5" debug="on" encoding="UTF-8">
|
---|
127 | <compilerarg value="-Xlint:deprecation"/>
|
---|
128 | <compilerarg value="-Xlint:unchecked"/>
|
---|
129 | </javac>
|
---|
130 | </target>
|
---|
131 | <target name="init">
|
---|
132 | <mkdir dir="build"/>
|
---|
133 | <mkdir dir="dist"/>
|
---|
134 | </target>
|
---|
135 | <target name="javadoc">
|
---|
136 | <javadoc destdir="javadoc"
|
---|
137 | sourcepath="src"
|
---|
138 | packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
|
---|
139 | windowtitle="JOSM"
|
---|
140 | use="true"
|
---|
141 | linksource="true"
|
---|
142 | author="false">
|
---|
143 | <link href="http://docs.oracle.com/javase/6/docs/api"/>
|
---|
144 | <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
|
---|
145 | <bottom><![CDATA[<a href="http://josm.openstreetmap.de/">JOSM</a>]]></bottom>
|
---|
146 | </javadoc>
|
---|
147 | </target>
|
---|
148 | <target name="clean">
|
---|
149 | <delete dir="build"/>
|
---|
150 | <delete dir="dist"/>
|
---|
151 | <delete dir="${mapcss.dir}/parsergen"/>
|
---|
152 | </target>
|
---|
153 | <path id="test.classpath">
|
---|
154 | <fileset dir="${test.dir}/lib">
|
---|
155 | <include name="**/*.jar"/>
|
---|
156 | </fileset>
|
---|
157 | <fileset dir="lib">
|
---|
158 | <include name="**/*.jar"/>
|
---|
159 | </fileset>
|
---|
160 | <pathelement path="dist/josm-custom.jar"/>
|
---|
161 | </path>
|
---|
162 | <target name="test-init">
|
---|
163 | <mkdir dir="${test.dir}/${build.dir}"/>
|
---|
164 | <mkdir dir="${test.dir}/report"/>
|
---|
165 | </target>
|
---|
166 | <target name="test-clean">
|
---|
167 | <delete dir="${test.dir}/${build.dir}"/>
|
---|
168 | <delete dir="${test.dir}/report"/>
|
---|
169 | </target>
|
---|
170 | <target name="test-compile" depends="test-init,dist">
|
---|
171 | <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
|
---|
172 | <compilerarg value="-Xlint:deprecation"/>
|
---|
173 | <compilerarg value="-Xlint:unchecked"/>
|
---|
174 | </javac>
|
---|
175 | <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" target="1.5" source="1.5" debug="on" encoding="UTF-8">
|
---|
176 | <compilerarg value="-Xlint:deprecation"/>
|
---|
177 | <compilerarg value="-Xlint:unchecked"/>
|
---|
178 | </javac>
|
---|
179 | </target>
|
---|
180 | <target name="test" depends="test-compile">
|
---|
181 | <junit printsummary="yes">
|
---|
182 | <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
|
---|
183 | <sysproperty key="java.awt.headless" value="true"/>
|
---|
184 | <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
|
---|
185 | <classpath>
|
---|
186 | <path refid="test.classpath"/>
|
---|
187 | <pathelement path="${test.dir}/${build.dir}"/>
|
---|
188 | <pathelement path="${test.dir}/config"/>
|
---|
189 | </classpath>
|
---|
190 | <formatter type="plain"/>
|
---|
191 | <formatter type="xml"/>
|
---|
192 | <batchtest fork="yes" todir="${test.dir}/report">
|
---|
193 | <fileset dir="${test.dir}/unit" includes="**/*.java"/>
|
---|
194 | </batchtest>
|
---|
195 | </junit>
|
---|
196 | </target>
|
---|
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 | <target name="dist-optimized" depends="dist">
|
---|
207 | <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
|
---|
208 | <proguard>
|
---|
209 | -injars dist/josm-custom.jar
|
---|
210 | -outjars dist/josm-custom-optimized.jar
|
---|
211 |
|
---|
212 | -libraryjars ${java.home}/lib/rt.jar
|
---|
213 | -libraryjars ${java.home}/lib/jce.jar
|
---|
214 |
|
---|
215 | -dontoptimize
|
---|
216 | -dontobfuscate
|
---|
217 |
|
---|
218 | # These options probably are not necessary (and make processing a bit slower)
|
---|
219 | -dontskipnonpubliclibraryclasses
|
---|
220 | -dontskipnonpubliclibraryclassmembers
|
---|
221 |
|
---|
222 | -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
|
---|
223 | public static void main(java.lang.String[]);
|
---|
224 | }
|
---|
225 | -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
|
---|
226 |
|
---|
227 | -keep class JOSM
|
---|
228 | -keep class * extends org.openstreetmap.josm.io.FileImporter
|
---|
229 | -keep class * extends org.openstreetmap.josm.io.FileExporter
|
---|
230 | -keep class org.openstreetmap.josm.data.imagery.types.Adapter1
|
---|
231 | -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
|
---|
232 |
|
---|
233 | -keepclassmembers enum * {
|
---|
234 | public static **[] values();
|
---|
235 | public static ** valueOf(java.lang.String);
|
---|
236 | }
|
---|
237 |
|
---|
238 | # Keep unused public methods (can be useful for plugins)
|
---|
239 | -keepclassmembers class * {
|
---|
240 | public protected *;
|
---|
241 | }
|
---|
242 |
|
---|
243 | # 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
|
---|
244 | -dontnote
|
---|
245 | </proguard>
|
---|
246 | </target>
|
---|
247 | <target name="check-plugins" depends="dist-optimized">
|
---|
248 | <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
|
---|
249 | <local name="dir"/>
|
---|
250 | <local name="plugins"/>
|
---|
251 | <property name="dir" value="plugin-check"/>
|
---|
252 | <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
|
---|
253 | <classpath path="tools/animal-sniffer-ant-tasks-1.7.jar"/>
|
---|
254 | </typedef>
|
---|
255 | <delete dir="${dir}"/>
|
---|
256 | <mkdir dir="${dir}"/>
|
---|
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"/>
|
---|
261 | <fileset file="${java.home}/lib/jce.jar"/>
|
---|
262 | </path>
|
---|
263 | </as:build-signatures>
|
---|
264 | <!-- List of deprecated plugins -->
|
---|
265 | <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java">
|
---|
266 | <filterchain>
|
---|
267 | <linecontains>
|
---|
268 | <contains value="new DeprecatedPlugin("/>
|
---|
269 | </linecontains>
|
---|
270 | <tokenfilter>
|
---|
271 | <replaceregex pattern=".*new DeprecatedPlugin\("(.+?)".*" replace="\1|" flags="gi"/>
|
---|
272 | </tokenfilter>
|
---|
273 | <striplinebreaks/>
|
---|
274 | <tokenfilter>
|
---|
275 | <replaceregex pattern="\|$" replace="" flags="gi"/>
|
---|
276 | </tokenfilter>
|
---|
277 | </filterchain>
|
---|
278 | </loadfile>
|
---|
279 | <!-- Download plugins -->
|
---|
280 | <loadresource property="plugins">
|
---|
281 | <url url="http://josm.openstreetmap.de/plugin"/>
|
---|
282 | <filterchain>
|
---|
283 | <linecontainsregexp negate="true">
|
---|
284 | <regexp pattern="^\t.*"/>
|
---|
285 | </linecontainsregexp>
|
---|
286 | <linecontainsregexp negate="true">
|
---|
287 | <regexp pattern="${deprecated-plugins}"/>
|
---|
288 | </linecontainsregexp>
|
---|
289 | <tokenfilter>
|
---|
290 | <replaceregex pattern="^.*;" replace="" flags="gi"/>
|
---|
291 | </tokenfilter>
|
---|
292 | </filterchain>
|
---|
293 | </loadresource>
|
---|
294 | <copy todir="${dir}" flatten="true">
|
---|
295 | <resourcelist>
|
---|
296 | <string value="${plugins}"/>
|
---|
297 | </resourcelist>
|
---|
298 | </copy>
|
---|
299 | <!-- Check plugins -->
|
---|
300 | <as:check-signature signature="${dir}/api.sig">
|
---|
301 | <ignore classname="org.jgraph.*"/>
|
---|
302 | <ignore classname="com.touchgraph.*"/>
|
---|
303 | <ignore classname="com.sun.xml.fastinfoset.*"/>
|
---|
304 | <ignore classname="javax.jms.*"/>
|
---|
305 | <ignore classname="org.jvnet.staxex.*"/>
|
---|
306 | <ignore classname="javax.mail.*"/>
|
---|
307 | <ignore classname="com.sun.jdmk.*"/>
|
---|
308 | <ignore classname="org.apache.avalon.framework.logger.Logger"/>
|
---|
309 | <ignore classname="org.apache.log.*"/>
|
---|
310 | <ignore classname="junit.*"/>
|
---|
311 | <path path="${dir}"/>
|
---|
312 | </as:check-signature>
|
---|
313 | </target>
|
---|
314 |
|
---|
315 | <target name="findbugs" depends="dist">
|
---|
316 | <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
|
---|
317 | <path id="findbugs-classpath">
|
---|
318 | <fileset dir="tools/findbugs/">
|
---|
319 | <include name="*.jar"/>
|
---|
320 | </fileset>
|
---|
321 | </path>
|
---|
322 | <property name="findbugs-classpath" refid="findbugs-classpath"/>
|
---|
323 | <findbugs output="xml"
|
---|
324 | outputFile="findbugs-josm.xml"
|
---|
325 | classpath="${findbugs-classpath}"
|
---|
326 | pluginList=""
|
---|
327 | excludeFilter="tools/findbugs/josm-filter.xml"
|
---|
328 | effort="max"
|
---|
329 | >
|
---|
330 | <sourcePath path="${basedir}/src" />
|
---|
331 | <class location="${basedir}/dist/josm-custom.jar" />
|
---|
332 | </findbugs>
|
---|
333 | </target>
|
---|
334 | <target name="run" depends="dist">
|
---|
335 | <java jar="dist/josm-custom.jar" fork="true">
|
---|
336 | <arg value="--set=expert=true"/>
|
---|
337 | <arg value="--set=remotecontrol.enabled=true"/>
|
---|
338 | <arg value="--set=debug.edt-checker.enable=false"/>
|
---|
339 | <jvmarg value="-Djosm.home=/tmp/.josm/"/>
|
---|
340 | </java>
|
---|
341 | </target>
|
---|
342 |
|
---|
343 | </project>
|
---|