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 | <copy file="styles/standard/elemstyles.xml" todir="data"/> |
---|
36 | <property name="revision.dir" value="bin"/> |
---|
37 | <antcall target="create-revision" /> |
---|
38 | </target> |
---|
39 | |
---|
40 | <!-- |
---|
41 | ** Creates the REVISION file to be included in the distribution |
---|
42 | --> |
---|
43 | <target name="create-revision"> |
---|
44 | <property name="revision.dir" value="${build.dir}"/> |
---|
45 | <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false"> |
---|
46 | <env key="LANG" value="C"/> |
---|
47 | <arg value="info"/> |
---|
48 | <arg value="--xml"/> |
---|
49 | <arg value="."/> |
---|
50 | </exec> |
---|
51 | <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/> |
---|
52 | <delete file="REVISION.XML" /> |
---|
53 | <tstamp> |
---|
54 | <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/> |
---|
55 | </tstamp> |
---|
56 | |
---|
57 | <property name="version.entry.commit.revision" value="UNKNOWN"/> |
---|
58 | <mkdir dir="${revision.dir}" /> |
---|
59 | <echo file="${revision.dir}/REVISION"> |
---|
60 | # automatically generated by JOSM build.xml - do not edit |
---|
61 | Revision: ${version.entry.commit.revision} |
---|
62 | Is-Local-Build: true |
---|
63 | Build-Date: ${build.tstamp} |
---|
64 | </echo> |
---|
65 | </target> |
---|
66 | |
---|
67 | |
---|
68 | <target name="dist" depends="compile,create-revision"> |
---|
69 | |
---|
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"/> |
---|
80 | <echo>Revision ${version.entry.commit.revision}</echo> |
---|
81 | <copy file="CONTRIBUTION" todir="build"/> |
---|
82 | <copy file="README" todir="build"/> |
---|
83 | <copy file="LICENSE" todir="build"/> |
---|
84 | |
---|
85 | <!-- styles --> |
---|
86 | <copy file="styles/standard/elemstyles.xml" todir="build/data"/> |
---|
87 | |
---|
88 | <!-- create josm-custom.jar --> |
---|
89 | <delete file="dist/josm-custom.jar"/> |
---|
90 | <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}"> |
---|
91 | <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar --> |
---|
92 | <manifest> |
---|
93 | <attribute name="Main-class" value="JOSM" /> |
---|
94 | <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/> |
---|
95 | <attribute name="Main-Date" value="${version.entry.commit.date}"/> |
---|
96 | </manifest> |
---|
97 | <zipfileset dir="images" prefix="images" /> |
---|
98 | <zipfileset dir="data" prefix="data" /> |
---|
99 | <zipfileset dir="src/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images" /> |
---|
100 | |
---|
101 | <!-- All jar files necessary to run only JOSM (no tests) --> |
---|
102 | <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar" /> |
---|
103 | <zipfileset src="lib/signpost-core-1.2.1.1.jar" /> |
---|
104 | </jar> |
---|
105 | </target> |
---|
106 | |
---|
107 | <target name="distmac" depends="dist"> |
---|
108 | <!-- modify MacOS X Info.plist file to hold the SVN version number --> |
---|
109 | <copy file="macosx/JOSM.app/Contents/Info.plist" todir="build"/> |
---|
110 | <replace file="build/Info.plist" token="@SVNVersion@" value="${version.entry.commit.revision}"/> |
---|
111 | <!-- create ZIP file with MacOS X application bundle --> |
---|
112 | <zip destfile="dist/josm-custom-macosx.zip" update="true"> |
---|
113 | <zipfileset dir="build" includes="CONTRIBUTION README LICENSE"/> |
---|
114 | <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"/> |
---|
115 | <zipfileset dir="build" includes="Info.plist" prefix="JOSM.app/Contents"/> |
---|
116 | <zipfileset dir="dist" includes="josm-custom.jar" prefix="JOSM.app/Contents/Resources/Java"/> |
---|
117 | <zipfileset dir="macosx" includes="JOSM.app/Contents/MacOS/JOSM" filemode="755"/> |
---|
118 | </zip> |
---|
119 | </target> |
---|
120 | |
---|
121 | <target name="compile" depends="init"> |
---|
122 | <javac srcdir="src" classpathref="classpath" destdir="build" |
---|
123 | target="1.5" source="1.5" debug="on" encoding="UTF-8"> |
---|
124 | <compilerarg value="-Xlint:deprecation"/> |
---|
125 | <compilerarg value="-Xlint:unchecked"/> |
---|
126 | </javac> |
---|
127 | </target> |
---|
128 | |
---|
129 | <target name="init"> |
---|
130 | <mkdir dir="build" /> |
---|
131 | <mkdir dir="dist" /> |
---|
132 | </target> |
---|
133 | |
---|
134 | <target name="clean"> |
---|
135 | <delete dir="build" /> |
---|
136 | <delete dir="dist" /> |
---|
137 | </target> |
---|
138 | |
---|
139 | <target name="javacc"> |
---|
140 | <exec executable="javacc"> |
---|
141 | <arg value="-debug_parser=false"/> |
---|
142 | <arg value="-debug_lookahead=false"/> |
---|
143 | <arg value="-debug_token_manager=false"/> |
---|
144 | <arg value="-output_directory=${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss/parser"/> |
---|
145 | <arg value="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParser.jj"/> |
---|
146 | </exec> |
---|
147 | </target> |
---|
148 | |
---|
149 | <path id="test.classpath"> |
---|
150 | <fileset dir="${test.dir}/lib"> |
---|
151 | <include name="**/*.jar"/> |
---|
152 | </fileset> |
---|
153 | <fileset dir="lib"> |
---|
154 | <include name="**/*.jar"/> |
---|
155 | </fileset> |
---|
156 | <pathelement path="dist/josm-custom.jar"/> |
---|
157 | </path> |
---|
158 | |
---|
159 | <target name="test-init"> |
---|
160 | <mkdir dir="${test.dir}/${build.dir}" /> |
---|
161 | <mkdir dir="${test.dir}/report" /> |
---|
162 | </target> |
---|
163 | |
---|
164 | <target name="test-clean"> |
---|
165 | <delete dir="${test.dir}/${build.dir}"/> |
---|
166 | <delete dir="${test.dir}/report"/> |
---|
167 | </target> |
---|
168 | |
---|
169 | <target name="test-compile" depends="test-init,dist"> |
---|
170 | <javac srcdir="${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}" |
---|
171 | 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}" |
---|
176 | target="1.5" source="1.5" debug="on" encoding="UTF-8"> |
---|
177 | <compilerarg value="-Xlint:deprecation"/> |
---|
178 | <compilerarg value="-Xlint:unchecked"/> |
---|
179 | </javac> |
---|
180 | </target> |
---|
181 | |
---|
182 | <target name="test" depends="test-compile"> |
---|
183 | <junit printsummary="yes"> |
---|
184 | <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/> |
---|
185 | <sysproperty key="java.awt.headless" value="true"/> |
---|
186 | <classpath> |
---|
187 | <path refid="test.classpath"/> |
---|
188 | <pathelement path="${test.dir}/${build.dir}"/> |
---|
189 | <pathelement path="${test.dir}/config"/> |
---|
190 | </classpath> |
---|
191 | <formatter type="plain"/> |
---|
192 | <formatter type="xml"/> |
---|
193 | <batchtest fork="yes" todir="${test.dir}/report"> |
---|
194 | <fileset dir="${test.dir}/unit" includes="**/*.java"/> |
---|
195 | </batchtest> |
---|
196 | </junit> |
---|
197 | </target> |
---|
198 | |
---|
199 | <target name="test-html" depends="test" description="Generate HTML test reports"> |
---|
200 | <!-- May require additional ant dependencies like ant-trax package --> |
---|
201 | <junitreport todir="${test.dir}/report"> |
---|
202 | <fileset dir="${test.dir}/report"> |
---|
203 | <include name="TEST-*.xml"/> |
---|
204 | </fileset> |
---|
205 | <report todir="${test.dir}/report/html"/> |
---|
206 | </junitreport> |
---|
207 | </target> |
---|
208 | |
---|
209 | <target name="dist-optimized" depends="dist"> |
---|
210 | <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar" /> |
---|
211 | <proguard> |
---|
212 | -injars dist/josm-custom.jar |
---|
213 | -outjars dist/josm-custom-optimized.jar |
---|
214 | |
---|
215 | -libraryjars ${java.home}/lib/rt.jar |
---|
216 | -libraryjars ${java.home}/lib/jce.jar |
---|
217 | |
---|
218 | -dontoptimize |
---|
219 | -dontobfuscate |
---|
220 | |
---|
221 | -dontskipnonpubliclibraryclasses |
---|
222 | |
---|
223 | -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication { |
---|
224 | public static void main(java.lang.String[]); |
---|
225 | } |
---|
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.actions.search.SearchCompiler$Never |
---|
231 | |
---|
232 | -keepclassmembers enum * { |
---|
233 | public static **[] values(); |
---|
234 | public static ** valueOf(java.lang.String); |
---|
235 | } |
---|
236 | |
---|
237 | -keepclassmembers class * { |
---|
238 | public protected *; |
---|
239 | } |
---|
240 | </proguard> |
---|
241 | </target> |
---|
242 | |
---|
243 | <target name="check-plugins" depends="dist-optimized"> |
---|
244 | <echo message="Check of plugins binary compatibility (needs ant 1.8)"/> |
---|
245 | |
---|
246 | <local name="dir"/> |
---|
247 | <local name="plugins"/> |
---|
248 | |
---|
249 | <property name="dir" value="plugin-check"/> |
---|
250 | |
---|
251 | <typedef uri="antlib:org.codehaus.mojo.animal_sniffer"> |
---|
252 | <classpath path="tools/animal-sniffer-ant-tasks-1.5.jar" /> |
---|
253 | </typedef> |
---|
254 | |
---|
255 | <delete dir="${dir}"/> |
---|
256 | |
---|
257 | <mkdir dir="${dir}"/> |
---|
258 | |
---|
259 | <as:build-signatures destfile="${dir}/api.sig"> |
---|
260 | <path> |
---|
261 | <fileset file="dist/josm-custom-optimized.jar" /> |
---|
262 | <fileset file="${java.home}/lib/rt.jar" /> |
---|
263 | <fileset file="${java.home}/lib/jce.jar" /> |
---|
264 | </path> |
---|
265 | </as:build-signatures> |
---|
266 | |
---|
267 | <!-- List of deprecated plugins --> |
---|
268 | <loadfile property="deprecated-plugins" srcFile="src/org/openstreetmap/josm/plugins/PluginHandler.java"> |
---|
269 | <filterchain> |
---|
270 | <linecontains> |
---|
271 | <contains value="new DeprecatedPlugin("/> |
---|
272 | </linecontains> |
---|
273 | <tokenfilter> |
---|
274 | <replaceregex pattern='.*new DeprecatedPlugin\("(.+?)".*' replace="\1|" flags="gi"/> |
---|
275 | </tokenfilter> |
---|
276 | <striplinebreaks/> |
---|
277 | <tokenfilter> |
---|
278 | <replaceregex pattern='\|$' replace="" flags="gi"/> |
---|
279 | </tokenfilter> |
---|
280 | </filterchain> |
---|
281 | </loadfile> |
---|
282 | |
---|
283 | <!-- Download plugins --> |
---|
284 | <loadresource property="plugins"> |
---|
285 | <url url="http://josm.openstreetmap.de/plugin"/> |
---|
286 | <filterchain> |
---|
287 | <linecontainsregexp negate="true"> |
---|
288 | <regexp pattern="^\t.*"/> |
---|
289 | </linecontainsregexp> |
---|
290 | <linecontainsregexp negate="true"> |
---|
291 | <regexp pattern="${deprecated-plugins}"/> |
---|
292 | </linecontainsregexp> |
---|
293 | <tokenfilter> |
---|
294 | <replaceregex pattern="^.*;" replace="" flags="gi"/> |
---|
295 | </tokenfilter> |
---|
296 | </filterchain> |
---|
297 | </loadresource> |
---|
298 | |
---|
299 | <copy todir="${dir}" flatten="true"> |
---|
300 | <resourcelist> |
---|
301 | <string value="${plugins}"/> |
---|
302 | </resourcelist> |
---|
303 | </copy> |
---|
304 | |
---|
305 | <!-- Check plugins --> |
---|
306 | <as:check-signature signature="${dir}/api.sig"> |
---|
307 | <ignore classname="org.jgraph.*"/> |
---|
308 | <ignore classname="com.touchgraph.*"/> |
---|
309 | <ignore classname="com.sun.xml.fastinfoset.*"/> |
---|
310 | <ignore classname="javax.jms.*"/> |
---|
311 | <ignore classname="org.jvnet.staxex.*"/> |
---|
312 | <ignore classname="javax.mail.*"/> |
---|
313 | <ignore classname="com.sun.jdmk.*"/> |
---|
314 | <ignore classname="org.apache.avalon.framework.logger.Logger"/> |
---|
315 | <ignore classname="org.apache.log.*"/> |
---|
316 | <ignore classname="junit.*"/> |
---|
317 | <path path="${dir}"/> |
---|
318 | </as:check-signature> |
---|
319 | |
---|
320 | </target> |
---|
321 | |
---|
322 | |
---|
323 | </project> |
---|