| 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/DevelopersGuide/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 |     <property name="imagerytypes.dir" location="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
 | 
|---|
| 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 |     <!-- For Windows-specific stuff -->
 | 
|---|
| 25 |     <condition property="isWindows">
 | 
|---|
| 26 |         <os family="Windows"/>
 | 
|---|
| 27 |     </condition>
 | 
|---|
| 28 | 
 | 
|---|
| 29 |     <!--
 | 
|---|
| 30 |       ** Used by Eclipse ant builder for updating
 | 
|---|
| 31 |       ** the REVISION file used by JOSM
 | 
|---|
| 32 |     -->
 | 
|---|
| 33 |     <target name="create-revision-eclipse">
 | 
|---|
| 34 |         <property name="revision.dir" value="bin"/>
 | 
|---|
| 35 |         <antcall target="create-revision"/>
 | 
|---|
| 36 |     </target>
 | 
|---|
| 37 |     <!--
 | 
|---|
| 38 |       ** Initializes the REVISION.XML file from SVN information
 | 
|---|
| 39 |     -->
 | 
|---|
| 40 |     <target name="init-svn-revision-xml">
 | 
|---|
| 41 |         <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false" resultproperty="svn.info.result">
 | 
|---|
| 42 |             <env key="LANG" value="C"/>
 | 
|---|
| 43 |             <arg value="info"/>
 | 
|---|
| 44 |             <arg value="--xml"/>
 | 
|---|
| 45 |             <arg value="."/>
 | 
|---|
| 46 |         </exec>
 | 
|---|
| 47 |         <condition property="svn.info.success">
 | 
|---|
| 48 |             <equals arg1="${svn.info.result}" arg2="0" />
 | 
|---|
| 49 |         </condition>
 | 
|---|
| 50 |     </target>
 | 
|---|
| 51 |     <!--
 | 
|---|
| 52 |       ** Initializes the REVISION.XML file from git information
 | 
|---|
| 53 |     -->
 | 
|---|
| 54 |     <target name="init-git-revision-xml" unless="svn.info.success">
 | 
|---|
| 55 |         <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false">
 | 
|---|
| 56 |             <arg value="log"/>
 | 
|---|
| 57 |             <arg value="-1"/>
 | 
|---|
| 58 |             <arg value="--grep=git-svn-id"/>
 | 
|---|
| 59 |             <!--
 | 
|---|
| 60 |             %B:  raw body (unwrapped subject and body)
 | 
|---|
| 61 |             %n:  new line
 | 
|---|
| 62 |             %ai: author date, ISO 8601 format
 | 
|---|
| 63 |             -->
 | 
|---|
| 64 |             <arg value="--pretty=format:%B%n%ai"/>
 | 
|---|
| 65 |             <arg value="HEAD"/>
 | 
|---|
| 66 |         </exec>
 | 
|---|
| 67 |         <replaceregexp file="REVISION.XML" flags="s"
 | 
|---|
| 68 |                        match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
 | 
|---|
| 69 |                        replace="<info><entry><commit revision="\1"><date>\2</date></commit></entry></info>"/>
 | 
|---|
| 70 |     </target>
 | 
|---|
| 71 |     <!--
 | 
|---|
| 72 |       ** Creates the REVISION file to be included in the distribution
 | 
|---|
| 73 |     -->
 | 
|---|
| 74 |     <target name="create-revision" depends="init-svn-revision-xml, init-git-revision-xml">
 | 
|---|
| 75 |         <property name="revision.dir" value="${build.dir}"/>
 | 
|---|
| 76 |         <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
 | 
|---|
| 77 |         <delete file="REVISION.XML"/>
 | 
|---|
| 78 |         <tstamp>
 | 
|---|
| 79 |             <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
 | 
|---|
| 80 |         </tstamp>
 | 
|---|
| 81 |         <property name="version.entry.commit.revision" value="UNKNOWN"/>
 | 
|---|
| 82 |         <property name="version.entry.commit.date" value="UNKNOWN"/>
 | 
|---|
| 83 |         <mkdir dir="${revision.dir}"/>
 | 
|---|
| 84 |         <!-- add Build-Name: ... when making special builds, e.g. DEBIAN -->
 | 
|---|
| 85 |         <echo file="${revision.dir}/REVISION">
 | 
|---|
| 86 | # automatically generated by JOSM build.xml - do not edit
 | 
|---|
| 87 | Revision: ${version.entry.commit.revision}
 | 
|---|
| 88 | Is-Local-Build: true
 | 
|---|
| 89 | Build-Date: ${build.tstamp}
 | 
|---|
| 90 | </echo>
 | 
|---|
| 91 |     </target>
 | 
|---|
| 92 |     <!--
 | 
|---|
| 93 |       ** Check internal XML files against their XSD
 | 
|---|
| 94 |     -->
 | 
|---|
| 95 |     <target name="check-schemas" unless="check-schemas.notRequired">
 | 
|---|
| 96 |         <schemavalidate file="data/defaultpresets.xml" >
 | 
|---|
| 97 |             <schema namespace="http://josm.openstreetmap.de/tagging-preset-1.0" file="data/tagging-preset.xsd" />
 | 
