1 | <!-- ** build.xml - main ant file for JOSM
|
---|
2 | **
|
---|
3 | ** To build run
|
---|
4 | ** ant clean
|
---|
5 | ** ant dist
|
---|
6 | ** This will create 'josm-custom.jar' in directory 'dist'. See also
|
---|
7 | ** https://josm.openstreetmap.de/wiki/CreateBuild
|
---|
8 | **
|
---|
9 | **
|
---|
10 | -->
|
---|
11 | <project name="josm" default="dist" basedir="." xmlns:as="antlib:org.codehaus.mojo.animal_sniffer">
|
---|
12 | <property name="test.dir" value="test" />
|
---|
13 | <property name="src.dir" value="src" />
|
---|
14 | <property name="build.dir" value="build"/>
|
---|
15 | <!-- build parameter: compression level (ant -Dclevel=N)
|
---|
16 | N ranges from 0 (no compression) to 9 (maximum compression)
|
---|
17 | default: 9 -->
|
---|
18 | <condition property="clevel" value="${clevel}" else="9">
|
---|
19 | <isset property="clevel" />
|
---|
20 | </condition>
|
---|
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>
|
---|
28 |
|
---|
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 | <!--
|
---|
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 |
|
---|
56 | <property name="version.entry.commit.revision" value="UNKNOWN"/>
|
---|
57 | <mkdir dir="${revision.dir}" />
|
---|
58 | <echo file="${revision.dir}/REVISION">
|
---|
59 | # automatically generated by JOSM build.xml - do not edit
|
---|
60 | Revision: ${version.entry.commit.revision}
|
---|
61 | Is-Local-Build: true
|
---|
62 | Build-Date: ${build.tstamp}
|
---|
63 | </echo>
|
---|
64 | </target>
|
---|
65 |
|
---|
66 |
|
---|
67 | <target name="dist" depends="compile,create-revision">
|
---|
68 |
|
---|
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"/>
|
---|
79 | <echo>Revision ${version.entry.commit.revision}</echo>
|
---|
80 | <copy file="CONTRIBUTION" todir="build"/>
|
---|
81 | <copy file="README" todir="build"/>
|
---|
82 | <copy file="LICENSE" todir="build"/>
|
---|
83 |
|
---|
84 | <!-- create josm-custom.jar -->
|
---|
85 | <delete file="dist/josm-custom.jar"/>
|
---|
86 | <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
|
---|
87 | <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
|
---|
88 | <manifest>
|
---|
89 | <attribute name="Main-class" value="JOSM" />
|
---|
90 | <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
|
---|
91 | <attribute name="Main-Date" value="${version.entry.commit.date}"/>
|
---|
92 | </manifest>
|
---|
93 | <zipfileset dir="images" prefix="images" />
|
---|
94 | <zipfileset dir="data" prefix="data" />
|
---|
95 | <zipfileset dir="styles" prefix="styles" />
|
---|
96 | <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images" />
|
---|
97 |
|
---|
98 | <!-- All jar files necessary to run only JOSM (no tests) -->
|
---|
99 | <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar" />
|
---|
100 | <zipfileset src="lib/signpost-core-1.2.1.1.jar" />
|
---|
101 | </jar>
|
---|
102 | </target>
|
---|
103 |
|
---|
104 | <target name="distmac" depends="dist">
|
---|
105 | <!-- modify MacOS X Info.plist file to hold the SVN version number -->
|
---|
106 | <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/>
|
---|
107 | <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/>
|
---|
108 | <!-- create ZIP file with MacOS X application bundle -->
|
---|
109 | <zip destfile="dist/josm-custom-macosx.zip" update="true">
|
---|
110 | <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/>
|
---|
111 | <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"/>
|
---|
112 | <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/>
|
---|
113 | <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/>
|
---|
114 | <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/>
|
---|
115 | </zip>
|
---|
116 | </target>
|
---|
117 |
|
---|
118 | <target name="compile" depends="init">
|
---|
119 | <javac srcdir="src" classpathref="classpath" destdir="build"
|
---|
120 | target="1.5" source="1.5" debug="on" encoding="UTF-8">
|
---|
121 | <compilerarg value="-Xlint:deprecation"/>
|
---|
122 | <compilerarg value="-Xlint:unchecked"/>
|
---|
123 | </javac>
|
---|
124 | </target>
|
---|
125 |
|
---|
126 | <target name="init">
|
---|
127 | <mkdir dir="build" />
|
---|
128 | <mkdir dir="dist" />
|
---|
129 | </target>
|
---|
130 |
|
---|
131 | <target name="clean">
|
---|
132 | <delete dir="build" />
|
---|
133 | <delete dir="dist" />
|
---|
134 | </target>
|
---|
135 |
|
---|
136 | <target name="javacc">
|
---|
137 | <exec executable="javacc">
|
---|
138 | <arg value="-debug_parser=false"/>
|
---|
139 | <arg value="-debug_lookahead=false"/>
|
---|
140 | <arg value="-debug_token_manager=false"/>
|
---|
141 | <arg value="-output_directory=${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss/parser"/>
|
---|
142 | <arg value="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParser.jj"/>
|
---|
143 | </exec>
|
---|
144 | </target>
|
---|
145 |
|
---|
146 | <path id="test.classpath">
|
---|
147 | <fileset dir="${test.dir}/lib">
|
---|
148 | <include name="**/*.jar"/>
|
---|
149 | </fileset>
|
---|
150 | <fileset dir="lib">
|
---|
151 | <include name="**/*.jar"/>
|
---|
152 | </fileset>
|
---|
153 | <pathelement path="dist/josm-custom.jar"/>
|
---|
154 | </path>
|
---|
155 |
|
---|
156 | <target name="test-init">
|
---|
157 | <mkdir dir="${test.dir}/${build.dir}" />
|
---|
158 | <mkdir dir="${test.dir}/report" />
|
---|
159 | </target>
|
---|
160 |
|
---|
161 | <target name="test-clean">
|
---|
162 | <delete dir="${test.dir}/${build.dir}"/>
|
---|
163 | <delete dir="${test.dir}/report"/>
|
---|
164 | </target>
|
---|
165 |
|
---|
166 | <target name="test-compile" depends="test-init,dist">
|
---|
167 | <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
|
---|
168 | target="1.5" source="1.5" debug="on" encoding="UTF-8">
|
---|
169 | <compilerarg value="-Xlint:deprecation"/>
|
---|
170 | <compilerarg value="-Xlint:unchecked"/>
|
---|
171 | </javac>
|
---|
172 | <javac srcdir="${test.dir}/functional" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
|
---|
173 | target="1.5" source="1.5" debug="on" encoding="UTF-8">
|
---|
174 | <compilerarg value="-Xlint:deprecation"/>
|
---|
175 | <compilerarg value="-Xlint:unchecked"/>
|
---|
176 | </javac>
|
---|
177 | </target>
|
---|
178 |
|
---|
179 | <target name="test" depends="test-compile">
|
---|
180 | <junit printsummary="yes">
|
---|
181 | <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
|
---|
182 | <sysproperty key="java.awt.headless" value="true"/>
|
---|
183 | <classpath>
|
---|
184 | <path refid="test.classpath"/>
|
---|
185 | <pathelement path="${test.dir}/${build.dir}"/>
|
---|
186 | <pathelement path="${test.dir}/config"/>
|
---|
187 | </classpath>
|
---|
188 | <formatter type="plain"/>
|
---|
189 | <formatter type="xml"/>
|
---|
190 | <batchtest fork="yes" todir="${test.dir}/report">
|
---|
191 | <fileset dir="${test.dir}/unit" includes="**/*.java"/>
|
---|
192 | </batchtest>
|
---|
193 | </junit>
|
---|
194 | </target>
|
---|
195 |
|
---|
196 | <target name="test-html" depends="test" description="Generate HTML test reports">
|
---|
197 | <!-- May require additional ant dependencies like ant-trax package -->
|
---|
198 | <junitreport todir="${test.dir}/report">
|
---|
199 | <fileset dir="${test.dir}/report">
|
---|
200 | <include name="TEST-*.xml"/>
|
---|
201 | </fileset>
|
---|
202 | <report todir="${test.dir}/report/html"/>
|
---|
203 | </junitreport>
|
---|
204 | </target>
|
---|
205 |
|
---|
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 | -dontskipnonpubliclibraryclasses
|
---|
219 |
|
---|
220 | -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
|
---|
221 | public static void main(java.lang.String[]);
|
---|
222 | }
|
---|
223 |
|
---|
224 | -keep class JOSM
|
---|
225 | -keep class * extends org.openstreetmap.josm.io.FileImporter
|
---|
226 | -keep class * extends org.openstreetmap.josm.io.FileExporter
|
---|
227 | -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
|
---|
228 |
|
---|
229 | -keepclassmembers enum * {
|
---|
230 | public static **[] values();
|
---|
231 | public static ** valueOf(java.lang.String);
|
---|
232 | }
|
---|
233 |
|
---|
234 | -keepclassmembers class * {
|
---|
235 | public protected *;
|
---|
236 | }
|
---|
237 | </proguard>
|
---|
238 | </target>
|
---|
239 |
|
---|
240 | <target name="check-plugins" depends="dist-optimized">
|
---|
241 | <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
|
---|
242 |
|
---|
243 | <local name="dir"/>
|
---|
244 | <local name="plugins"/>
|
---|
245 |
|
---|
246 | <property name="dir" value="plugin-check"/>
|
---|
247 |
|
---|
248 | <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
|
---|
249 | <classpath path="tools/animal-sniffer-ant-tasks-1.5.jar" />
|
---|
250 | </typedef>
|
---|
251 |
|
---|
252 | <delete dir="${dir}"/>
|
---|
253 |
|
---|
254 | <mkdir dir="${dir}"/>
|
---|
255 |
|
---|
256 | <as:build-signatures destfile="${dir}/api.sig">
|
---|
257 | <path>
|
---|
258 | <fileset file="dist/josm-custom-optimized.jar" />
|
---|
259 | <fileset file="${java.home}/lib/rt.jar" />
|
---|
260 | <fileset file="${java.home}/lib/jce.jar" />
|
---|
261 | </path>
|
---|
262 | </as:build-signatures>
|
---|
263 |
|
---|
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 |
|
---|
280 | <!-- Download plugins -->
|
---|
281 | <loadresource property="plugins">
|
---|
282 | <url url="http://josm.openstreetmap.de/plugin"/>
|
---|
283 | <filterchain>
|
---|
284 | <linecontainsregexp negate="true">
|
---|
285 | <regexp pattern="^\t.*"/>
|
---|
286 | </linecontainsregexp>
|
---|
287 | <linecontainsregexp negate="true">
|
---|
288 | <regexp pattern="${deprecated-plugins}"/>
|
---|
289 | </linecontainsregexp>
|
---|
290 | <tokenfilter>
|
---|
291 | <replaceregex pattern="^.*;" replace="" flags="gi"/>
|
---|
292 | </tokenfilter>
|
---|
293 | </filterchain>
|
---|
294 | </loadresource>
|
---|
295 |
|
---|
296 | <copy todir="${dir}" flatten="true">
|
---|
297 | <resourcelist>
|
---|
298 | <string value="${plugins}"/>
|
---|
299 | </resourcelist>
|
---|
300 | </copy>
|
---|
301 |
|
---|
302 | <!-- Check plugins -->
|
---|
303 | <as:check-signature signature="${dir}/api.sig">
|
---|
304 | <ignore classname="org.jgraph.*"/>
|
---|
305 | <ignore classname="com.touchgraph.*"/>
|
---|
306 | <ignore classname="com.sun.xml.fastinfoset.*"/>
|
---|
307 | <ignore classname="javax.jms.*"/>
|
---|
308 | <ignore classname="org.jvnet.staxex.*"/>
|
---|
309 | <ignore classname="javax.mail.*"/>
|
---|
310 | <ignore classname="com.sun.jdmk.*"/>
|
---|
311 | <ignore classname="org.apache.avalon.framework.logger.Logger"/>
|
---|
312 | <ignore classname="org.apache.log.*"/>
|
---|
313 | <ignore classname="junit.*"/>
|
---|
314 | <path path="${dir}"/>
|
---|
315 | </as:check-signature>
|
---|
316 |
|
---|
317 | </target>
|
---|
318 |
|
---|
319 |
|
---|
320 | </project>
|
---|