source: josm/trunk/build.xml@ 6993

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

fix #9778 - more https accesses to josm website

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