|---|
| 98 |         </schemavalidate>
 | 
|---|
| 99 |     </target>
 | 
|---|
| 100 |     <!--
 | 
|---|
| 101 |       ** Main target that builds JOSM and checks XML against schemas
 | 
|---|
| 102 |     -->
 | 
|---|
| 103 |     <target name="dist" depends="compile,create-revision,check-schemas">
 | 
|---|
| 104 |         <echo>Revision ${version.entry.commit.revision}</echo>
 | 
|---|
| 105 |         <copy file="CONTRIBUTION" todir="build"/>
 | 
|---|
| 106 |         <copy file="README" todir="build"/>
 | 
|---|
| 107 |         <copy file="LICENSE" todir="build"/>
 | 
|---|
| 108 |         <!-- create josm-custom.jar -->
 | 
|---|
| 109 |         <delete file="dist/josm-custom.jar"/>
 | 
|---|
| 110 |         <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
 | 
|---|
| 111 |             <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
 | 
|---|
| 112 |             <manifest>
 | 
|---|
| 113 |                 <attribute name="Main-class" value="JOSM"/>
 | 
|---|
| 114 |                 <attribute name="Main-Version" value="${version.entry.commit.revision} SVN"/>
 | 
|---|
| 115 |                 <attribute name="Main-Date" value="${version.entry.commit.date}"/>
 | 
|---|
| 116 |                 <attribute name="Permissions" value="all-permissions"/>
 | 
|---|
| 117 |                 <attribute name="Codebase" value="josm.openstreetmap.de"/>
 | 
|---|
| 118 |                 <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
 | 
|---|
| 119 |             </manifest>
 | 
|---|
| 120 |             <zipfileset dir="images" prefix="images"/>
 | 
|---|
| 121 |             <zipfileset dir="data" prefix="data"/>
 | 
|---|
| 122 |             <zipfileset dir="styles" prefix="styles"/>
 | 
|---|
| 123 |             <zipfileset dir="${src.dir}/org/openstreetmap/gui/jmapviewer/images" prefix="org/openstreetmap/gui/jmapviewer/images"/>
 | 
|---|
| 124 |         </jar>
 | 
|---|
| 125 |     </target>
 | 
|---|
| 126 |     <!-- Mac OS X target -->
 | 
|---|
| 127 |     <target name="mac">
 | 
|---|
| 128 |         <!-- Using https://bitbucket.org/infinitekind/appbundler to create mac application bundle -->
 | 
|---|
| 129 |         <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="tools/appbundler-1.0ea.jar"/>
 | 
|---|
| 130 |         <!-- create MacOS X application bundle -->
 | 
|---|
| 131 |         <bundleapp outputdirectory="${bundle.outdir}" name="JOSM" displayname="JOSM" executablename="JOSM" identifier="org.openstreetmap.josm"
 | 
|---|
| 132 |                    mainclassname="org.openstreetmap.josm.gui.MainApplication"
 | 
|---|
| 133 |                    copyright="JOSM, and all its integral parts, are released under the GNU General Public License v2 or later"
 | 
|---|
| 134 |                    applicationCategory="public.app-category.utilities"
 | 
|---|
| 135 |                    shortversion="${version.entry.commit.revision} SVN"
 | 
|---|
| 136 |                    version="${version.entry.commit.revision} SVN"
 | 
|---|
| 137 |                    icon="macosx/JOSM.app/Contents/Resources/JOSM.icns"
 | 
|---|
| 138 |                    highResolutionCapable="true">
 | 
|---|
| 139 | 
 | 
|---|
| 140 |             <arch name="x86_64"/>
 | 
|---|
| 141 |             <arch name="i386"/>
 | 
|---|
| 142 | 
 | 
|---|
| 143 |             <classpath file="${bundle.jar}"/>
 | 
|---|
| 144 | 
 | 
|---|
| 145 |             <option value="-Xmx1024m"/>
 | 
|---|
| 146 | 
 | 
|---|
| 147 |             <option value="-Xdock:icon=Contents/Resources/JOSM.icns"/>
 | 
|---|
| 148 |             <option value="-Xdock:name=JOSM"/>
 | 
|---|
| 149 | 
 | 
|---|
| 150 |             <!-- OSX specific options, optional -->
 | 
|---|
| 151 |             <option value="-Dapple.laf.useScreenMenuBar=true"/>
 | 
|---|
| 152 |             <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
 | 
|---|
| 153 |             <option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
 | 
|---|
| 154 |             <option value="-Dcom.apple.mrj.application.apple.menu.about.name=JOSM"/>
 | 
|---|
| 155 |             <option value="-Dcom.apple.smallTabs=true"/>
 | 
|---|
| 156 |         </bundleapp>
 | 
|---|
| 157 |         
 | 
|---|
| 158 |         <!-- appbundler lacks the possibility of defining our own keys or using a template, so update the .plist manually -->
 | 
|---|
| 159 |         <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="tools/xmltask.jar"/>
 | 
|---|
| 160 |         
 | 
|---|
| 161 |         <xmltask source="${bundle.outdir}/JOSM.app/Contents/Info.plist" dest="${bundle.outdir}/JOSM.app/Contents/Info.plist" indent="false">
 | 
|---|
| 162 |             <!-- remove empty CFBundleDocumentTypes definition -->
 | 
|---|
| 163 |             <remove path="/plist/dict/key[text()='CFBundleDocumentTypes']|/plist/dict/key[text()='CFBundleDocumentTypes']/following-sibling::array[1]"/>
 | 
|---|
| 164 |             <!-- insert our own keys -->
 | 
|---|
| 165 |             <insert position="before" path="/plist/dict/key[1]" file="macosx/JOSM.app/Contents/Info.plist_template.xml" />
 | 
|---|
| 166 |         </xmltask>
 | 
|---|
| 167 |         
 | 
|---|
| 168 |         <!-- create ZIP file with MacOS X application bundle -->
 | 
|---|
| 169 |         <zip destfile="${bundle.outdir}/josm-custom-macosx.zip" update="true">
 | 
|---|
| 170 |             <zipfileset dir="." includes="CONTRIBUTION README LICENSE"/>
 | 
|---|
| 171 |             <zipfileset dir="${bundle.outdir}" includes="JOSM.app/**/*" filemode="755" />
 | 
|---|
| 172 |         </zip>
 | 
|---|
| 173 |     </target>
 | 
|---|
| 174 |     <target name="distmac" depends="dist">
 | 
|---|
| 175 |         <antcall target="mac">
 | 
|---|
| 176 |             <param name="bundle.outdir" value="dist"/>
 | 
|---|
| 177 |             <param name="bundle.jar" value="dist/josm-custom.jar"/>
 | 
|---|
| 178 |         </antcall>
 | 
|---|
| 179 |     </target>
 | 
|---|
| 180 |     <target name="javacc" depends="init" unless="javacc.notRequired">
 | 
|---|
| 181 |         <mkdir dir="${mapcss.dir}/parsergen"/>
 | 
|---|
| 182 |         <exec append="false" executable="java" failifexecutionfails="true">
 | 
|---|
| 183 |             <arg value="-cp"/>
 | 
|---|
| 184 |             <arg value="${javacc.home}/javacc.jar"/>
 | 
|---|
| 185 |             <arg value="javacc"/>
 | 
|---|
| 186 |             <arg value="-DEBUG_PARSER=false"/>
 | 
|---|
| 187 |             <arg value="-DEBUG_TOKEN_MANAGER=false"/>
 | 
|---|
| 188 |             <arg value="-JDK_VERSION=1.7"/>
 | 
|---|
| 189 |             <arg value="-GRAMMAR_ENCODING=UTF-8"/>
 | 
|---|
| 190 |             <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
 | 
|---|
| 191 |             <arg value="${mapcss.dir}/MapCSSParser.jj"/>
 | 
|---|
| 192 |         </exec>
 | 
|---|
| 193 |     </target>
 | 
|---|
| 194 |     <target name="-jaxb_win" if="isWindows">
 | 
|---|
| 195 |         <property name="xjc" value="${java.home}\..\bin\xjc.exe" />
 | 
|---|
| 196 |     </target>
 | 
|---|
| 197 |     <target name="-jaxb_nix" unless="isWindows">
 | 
|---|
| 198 |         <property name="xjc" value="${java.home}/../bin/xjc" />
 | 
|---|
| 199 |     </target>
 | 
|---|
| 200 |     <target name="jaxb" depends="init, -jaxb_win, -jaxb_nix" unless="jaxb.notRequired">
 | 
|---|
| 201 |         <exec executable="${xjc}" failonerror="true">
 | 
|---|
| 202 |             <arg value="-d"/>
 | 
|---|
| 203 |             <arg value="${src.dir}"/>
 | 
|---|
| 204 |             <arg value="-encoding"/>
 | 
|---|
| 205 |             <arg value="UTF-8"/>
 | 
|---|
| 206 |             <arg value="data_nodist/wms-cache.xsd"/>
 | 
|---|
| 207 |         </exec>
 | 
|---|
| 208 |     </target>
 | 
|---|
| 209 |     <target name="compile" depends="init,javacc,jaxb">
 | 
|---|
| 210 |         <!-- COTS -->
 | 
|---|
| 211 |         <javac srcdir="${src.dir}" includes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**" nowarn="on"
 | 
|---|
| 212 |             destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="iso-8859-1">
 | 
|---|
| 213 |             <!-- get rid of "internal proprietary API" warning -->
 | 
|---|
| 214 |             <compilerarg value="-XDignore.symbol.file"/>
 | 
|---|
| 215 |         </javac>
 | 
|---|
| 216 |         <!-- JMapViewer/JOSM -->
 | 
|---|
| 217 |         <javac srcdir="${src.dir}" excludes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java" 
 | 
|---|
| 218 |             destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
 | 
|---|
| 219 |             <compilerarg value="-Xlint:cast"/>
 | 
|---|
| 220 |             <compilerarg value="-Xlint:deprecation"/>
 | 
|---|
| 221 |             <compilerarg value="-Xlint:dep-ann"/>
 | 
|---|
| 222 |             <compilerarg value="-Xlint:divzero"/>
 | 
|---|
| 223 |             <compilerarg value="-Xlint:empty"/>
 | 
|---|
| 224 |             <compilerarg value="-Xlint:finally"/>
 | 
|---|
| 225 |             <compilerarg value="-Xlint:overrides"/>
 | 
|---|
| 226 |             <!--<compilerarg value="-Xlint:rawtypes"/>-->
 | 
|---|
| 227 |             <compilerarg value="-Xlint:static"/>
 | 
|---|
| 228 |             <compilerarg value="-Xlint:try"/>
 | 
|---|
| 229 |             <compilerarg value="-Xlint:unchecked"/>
 | 
|---|
| 230 |             <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
 | 
|---|
| 231 |             <compilerarg value="-XDignore.symbol.file"/>
 | 
|---|
| 232 |         </javac>
 | 
|---|
| 233 |         <copy todir="build" failonerror="no" includeemptydirs="no">
 | 
|---|
| 234 |             <fileset dir="resources"/>
 | 
|---|
| 235 |         </copy>
 | 
|---|
| 236 |     </target>
 | 
|---|
| 237 |     <target name="init">
 | 
|---|
| 238 |         <uptodate property="javacc.notRequired" targetfile="${mapcss.dir}/parsergen/MapCSSParser.java" >
 | 
|---|
| 239 |             <srcfiles dir="${mapcss.dir}" includes="MapCSSParser.jj"/>
 | 
|---|
| 240 |         </uptodate>
 | 
|---|
| 241 |         <uptodate property="jaxb.notRequired" targetfile="${src.dir}/org/openstreetmap/josm/data/imagery/types/package-info.java" >
 | 
|---|
| 242 |             <srcfiles dir="data_nodist" includes="wms-cache.xsd"/>
 | 
|---|
| 243 |         </uptodate>
 | 
|---|
| 244 |         <mkdir dir="build"/>
 | 
|---|
| 245 |         <mkdir dir="dist"/>
 | 
|---|
| 246 |     </target>
 | 
|---|
| 247 |     <target name="javadoc">
 | 
|---|
| 248 |         <javadoc destdir="javadoc" 
 | 
|---|
| 249 |                 sourcepath="${src.dir}"
 | 
|---|
| 250 |                 encoding="UTF-8"    
 | 
|---|
| 251 |                 packagenames="org.openstreetmap.josm.*,org.openstreetmap.gui.jmapviewer.*"
 | 
|---|
| 252 |                 windowtitle="JOSM"
 | 
|---|
| 253 |                 use="true"
 | 
|---|
| 254 |                 private="true"
 | 
|---|
| 255 |                 linksource="true"
 | 
|---|
| 256 |                 author="false">
 | 
|---|
| 257 |             <link href="http://docs.oracle.com/javase/7/docs/api"/>
 | 
|---|
| 258 |             <doctitle><![CDATA[<h2>JOSM - Javadoc</h2>]]></doctitle>
 | 
|---|
| 259 |             <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JOSM</a>]]></bottom>
 | 
|---|
| 260 |         </javadoc>
 | 
|---|
| 261 |     </target>
 | 
|---|
| 262 |     <target name="clean">
 | 
|---|
| 263 |         <delete dir="build"/>
 | 
|---|
| 264 |         <delete dir="dist"/>
 | 
|---|
| 265 |         <delete dir="${mapcss.dir}/parsergen"/>
 | 
|---|
| 266 |         <delete dir="${imagerytypes.dir}"/>
 | 
|---|
| 267 |     </target>
 | 
|---|
| 268 |     <path id="test.classpath">
 | 
|---|
| 269 |         <fileset dir="${test.dir}/lib">
 | 
|---|
| 270 |             <include name="**/*.jar"/>
 | 
|---|
| 271 |         </fileset>
 | 
|---|
| 272 |         <pathelement path="dist/josm-custom.jar"/>
 | 
|---|
| 273 |         <pathelement path="tools/groovy-all-2.3.6.jar"/>
 | 
|---|
| 274 |     </path>
 | 
|---|
| 275 |     <macrodef name="init-test-preferences">
 | 
|---|
| 276 |         <attribute name="testfamily"/>
 | 
|---|
| 277 |         <sequential>
 | 
|---|
| 278 |             <copy file="${test.dir}/config/preferences.template.xml" tofile="${test.dir}/config/@{testfamily}-josm.home/preferences.xml"/>
 | 
|---|
| 279 |             <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
 | 
|---|
| 280 |             <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
 | 
|---|
| 281 |         </sequential>
 | 
|---|
| 282 |     </macrodef>
 | 
|---|
| 283 |     <target name="test-init">
 | 
|---|
| 284 |         <mkdir dir="${test.dir}/build"/>
 | 
|---|
| 285 |         <mkdir dir="${test.dir}/build/unit"/>
 | 
|---|
| 286 |         <mkdir dir="${test.dir}/build/functional"/>
 | 
|---|
| 287 |         <mkdir dir="${test.dir}/build/performance"/>
 | 
|---|
| 288 |         <mkdir dir="${test.dir}/report"/>
 | 
|---|
| 289 |         <init-test-preferences testfamily="unit"/>
 | 
|---|
| 290 |         <init-test-preferences testfamily="functional"/>
 | 
|---|
| 291 |         <init-test-preferences testfamily="performance"/>
 | 
|---|
| 292 |     </target>
 | 
|---|
| 293 |     <target name="test-clean">
 | 
|---|
| 294 |         <delete dir="${test.dir}/build"/>
 | 
|---|
| 295 |         <delete dir="${test.dir}/report"/>
 | 
|---|
| 296 |         <delete file="${test.dir}/jacoco.exec" />
 | 
|---|
| 297 |         <delete file="${test.dir}/config/unit-josm.home/preferences.xml" />
 | 
|---|
| 298 |         <delete file="${test.dir}/config/functional-josm.home/preferences.xml" />
 | 
|---|
| 299 |         <delete file="${test.dir}/config/performance-josm.home/preferences.xml" />
 | 
|---|
| 300 |         <delete dir="${test.dir}/config/unit-josm.home/cache" failonerror="false"/>
 | 
|---|
| 301 |         <delete dir="${test.dir}/config/functional-josm.home/cache" failonerror="false"/>
 | 
|---|
| 302 |         <delete dir="${test.dir}/config/performance-josm.home/cache" failonerror="false"/>
 | 
|---|
| 303 |     </target>
 | 
|---|
| 304 |     <macrodef name="call-groovyc">
 | 
|---|
| 305 |         <attribute name="testfamily"/>
 | 
|---|
| 306 |         <element name="cp-elements"/>
 | 
|---|
| 307 |         <sequential>
 | 
|---|
| 308 |             <groovyc srcdir="${test.dir}/@{testfamily}" destdir="${test.dir}/build/@{testfamily}" encoding="UTF-8">
 | 
|---|
| 309 |                 <classpath>
 | 
|---|
| 310 |                     <cp-elements/>
 | 
|---|
| 311 |                 </classpath>
 | 
|---|
| 312 |                 <javac target="1.7" source="1.7" debug="on" encoding="UTF-8">
 | 
|---|
| 313 |                     <compilerarg value="-Xlint:all"/>
 | 
|---|
| 314 |                     <compilerarg value="-Xlint:-serial"/>
 | 
|---|
| 315 |                 </javac>
 | 
|---|
| 316 |             </groovyc>
 | 
|---|
| 317 |         </sequential>
 | 
|---|
| 318 |     </macrodef>
 | 
|---|
| 319 |     <target name="test-compile" depends="test-init,dist">
 | 
|---|
| 320 |         <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="tools/groovy-all-2.3.6.jar"/>
 | 
|---|
| 321 |         <call-groovyc testfamily="unit">
 | 
|---|
| 322 |             <cp-elements>
 | 
|---|
| 323 |                 <path refid="test.classpath"/>
 | 
|---|
| 324 |             </cp-elements>
 | 
|---|
| 325 |         </call-groovyc>
 | 
|---|
| 326 |         <call-groovyc testfamily="functional">
 | 
|---|
| 327 |             <cp-elements>
 | 
|---|
| 328 |                 <path refid="test.classpath"/>
 | 
|---|
| 329 |                 <pathelement path="${test.dir}/build/unit"/>
 | 
|---|
| 330 |             </cp-elements>
 | 
|---|
| 331 |         </call-groovyc>
 | 
|---|
| 332 |         <call-groovyc testfamily="performance">
 | 
|---|
| 333 |             <cp-elements>
 | 
|---|
| 334 |                 <path refid="test.classpath"/>
 | 
|---|
| 335 |                 <pathelement path="${test.dir}/build/unit"/>
 | 
|---|
| 336 |             </cp-elements>
 | 
|---|
| 337 |         </call-groovyc>
 | 
|---|
| 338 |     </target>
 | 
|---|
| 339 |     <macrodef name="call-junit">
 | 
|---|
| 340 |         <attribute name="testfamily"/>
 | 
|---|
| 341 |         <sequential>
 | 
|---|
| 342 |             <echo message="Running @{testfamily} tests with JUnit"/>
 | 
|---|
| 343 |             <jacoco:coverage destfile="${test.dir}/jacoco.exec">
 | 
|---|
| 344 |                 <junit printsummary="yes" fork="true" forkmode="once">
 | 
|---|
| 345 |                     <jvmarg value="-Dfile.encoding=UTF-8"/>
 | 
|---|
| 346 |                     <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
 | 
|---|
| 347 |                     <sysproperty key="josm.test.data" value="${test.dir}/data"/>
 | 
|---|
| 348 |                     <sysproperty key="java.awt.headless" value="true"/>
 | 
|---|
| 349 |                     <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
 | 
|---|
| 350 |                     <classpath>
 | 
|---|
| 351 |                         <path refid="test.classpath"/>
 | 
|---|
| 352 |                         <pathelement path="${test.dir}/build/unit"/>
 | 
|---|
| 353 |                         <pathelement path="${test.dir}/build/@{testfamily}"/>
 | 
|---|
| 354 |                         <pathelement path="${test.dir}/config"/>
 | 
|---|
| 355 |                     </classpath>
 | 
|---|
| 356 |                     <formatter type="plain"/>
 | 
|---|
| 357 |                     <formatter type="xml"/>
 | 
|---|
| 358 |                     <batchtest fork="yes" todir="${test.dir}/report">
 | 
|---|
| 359 |                         <fileset dir="${test.dir}/build/@{testfamily}" includes="**/*Test.class"/>
 | 
|---|
| 360 |                     </batchtest>
 | 
|---|
| 361 |                 </junit>
 | 
|---|
| 362 |             </jacoco:coverage>
 | 
|---|
| 363 |         </sequential>
 | 
|---|
| 364 |     </macrodef>
 | 
|---|
| 365 |     <target name="test" depends="test-compile" 
 | 
|---|
| 366 |         description="Run unit, functional and performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
 | 
|---|
| 367 |         <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" />
 | 
|---|
| 368 |         <call-junit testfamily="unit"/>
 | 
|---|
| 369 |         <call-junit testfamily="functional"/>
 | 
|---|
| 370 |         <call-junit testfamily="performance"/>
 | 
|---|
| 371 |     </target>
 | 
|---|
| 372 |     <target name="test-html" depends="test" description="Generate HTML test reports">
 | 
|---|
| 373 |         <!-- May require additional ant dependencies like ant-trax package -->
 | 
|---|
| 374 |         <junitreport todir="${test.dir}/report">
 | 
|---|
| 375 |             <fileset dir="${test.dir}/report">
 | 
|---|
| 376 |                 <include name="TEST-*.xml"/>
 | 
|---|
| 377 |             </fileset>
 | 
|---|
| 378 |             <report todir="${test.dir}/report/html"/>
 | 
|---|
| 379 |         </junitreport>
 | 
|---|
| 380 |         <jacoco:report>
 | 
|---|
| 381 |             <executiondata>
 | 
|---|
| 382 |                 <file file="${test.dir}/jacoco.exec"/>
 | 
|---|
| 383 |             </executiondata>
 | 
|---|
| 384 |             <structure name="JOSM Test Coverage">
 | 
|---|
| 385 |                 <classfiles>
 | 
|---|
| 386 |                     <fileset dir="${build.dir}" includes="org/openstreetmap/"/>
 | 
|---|
| 387 |                 </classfiles>
 | 
|---|
| 388 |                 <sourcefiles encoding="UTF-8">
 | 
|---|
| 389 |                     <fileset dir="${src.dir}" includes="org/openstreetmap/"/>
 | 
|---|
| 390 |                 </sourcefiles>
 | 
|---|
| 391 |             </structure>
 | 
|---|
| 392 |             <html destdir="${test.dir}/report/jacoco"/>
 | 
|---|
| 393 |         </jacoco:report>
 | 
|---|
| 394 |     </target>
 | 
|---|
| 395 |     <target name="dist-optimized" depends="dist">
 | 
|---|
| 396 |         <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard.jar"/>
 | 
|---|
| 397 |         <proguard>
 | 
|---|
| 398 |         -injars dist/josm-custom.jar
 | 
|---|
| 399 |         -outjars dist/josm-custom-optimized.jar
 | 
|---|
| 400 | 
 | 
|---|
| 401 |         -libraryjars ${java.home}/lib/rt.jar
 | 
|---|
| 402 |         -libraryjars ${java.home}/lib/jce.jar
 | 
|---|
| 403 | 
 | 
|---|
| 404 |         -dontoptimize
 | 
|---|
| 405 |         -dontobfuscate
 | 
|---|
| 406 | 
 | 
|---|
| 407 |         # These options probably are not necessary (and make processing a bit slower)
 | 
|---|
| 408 |         -dontskipnonpubliclibraryclasses
 | 
|---|
| 409 |         -dontskipnonpubliclibraryclassmembers
 | 
|---|
| 410 | 
 | 
|---|
| 411 |         -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplication {
 | 
|---|
| 412 |             public static void main(java.lang.String[]);
 | 
|---|
| 413 |         }
 | 
|---|
| 414 |         -keepclasseswithmembers public class org.openstreetmap.josm.gui.MainApplet
 | 
|---|
| 415 | 
 | 
|---|
| 416 |         -keep class JOSM
 | 
|---|
| 417 |         -keep class * extends org.openstreetmap.josm.io.FileImporter
 | 
|---|
| 418 |         -keep class * extends org.openstreetmap.josm.io.FileExporter
 | 
|---|
| 419 |         -keep class org.w3._2001.xmlschema.Adapter1
 | 
|---|
| 420 |         -keep class org.openstreetmap.josm.actions.search.SearchCompiler$Never
 | 
|---|
| 421 | 
 | 
|---|
| 422 |         -keepclassmembers enum  * {
 | 
|---|
| 423 |             public static **[] values();
 | 
|---|
| 424 |             public static ** valueOf(java.lang.String);
 | 
|---|
| 425 |         }
 | 
|---|
| 426 | 
 | 
|---|
| 427 |         # Keep unused public methods (can be useful for plugins)
 | 
|---|
| 428 |         -keepclassmembers class * {
 | 
|---|
| 429 |             public protected *;
 | 
|---|
| 430 |         }
 | 
|---|
| 431 | 
 | 
|---|
| 432 |         # Disable annoying [proguard] Note: the configuration keeps the entry point '...', but not the descriptor class '...'.
 | 
|---|
| 433 |         # This note should not be a problem as we don't use obfuscation
 | 
|---|
| 434 |         -dontnote
 | 
|---|
| 435 |         </proguard>
 | 
|---|
| 436 |     </target>
 | 
|---|
| 437 |     <target name="check-plugins" depends="dist-optimized">
 | 
|---|
| 438 |         <echo message="Check of plugins binary compatibility (needs ant 1.8)"/>
 | 
|---|
| 439 |         <local name="dir"/>
 | 
|---|
| 440 |         <local name="plugins"/>
 | 
|---|
| 441 |         <property name="dir" value="plugin-check"/>
 | 
|---|
| 442 |         <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
 | 
|---|
| 443 |             <classpath path="tools/animal-sniffer-ant-tasks-1.11.jar"/>
 | 
|---|
| 444 |         </typedef>
 | 
|---|
| 445 |         <mkdir dir="${dir}"/>
 | 
|---|
| 446 |         <!-- List of deprecated plugins -->
 | 
|---|
| 447 |         <loadfile property="deprecated-plugins" srcFile="${src.dir}/org/openstreetmap/josm/plugins/PluginHandler.java">
 | 
|---|
| 448 |             <filterchain>
 | 
|---|
| 449 |                 <linecontains>
 | 
|---|
| 450 |                     <contains value="new DeprecatedPlugin("/>
 | 
|---|
| 451 |                 </linecontains>
 | 
|---|
| 452 |                 <tokenfilter>
 | 
|---|
| 453 |                     <replaceregex pattern=".*new DeprecatedPlugin\("(.+?)".*" replace="\1|" flags="gi"/>
 | 
|---|
| 454 |                 </tokenfilter>
 | 
|---|
| 455 |                 <striplinebreaks/>
 | 
|---|
| 456 |                 <tokenfilter>
 | 
|---|
| 457 |                     <replaceregex pattern="\|$" replace="" flags="gi"/>
 | 
|---|
| 458 |                 </tokenfilter>
 | 
|---|
| 459 |             </filterchain>
 | 
|---|
| 460 |         </loadfile>
 | 
|---|
| 461 |         <!-- Download list of plugins -->
 | 
|---|
| 462 |         <loadresource property="plugins">
 | 
|---|
| 463 |             <url url="https://josm.openstreetmap.de/plugin"/>
 | 
|---|
| 464 |             <filterchain>
 | 
|---|
| 465 |                 <linecontainsregexp negate="true">
 | 
|---|
| 466 |                     <regexp pattern="^\t.*"/>
 | 
|---|
| 467 |                 </linecontainsregexp>
 | 
|---|
| 468 |                 <linecontainsregexp negate="true">
 | 
|---|
| 469 |                     <regexp pattern="${deprecated-plugins}"/>
 | 
|---|
| 470 |                 </linecontainsregexp>
 | 
|---|
| 471 |                 <tokenfilter>
 | 
|---|
| 472 |                     <replaceregex pattern="^.*;" replace="" flags="gi"/>
 | 
|---|
| 473 |                 </tokenfilter>
 | 
|---|
| 474 |             </filterchain>
 | 
|---|
| 475 |         </loadresource>
 | 
|---|
| 476 |         <!-- Delete files that are not in plugin list (like old plugins) -->
 | 
|---|
| 477 |         <loadresource property="file-list">
 | 
|---|
| 478 |             <propertyresource name="plugins"/>
 | 
|---|
| 479 |             <filterchain>
 | 
|---|
| 480 |                 <tokenfilter>
 | 
|---|
| 481 |                     <replaceregex pattern="^.*/(.*)$" replace="\1\|" flags=""/>
 | 
|---|
| 482 |                 </tokenfilter>
 | 
|---|
| 483 |                 <striplinebreaks/>
 | 
|---|
| 484 |                 <tokenfilter>
 | 
|---|
| 485 |                     <replaceregex pattern="\|$" replace="" flags="gi"/>
 | 
|---|
| 486 |                 </tokenfilter>    
 | 
|---|
| 487 |             </filterchain>
 | 
|---|
| 488 |         </loadresource>
 | 
|---|
| 489 |         <delete>
 | 
|---|
| 490 |             <restrict>
 | 
|---|
| 491 |                 <fileset dir="${dir}"/>
 | 
|---|
| 492 |                 <not>
 | 
|---|
| 493 |                     <name regex="${file-list}"/>
 | 
|---|
| 494 |                 </not>
 | 
|---|
| 495 |             </restrict>
 | 
|---|
| 496 |         </delete>
 | 
|---|
| 497 |         <!-- Download plugins -->
 | 
|---|
| 498 |         <copy todir="${dir}" flatten="true">
 | 
|---|
| 499 |             <resourcelist>
 | 
|---|
| 500 |                 <string value="${plugins}"/>
 | 
|---|
| 501 |             </resourcelist>
 | 
|---|
| 502 |         </copy>
 | 
|---|
| 503 |         <!-- Check plugins -->
 | 
|---|
| 504 |         <as:build-signatures destfile="${dir}/api.sig">
 | 
|---|
| 505 |             <path>
 | 
|---|
| 506 |                 <fileset file="dist/josm-custom-optimized.jar"/>
 | 
|---|
| 507 |                 <fileset file="${java.home}/lib/rt.jar"/>
 | 
|---|
| 508 |                 <fileset file="${java.home}/lib/jce.jar"/>
 | 
|---|
| 509 |             </path>
 | 
|---|
| 510 |         </as:build-signatures>
 | 
|---|
| 511 |         <as:check-signature signature="${dir}/api.sig">
 | 
|---|
| 512 |             <ignore classname="au.edu.*"/>
 | 
|---|
| 513 |             <ignore classname="au.com.*"/>
 | 
|---|
| 514 |             <ignore classname="com.*"/>
 | 
|---|
| 515 |             <ignore classname="javax.*"/>
 | 
|---|
| 516 |             <ignore classname="jogamp.*"/>
 | 
|---|
| 517 |             <ignore classname="junit.*"/>
 | 
|---|
| 518 |             <ignore classname="net.sf.*"/>
 | 
|---|
| 519 |             <ignore classname="nu.xom.*"/>
 | 
|---|
| 520 |             <ignore classname="org.apache.*"/>
 | 
|---|
| 521 |             <ignore classname="org.codehaus.*"/>
 | 
|---|
| 522 |             <ignore classname="org.dom4j.*"/>
 | 
|---|
| 523 |             <ignore classname="org.hsqldb.*"/>
 | 
|---|
| 524 |             <ignore classname="org.ibex.*"/>
 | 
|---|
| 525 |             <ignore classname="org.jaitools.*"/>
 | 
|---|
| 526 |             <ignore classname="org.jaxen.*"/>
 | 
|---|
| 527 |             <ignore classname="org.jdom2.*"/>
 | 
|---|
| 528 |             <ignore classname="org.jgraph.*"/>
 | 
|---|
| 529 |             <ignore classname="org.joda.time.*"/>
 | 
|---|
| 530 |             <ignore classname="org.jvnet.staxex.*"/>
 | 
|---|
| 531 |             <ignore classname="org.kxml2.*"/>
 | 
|---|
| 532 |             <ignore classname="org.python.*"/>
 | 
|---|
| 533 |             <ignore classname="org.slf4j.*"/>
 | 
|---|
| 534 |                 <!-- plugins used by another ones -->
 | 
|---|
| 535 |             <ignore classname="org.openstreetmap.josm.plugins.geotools.*"/>
 | 
|---|
| 536 |             <ignore classname="org.openstreetmap.josm.plugins.jts.*"/>
 | 
|---|
| 537 |             <ignore classname="org.openstreetmap.josm.plugins.log4j.*"/>
 | 
|---|
| 538 |             <ignore classname="org.openstreetmap.josm.plugins.utilsplugin2.*"/>
 | 
|---|
| 539 |             <path path="${dir}"/>
 | 
|---|
| 540 |         </as:check-signature>
 | 
|---|
| 541 |     </target>
 | 
|---|
| 542 | 
 | 
|---|
| 543 |     <target name="findbugs" depends="dist">
 | 
|---|
| 544 |         <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="tools/findbugs/findbugs-ant.jar"/>
 | 
|---|
| 545 |         <path id="findbugs-classpath">
 | 
|---|
| 546 |             <fileset dir="tools/findbugs/">
 | 
|---|
| 547 |                 <include name="*.jar"/>
 | 
|---|
| 548 |             </fileset>
 | 
|---|
| 549 |         </path>
 | 
|---|
| 550 |         <property name="findbugs-classpath" refid="findbugs-classpath"/>
 | 
|---|
| 551 |         <findbugs output="xml"
 | 
|---|
| 552 |                 outputFile="findbugs-josm.xml"
 | 
|---|
| 553 |                 classpath="${findbugs-classpath}"
 | 
|---|
| 554 |                 pluginList=""
 | 
|---|
| 555 |                 excludeFilter="tools/findbugs/josm-filter.xml"
 | 
|---|
| 556 |                 effort="max"
 | 
|---|
| 557 |                 >
 | 
|---|
| 558 |             <sourcePath path="${basedir}/src" />
 | 
|---|
| 559 |             <class location="${basedir}/dist/josm-custom.jar" />
 | 
|---|
| 560 |         </findbugs>
 | 
|---|
| 561 |     </target>
 | 
|---|
| 562 |     <target name="run" depends="dist">
 | 
|---|
| 563 |         <java jar="dist/josm-custom.jar" fork="true">
 | 
|---|
| 564 |             <arg value="--set=expert=true"/>
 | 
|---|
| 565 |             <arg value="--set=remotecontrol.enabled=true"/>
 | 
|---|
| 566 |             <arg value="--set=debug.edt-checker.enable=false"/>
 | 
|---|
| 567 |             <jvmarg value="-Djosm.home=/tmp/.josm/"/>
 | 
|---|
| 568 |         </java>
 | 
|---|
| 569 |     </target>
 | 
|---|
| 570 | 
 | 
|---|
| 571 | </project>
 | 
|---|