| 1 | <?xml version="1.0" encoding="utf-8"?>
|
|---|
| 2 | <!--
|
|---|
| 3 | ** Template for the build targets common to all plugins
|
|---|
| 4 | ** ====================================================
|
|---|
| 5 | **
|
|---|
| 6 | ** To override a property, add it to the plugin build.xml _before_
|
|---|
| 7 | ** this template has been imported.
|
|---|
| 8 | ** To override a target, add it _after_ this template has been imported.
|
|---|
| 9 | **
|
|---|
| 10 | ** Paths are relative to the build.xml that imports this template.
|
|---|
| 11 | **
|
|---|
| 12 | -->
|
|---|
| 13 | <project name="plugin_common" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
|
|---|
| 14 |
|
|---|
| 15 | <property name="josm" location="../../core/dist/josm-custom.jar"/>
|
|---|
| 16 | <property name="josm.test.build.dir" location="../../core/test/build"/>
|
|---|
| 17 | <property name="groovy.jar" location="../00_core_tools/groovy-all-2.4.6.jar"/>
|
|---|
| 18 | <property name="checkstyle.jar" location="../00_core_tools/checkstyle/checkstyle-6.19-all.jar"/>
|
|---|
| 19 | <property name="findbugs-ant.jar" location="../00_core_tools/findbugs/findbugs-ant.jar"/>
|
|---|
| 20 | <property name="annotations.jar" location="../00_core_tools/findbugs/annotations.jar"/>
|
|---|
| 21 | <property name="plugin.build.dir" location="build"/>
|
|---|
| 22 | <property name="plugin.test.dir" location="test"/>
|
|---|
| 23 | <property name="plugin.src.dir" location="src"/>
|
|---|
| 24 | <property name="plugin.lib.dir" location="lib"/>
|
|---|
| 25 | <!-- this is the directory where the plugin jar is copied to -->
|
|---|
| 26 | <property name="plugin.dist.dir" location="../../dist"/>
|
|---|
| 27 | <property name="ant.build.javac.target" value="1.7"/>
|
|---|
| 28 | <property name="ant.build.javac.source" value="1.7"/>
|
|---|
| 29 | <property name="plugin.jar" location="${plugin.dist.dir}/${ant.project.name}.jar"/>
|
|---|
| 30 |
|
|---|
| 31 | <!-- For Windows-specific stuff -->
|
|---|
| 32 | <condition property="isWindows">
|
|---|
| 33 | <os family="Windows"/>
|
|---|
| 34 | </condition>
|
|---|
| 35 | <target name="-jaxb_win" if="isWindows">
|
|---|
| 36 | <property name="xjc" value="${java.home}\..\bin\xjc.exe" />
|
|---|
| 37 | </target>
|
|---|
| 38 | <target name="-jaxb_nix" unless="isWindows">
|
|---|
| 39 | <property name="xjc" value="${java.home}/../bin/xjc" />
|
|---|
| 40 | </target>
|
|---|
| 41 |
|
|---|
| 42 | <!-- To be overriden in plugin build file before inclusion if other plugins are required -->
|
|---|
| 43 | <fileset id="plugin.requires.jars" dir="${plugin.dist.dir}" includes="nothing"/>
|
|---|
| 44 |
|
|---|
| 45 | <!--
|
|---|
| 46 | **********************************************************
|
|---|
| 47 | ** init - initializes the build
|
|---|
| 48 | **********************************************************
|
|---|
| 49 | -->
|
|---|
| 50 | <target name="init">
|
|---|
| 51 | <mkdir dir="${plugin.build.dir}"/>
|
|---|
| 52 | </target>
|
|---|
| 53 | <!--
|
|---|
| 54 | **********************************************************
|
|---|
| 55 | ** compile - compiles the source tree
|
|---|
| 56 | **********************************************************
|
|---|
| 57 | -->
|
|---|
| 58 | <target name="compile" depends="init">
|
|---|
| 59 | <echo message="compiling sources for ${plugin.jar} ..."/>
|
|---|
| 60 | <javac srcdir="src" debug="true" destdir="${plugin.build.dir}" includeantruntime="false" encoding="UTF-8">
|
|---|
| 61 | <compilerarg value="-Xlint:deprecation"/>
|
|---|
| 62 | <compilerarg value="-Xlint:unchecked"/>
|
|---|
| 63 | <classpath>
|
|---|
| 64 | <pathelement location="${josm}"/>
|
|---|
| 65 | <fileset dir="${plugin.lib.dir}" erroronmissingdir="no">
|
|---|
| 66 | <include name="**/*.jar"/>
|
|---|
| 67 | <exclude name="**/*-sources.jar"/>
|
|---|
| 68 | <exclude name="**/*-javadoc.jar"/>
|
|---|
| 69 | </fileset>
|
|---|
| 70 | <fileset refid="plugin.requires.jars"/>
|
|---|
| 71 | </classpath>
|
|---|
| 72 | </javac>
|
|---|
| 73 | </target>
|
|---|
| 74 | <!--
|
|---|
| 75 | **********************************************************
|
|---|
| 76 | ** setup-dist - copies files for distribution
|
|---|
| 77 | **********************************************************
|
|---|
| 78 | -->
|
|---|
| 79 | <target name="setup-dist-default">
|
|---|
| 80 | <copy todir="${plugin.build.dir}/resources" failonerror="no" includeemptydirs="no">
|
|---|
| 81 | <fileset dir="resources"/>
|
|---|
| 82 | </copy>
|
|---|
| 83 | <copy todir="${plugin.build.dir}/images" failonerror="no" includeemptydirs="no">
|
|---|
| 84 | <fileset dir="images"/>
|
|---|
| 85 | </copy>
|
|---|
| 86 | <copy todir="${plugin.build.dir}/data" failonerror="no" includeemptydirs="no">
|
|---|
| 87 | <fileset dir="data"/>
|
|---|
| 88 | </copy>
|
|---|
| 89 | <copy todir="${plugin.build.dir}">
|
|---|
| 90 | <fileset dir=".">
|
|---|
| 91 | <include name="README"/>
|
|---|
| 92 | <include name="LICENSE*"/>
|
|---|
| 93 | <include name="*GPL*"/>
|
|---|
| 94 | </fileset>
|
|---|
| 95 | </copy>
|
|---|
| 96 | </target>
|
|---|
| 97 | <target name="setup-dist">
|
|---|
| 98 | <antcall target="setup-dist-default" />
|
|---|
| 99 | </target>
|
|---|
| 100 | <!--
|
|---|
| 101 | **********************************************************
|
|---|
| 102 | ** dist - creates the plugin jar
|
|---|
| 103 | **********************************************************
|
|---|
| 104 | -->
|
|---|
| 105 | <target name="dist" depends="compile,revision">
|
|---|
| 106 | <echo message="creating ${ant.project.name}.jar ... "/>
|
|---|
| 107 | <antcall target="setup-dist" />
|
|---|
| 108 | <delete file="MANIFEST" failonerror="no"/>
|
|---|
| 109 | <manifest file="MANIFEST" mode="update">
|
|---|
| 110 | <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
|
|---|
| 111 | <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
|
|---|
| 112 | <attribute name="Plugin-Class" value="${plugin.class}" />
|
|---|
| 113 | <attribute name="Plugin-Description" value="${plugin.description}" />
|
|---|
| 114 | <attribute name="Plugin-Date" value="${version.entry.commit.date}" />
|
|---|
| 115 | <attribute name="Author" value="${plugin.author}"/>
|
|---|
| 116 | </manifest>
|
|---|
| 117 | <antcall target="add-manifest-attribute">
|
|---|
| 118 | <param name="manifest.attribute" value="Plugin-Link"/>
|
|---|
| 119 | <param name="property.name" value="plugin.link"/>
|
|---|
| 120 | <param name="property.value" value="${plugin.link}"/>
|
|---|
| 121 | </antcall>
|
|---|
| 122 | <antcall target="add-manifest-attribute">
|
|---|
| 123 | <param name="manifest.attribute" value="Plugin-Icon"/>
|
|---|
| 124 | <param name="property.name" value="plugin.icon"/>
|
|---|
| 125 | <param name="property.value" value="${plugin.icon}"/>
|
|---|
| 126 | </antcall>
|
|---|
| 127 | <antcall target="add-manifest-attribute">
|
|---|
| 128 | <param name="manifest.attribute" value="Plugin-Early"/>
|
|---|
| 129 | <param name="property.name" value="plugin.early"/>
|
|---|
| 130 | <param name="property.value" value="${plugin.early}"/>
|
|---|
| 131 | </antcall>
|
|---|
| 132 | <antcall target="add-manifest-attribute">
|
|---|
| 133 | <param name="manifest.attribute" value="Plugin-Requires"/>
|
|---|
| 134 | <param name="property.name" value="plugin.requires"/>
|
|---|
| 135 | <param name="property.value" value="${plugin.requires}"/>
|
|---|
| 136 | </antcall>
|
|---|
| 137 | <antcall target="add-manifest-attribute">
|
|---|
| 138 | <param name="manifest.attribute" value="Plugin-Stage"/>
|
|---|
| 139 | <param name="property.name" value="plugin.stage"/>
|
|---|
| 140 | <param name="property.value" value="${plugin.stage}"/>
|
|---|
| 141 | </antcall>
|
|---|
| 142 | <antcall target="add-manifest-attribute">
|
|---|
| 143 | <param name="manifest.attribute" value="Plugin-Canloadatruntime"/>
|
|---|
| 144 | <param name="property.name" value="plugin.canloadatruntime"/>
|
|---|
| 145 | <param name="property.value" value="${plugin.canloadatruntime}"/>
|
|---|
| 146 | </antcall>
|
|---|
| 147 | <antcall target="additional-manifest" />
|
|---|
| 148 | <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="MANIFEST" manifestencoding="UTF-8">
|
|---|
| 149 | <restrict>
|
|---|
| 150 | <not><or>
|
|---|
| 151 | <name name="META-INF/maven/*"/>
|
|---|
| 152 | <name name="META-INF/DEPENDENCIES"/>
|
|---|
| 153 | <name name="META-INF/LICENSE"/>
|
|---|
| 154 | <name name="META-INF/NOTICE"/>
|
|---|
| 155 | <name name="META-INF/*.RSA"/>
|
|---|
| 156 | <name name="META-INF/*.SF"/>
|
|---|
| 157 | </or></not>
|
|---|
| 158 | <archives>
|
|---|
| 159 | <zips>
|
|---|
| 160 | <fileset dir="${plugin.lib.dir}" includes="*.jar" excludes="*-sources.jar, *-javadoc.jar" erroronmissingdir="no"/>
|
|---|
| 161 | </zips>
|
|---|
| 162 | </archives>
|
|---|
| 163 | </restrict>
|
|---|
| 164 | </jar>
|
|---|
| 165 | <delete file="MANIFEST" failonerror="no"/>
|
|---|
| 166 | <antcall target="post-dist" />
|
|---|
| 167 | </target>
|
|---|
| 168 | <target name="post-dist">
|
|---|
| 169 | <!-- to be overidden by plugins that need to perform additional tasks on resulting jar -->
|
|---|
| 170 | </target>
|
|---|
| 171 | <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${property.name}">
|
|---|
| 172 | <manifest file="MANIFEST" mode="update">
|
|---|
| 173 | <attribute name="${manifest.attribute}" value="${property.value}" />
|
|---|
| 174 | </manifest>
|
|---|
| 175 | </target>
|
|---|
| 176 | <!-- target to add additional entries, empty in commons -->
|
|---|
| 177 | <target name="additional-manifest">
|
|---|
| 178 | </target>
|
|---|
| 179 | <target name="check-manifest-attribute">
|
|---|
| 180 | <condition property="have-${property.name}">
|
|---|
| 181 | <and>
|
|---|
| 182 | <isset property="${property.name}"/>
|
|---|
| 183 | <not>
|
|---|
| 184 | <equals arg1="${property.value}" arg2=""/>
|
|---|
| 185 | </not>
|
|---|
| 186 | <not>
|
|---|
| 187 | <equals arg1="${property.value}" arg2="..."/>
|
|---|
| 188 | </not>
|
|---|
| 189 | </and>
|
|---|
| 190 | </condition>
|
|---|
| 191 | </target>
|
|---|
| 192 | <!--
|
|---|
| 193 | **********************************************************
|
|---|
| 194 | ** revision - extracts the current revision number for the
|
|---|
| 195 | ** file build.number and stores it in the XML property
|
|---|
| 196 | ** version.*
|
|---|
| 197 | **********************************************************
|
|---|
| 198 | -->
|
|---|
| 199 | <!--
|
|---|
| 200 | ** Initializes the REVISION.XML file from SVN information
|
|---|
| 201 | -->
|
|---|
| 202 | <target name="init-svn-revision-xml">
|
|---|
| 203 | <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false" resultproperty="svn.info.result">
|
|---|
| 204 | <env key="LANG" value="C"/>
|
|---|
| 205 | <arg value="info"/>
|
|---|
| 206 | <arg value="--xml"/>
|
|---|
| 207 | <arg value="."/>
|
|---|
| 208 | </exec>
|
|---|
| 209 | <condition property="svn.info.success">
|
|---|
| 210 | <equals arg1="${svn.info.result}" arg2="0" />
|
|---|
| 211 | </condition>
|
|---|
| 212 | </target>
|
|---|
| 213 | <!--
|
|---|
| 214 | ** Initializes the REVISION.XML file from git-svn information.
|
|---|
| 215 | Obtains the revision from the git-svn-id field.
|
|---|
| 216 | -->
|
|---|
| 217 | <target name="init-git-svn-revision-xml" unless="svn.info.success">
|
|---|
| 218 | <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.svn.info.result">
|
|---|
| 219 | <arg value="log"/>
|
|---|
| 220 | <arg value="-1"/>
|
|---|
| 221 | <arg value="--grep=git-svn-id"/>
|
|---|
| 222 | <!--
|
|---|
| 223 | %B: raw body (unwrapped subject and body)
|
|---|
| 224 | %n: new line
|
|---|
| 225 | %ai: author date, ISO 8601 format
|
|---|
| 226 | -->
|
|---|
| 227 | <arg value="--pretty=format:%B%n%ai"/>
|
|---|
| 228 | <arg value="."/>
|
|---|
| 229 | </exec>
|
|---|
| 230 | <replaceregexp file="REVISION.XML" flags="s"
|
|---|
| 231 | match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
|
|---|
| 232 | replace="<info><entry><commit revision="\1"><date>\2</date></commit></entry></info>"/>
|
|---|
| 233 | <condition property="git.svn.fail">
|
|---|
| 234 | <not>
|
|---|
| 235 | <and>
|
|---|
| 236 | <equals arg1="${git.svn.info.result}" arg2="0" />
|
|---|
| 237 | <length file="REVISION.XML" when="greater" length="1" />
|
|---|
| 238 | </and>
|
|---|
| 239 | </not>
|
|---|
| 240 | </condition>
|
|---|
| 241 | </target>
|
|---|
| 242 | <!--
|
|---|
| 243 | ** Initializes the REVISION.XML file from git (w/o svn) information.
|
|---|
| 244 | Uses Unix date as revision number.
|
|---|
| 245 | -->
|
|---|
| 246 | <target name="init-git-revision-xml" if="git.svn.fail">
|
|---|
| 247 | <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.info.result">
|
|---|
| 248 | <arg value="log"/>
|
|---|
| 249 | <arg value="-1"/>
|
|---|
| 250 | <arg value="--pretty=format:%at%n%ai"/>
|
|---|
| 251 | <arg value="."/>
|
|---|
| 252 | </exec>
|
|---|
| 253 | <replaceregexp file="REVISION.XML" flags="s"
|
|---|
| 254 | match="\s*(\d*)\s+(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
|
|---|
| 255 | replace="<info><entry><commit revision="\1"><date>\2</date></commit></entry></info>"/>
|
|---|
| 256 | <condition property="git.fail">
|
|---|
| 257 | <not>
|
|---|
| 258 | <and>
|
|---|
| 259 | <equals arg1="${git.info.result}" arg2="0" />
|
|---|
| 260 | <length file="REVISION.XML" when="greater" length="1" />
|
|---|
| 261 | </and>
|
|---|
| 262 | </not>
|
|---|
| 263 | </condition>
|
|---|
| 264 | </target>
|
|---|
| 265 | <target name="init-revision-fallback" if="git.fail">
|
|---|
| 266 | <tstamp>
|
|---|
| 267 | <format property="current.time" pattern="yyyy-MM-dd'T'HH:mm:ss.SSS" />
|
|---|
| 268 | </tstamp>
|
|---|
| 269 | <echo file="REVISION.XML"><![CDATA[<info><entry><commit revision="UNKNOWN"><date>${current.time}</date></commit></entry></info>]]></echo>
|
|---|
| 270 | </target>
|
|---|
| 271 | <target name="revision" depends="init-svn-revision-xml, init-git-svn-revision-xml, init-git-revision-xml, init-revision-fallback">
|
|---|
| 272 | <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
|
|---|
| 273 | <delete file="REVISION.XML"/>
|
|---|
| 274 | </target>
|
|---|
| 275 | <!--
|
|---|
| 276 | **********************************************************
|
|---|
| 277 | ** clean - clean up the build environment
|
|---|
| 278 | **********************************************************
|
|---|
| 279 | -->
|
|---|
| 280 | <target name="clean">
|
|---|
| 281 | <delete dir="${plugin.build.dir}"/>
|
|---|
| 282 | <delete file="${plugin.jar}"/>
|
|---|
| 283 | </target>
|
|---|
| 284 | <!--
|
|---|
| 285 | **********************************************************
|
|---|
| 286 | ** install - install the plugin in your local JOSM installation
|
|---|
| 287 | **********************************************************
|
|---|
| 288 | -->
|
|---|
| 289 | <target name="install" depends="dist">
|
|---|
| 290 | <property environment="env"/>
|
|---|
| 291 | <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins">
|
|---|
| 292 | <and>
|
|---|
| 293 | <os family="windows"/>
|
|---|
| 294 | </and>
|
|---|
| 295 | </condition>
|
|---|
| 296 | <condition property="josm.plugins.dir" value="${user.home}/Library/JOSM/plugins">
|
|---|
| 297 | <and>
|
|---|
| 298 | <os family="mac"/>
|
|---|
| 299 | </and>
|
|---|
| 300 | </condition>
|
|---|
| 301 | <condition property="josm.plugins.dir" value="${user.home}/.josm/plugins">
|
|---|
| 302 | <and>
|
|---|
| 303 | <not><os family="windows"/></not>
|
|---|
| 304 | <not><os family="mac"/></not>
|
|---|
| 305 | </and>
|
|---|
| 306 | </condition>
|
|---|
| 307 | <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
|
|---|
| 308 | </target>
|
|---|
| 309 | <!--
|
|---|
| 310 | ************************** Publishing the plugin ***********************************
|
|---|
| 311 | -->
|
|---|
| 312 | <!--
|
|---|
| 313 | ** extracts the JOSM release for the JOSM version in ../core and saves it in the
|
|---|
| 314 | ** property ${coreversion.info.entry.revision}
|
|---|
| 315 | **
|
|---|
| 316 | -->
|
|---|
| 317 | <target name="core-info">
|
|---|
| 318 | <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
|
|---|
| 319 | <env key="LANG" value="C"/>
|
|---|
| 320 | <arg value="info"/>
|
|---|
| 321 | <arg value="--xml"/>
|
|---|
| 322 | <arg value="../../core"/>
|
|---|
| 323 | </exec>
|
|---|
| 324 | <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
|
|---|
| 325 | <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
|
|---|
| 326 | <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
|
|---|
| 327 | <delete file="core.info.xml"/>
|
|---|
| 328 | </target>
|
|---|
| 329 | <!--
|
|---|
| 330 | ** commits the source tree for this plugin
|
|---|
| 331 | -->
|
|---|
| 332 | <target name="commit-current">
|
|---|
| 333 | <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
|
|---|
| 334 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
|---|
| 335 | <env key="LANG" value="C"/>
|
|---|
| 336 | <arg value="commit"/>
|
|---|
| 337 | <arg value="-m"/>
|
|---|
| 338 | <arg value="${commit.message}"/>
|
|---|
| 339 | <arg value="."/>
|
|---|
| 340 | </exec>
|
|---|
| 341 | </target>
|
|---|
| 342 | <!--
|
|---|
| 343 | ** updates (svn up) the source tree for this plugin
|
|---|
| 344 | -->
|
|---|
| 345 | <target name="update-current">
|
|---|
| 346 | <echo>Updating plugin source ...</echo>
|
|---|
| 347 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
|---|
| 348 | <env key="LANG" value="C"/>
|
|---|
| 349 | <arg value="up"/>
|
|---|
| 350 | <arg value="."/>
|
|---|
| 351 | </exec>
|
|---|
| 352 | <echo>Updating ${plugin.jar} ...</echo>
|
|---|
| 353 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
|---|
| 354 | <env key="LANG" value="C"/>
|
|---|
| 355 | <arg value="up"/>
|
|---|
| 356 | <arg value="../dist/${plugin.jar}"/>
|
|---|
| 357 | </exec>
|
|---|
| 358 | </target>
|
|---|
| 359 | <!--
|
|---|
| 360 | ** commits the plugin.jar
|
|---|
| 361 | -->
|
|---|
| 362 | <target name="commit-dist">
|
|---|
| 363 | <echo>
|
|---|
| 364 | ***** Properties of published ${plugin.jar} *****
|
|---|
| 365 | Commit message : '${commit.message}'
|
|---|
| 366 | Plugin-Mainversion: ${plugin.main.version}
|
|---|
| 367 | JOSM build version: ${coreversion.info.entry.revision}
|
|---|
| 368 | Plugin-Version : ${version.entry.commit.revision}
|
|---|
| 369 | ***** / Properties of published ${plugin.jar} *****
|
|---|
| 370 |
|
|---|
| 371 | Now commiting ${plugin.jar} ...
|
|---|
| 372 | </echo>
|
|---|
| 373 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
|---|
| 374 | <env key="LANG" value="C"/>
|
|---|
| 375 | <arg value="-m"/>
|
|---|
| 376 | <arg value="${commit.message}"/>
|
|---|
| 377 | <arg value="commit"/>
|
|---|
| 378 | <arg value="${plugin.jar}"/>
|
|---|
| 379 | </exec>
|
|---|
| 380 | </target>
|
|---|
| 381 | <!-- ** make sure svn is present as a command line tool ** -->
|
|---|
| 382 | <target name="ensure-svn-present">
|
|---|
| 383 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
|
|---|
| 384 | <env key="LANG" value="C"/>
|
|---|
| 385 | <arg value="--version"/>
|
|---|
| 386 | </exec>
|
|---|
| 387 | <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
|
|---|
| 388 | <!-- return code not set at all? Most likely svn isn't installed -->
|
|---|
| 389 | <condition>
|
|---|
| 390 | <not>
|
|---|
| 391 | <isset property="svn.exit.code"/>
|
|---|
| 392 | </not>
|
|---|
| 393 | </condition>
|
|---|
| 394 | </fail>
|
|---|
| 395 | <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
|
|---|
| 396 | <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
|
|---|
| 397 | <condition>
|
|---|
| 398 | <isfailure code="${svn.exit.code}"/>
|
|---|
| 399 | </condition>
|
|---|
| 400 | </fail>
|
|---|
| 401 | </target>
|
|---|
| 402 |
|
|---|
| 403 | <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
|
|---|
| 404 | </target>
|
|---|
| 405 |
|
|---|
| 406 | <path id="test.classpath">
|
|---|
| 407 | <fileset dir="../00_core_test_lib">
|
|---|
| 408 | <include name="**/*.jar"/>
|
|---|
| 409 | </fileset>
|
|---|
| 410 | <fileset dir="${plugin.test.dir}/lib" erroronmissingdir="no">
|
|---|
| 411 | <include name="**/*.jar"/>
|
|---|
| 412 | <exclude name="**/*-sources.jar"/>
|
|---|
| 413 | <exclude name="**/*-javadoc.jar"/>
|
|---|
| 414 | </fileset>
|
|---|
| 415 | <fileset dir="lib" erroronmissingdir="no">
|
|---|
| 416 | <include name="**/*.jar"/>
|
|---|
| 417 | <exclude name="**/*-sources.jar"/>
|
|---|
| 418 | <exclude name="**/*-javadoc.jar"/>
|
|---|
| 419 | </fileset>
|
|---|
| 420 | <pathelement path="${plugin.test.dir}/data"/>
|
|---|
| 421 | <pathelement path="${josm.test.build.dir}/unit"/>
|
|---|
| 422 | <pathelement path="${josm}"/>
|
|---|
| 423 | <pathelement path="${plugin.jar}"/>
|
|---|
| 424 | <pathelement path="${groovy.jar}"/>
|
|---|
| 425 | <pathelement path="${annotations.jar}"/>
|
|---|
| 426 | </path>
|
|---|
| 427 | <macrodef name="init-test-preferences">
|
|---|
| 428 | <sequential>
|
|---|
| 429 | <copy file="${plugin.test.dir}/config/preferences.template.xml" tofile="${plugin.test.dir}/config/unit-josm.home/preferences.xml"/>
|
|---|
| 430 | <replace file="${plugin.test.dir}/config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
|
|---|
| 431 | <replace file="${plugin.test.dir}/config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
|
|---|
| 432 | </sequential>
|
|---|
| 433 | </macrodef>
|
|---|
| 434 | <target name="check-test">
|
|---|
| 435 | <available file="${plugin.test.dir}" type="dir" property="test.present"/>
|
|---|
| 436 | </target>
|
|---|
| 437 | <target name="test-init" depends="check-test" if="test.present">
|
|---|
| 438 | <mkdir dir="${plugin.test.dir}/build"/>
|
|---|
| 439 | <mkdir dir="${plugin.test.dir}/build/unit"/>
|
|---|
| 440 | <mkdir dir="${plugin.test.dir}/report"/>
|
|---|
| 441 | <init-test-preferences/>
|
|---|
| 442 | </target>
|
|---|
| 443 | <target name="test-clean">
|
|---|
| 444 | <delete dir="${plugin.test.dir}/build"/>
|
|---|
| 445 | <delete dir="${plugin.test.dir}/report"/>
|
|---|
| 446 | <delete file="${plugin.test.dir}/jacoco.exec" />
|
|---|
| 447 | <delete file="${plugin.test.dir}/config/unit-josm.home/preferences.xml" />
|
|---|
| 448 | <delete dir="${plugin.test.dir}/config/unit-josm.home/cache" failonerror="false"/>
|
|---|
| 449 | </target>
|
|---|
| 450 | <target name="test-compile" depends="test-init,dist" if="test.present">
|
|---|
| 451 | <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${groovy.jar}"/>
|
|---|
| 452 | <sequential>
|
|---|
| 453 | <groovyc srcdir="${plugin.test.dir}/unit" destdir="${plugin.test.dir}/build/unit" encoding="UTF-8">
|
|---|
| 454 | <classpath>
|
|---|
| 455 | <fileset refid="plugin.requires.jars"/>
|
|---|
| 456 | <path refid="test.classpath"/>
|
|---|
| 457 | </classpath>
|
|---|
| 458 | <javac debug="on" encoding="UTF-8">
|
|---|
| 459 | <compilerarg value="-Xlint:all"/>
|
|---|
| 460 | <compilerarg value="-Xlint:-serial"/>
|
|---|
| 461 | </javac>
|
|---|
| 462 | </groovyc>
|
|---|
| 463 | </sequential>
|
|---|
| 464 | </target>
|
|---|
| 465 | <target name="test" depends="dist, test-clean, test-compile" if="test.present"
|
|---|
| 466 | description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
|
|---|
| 467 | <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="../00_core_tools/jacocoant.jar" />
|
|---|
| 468 | <sequential>
|
|---|
| 469 | <echo message="Running unit tests with JUnit"/>
|
|---|
| 470 | <jacoco:coverage destfile="${plugin.test.dir}/jacoco.exec">
|
|---|
| 471 | <junit printsummary="yes" fork="true" forkmode="once" dir="${basedir}">
|
|---|
| 472 | <jvmarg value="-Dfile.encoding=UTF-8"/>
|
|---|
| 473 | <sysproperty key="josm.home" value="${plugin.test.dir}/config/unit-josm.home"/>
|
|---|
| 474 | <sysproperty key="josm.test.data" value="${plugin.test.dir}/data"/>
|
|---|
| 475 | <sysproperty key="java.awt.headless" value="true"/>
|
|---|
| 476 | <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
|
|---|
| 477 | <classpath>
|
|---|
| 478 | <fileset refid="plugin.requires.jars"/>
|
|---|
| 479 | <path refid="test.classpath"/>
|
|---|
| 480 | <pathelement path="${plugin.test.dir}/build/unit"/>
|
|---|
| 481 | </classpath>
|
|---|
| 482 | <formatter type="plain"/>
|
|---|
| 483 | <formatter type="xml"/>
|
|---|
| 484 | <batchtest fork="yes" todir="${plugin.test.dir}/report">
|
|---|
| 485 | <fileset dir="${plugin.test.dir}/build/unit" includes="**/*Test.class"/>
|
|---|
| 486 | </batchtest>
|
|---|
| 487 | </junit>
|
|---|
| 488 | </jacoco:coverage>
|
|---|
| 489 | </sequential>
|
|---|
| 490 | </target>
|
|---|
| 491 |
|
|---|
| 492 | <target name="checkstyle">
|
|---|
| 493 | <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpath="${checkstyle.jar}"/>
|
|---|
| 494 | <checkstyle config="../00_core_tools/checkstyle/josm_checks.xml">
|
|---|
| 495 | <fileset dir="${basedir}/src" includes="**/*.java"/>
|
|---|
| 496 | <fileset dir="${basedir}/test" includes="**/*.java" erroronmissingdir="false"/>
|
|---|
| 497 | <formatter type="xml" toFile="checkstyle-josm-${ant.project.name}.xml"/>
|
|---|
| 498 | </checkstyle>
|
|---|
| 499 | </target>
|
|---|
| 500 |
|
|---|
| 501 | <target name="findbugs" depends="dist">
|
|---|
| 502 | <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${findbugs-ant.jar}"/>
|
|---|
| 503 | <path id="findbugs-classpath">
|
|---|
| 504 | <fileset dir="../00_core_tools/findbugs/">
|
|---|
| 505 | <include name="*.jar"/>
|
|---|
| 506 | </fileset>
|
|---|
| 507 | </path>
|
|---|
| 508 | <property name="findbugs-classpath" refid="findbugs-classpath"/>
|
|---|
| 509 | <findbugs output="xml"
|
|---|
| 510 | outputFile="findbugs-josm-${ant.project.name}.xml"
|
|---|
| 511 | classpath="${findbugs-classpath}"
|
|---|
| 512 | pluginList=""
|
|---|
| 513 | excludeFilter="../00_core_tools/findbugs/josm-filter.xml"
|
|---|
| 514 | effort="default"
|
|---|
| 515 | reportLevel="low"
|
|---|
| 516 | >
|
|---|
| 517 | <sourcePath path="${basedir}/src" />
|
|---|
| 518 | <class location="${plugin.jar}" />
|
|---|
| 519 | </findbugs>
|
|---|
| 520 | </target>
|
|---|
| 521 |
|
|---|
| 522 | <target name="runjosm" depends="install">
|
|---|
| 523 | <java jar="${josm}" fork="true">
|
|---|
| 524 | </java>
|
|---|
| 525 | </target>
|
|---|
| 526 |
|
|---|
| 527 | <target name="profilejosm" depends="install">
|
|---|
| 528 | <nbprofiledirect>
|
|---|
| 529 | </nbprofiledirect>
|
|---|
| 530 | <java jar="${josm}" fork="true">
|
|---|
| 531 | <jvmarg value="${profiler.info.jvmargs.agent}"/>
|
|---|
| 532 | </java>
|
|---|
| 533 | </target>
|
|---|
| 534 | <!--
|
|---|
| 535 | ** shows a help text
|
|---|
| 536 | -->
|
|---|
| 537 | <target name="help">
|
|---|
| 538 | <echo>
|
|---|
| 539 | You can use following targets:
|
|---|
| 540 | * dist This default target builds the plugin jar file
|
|---|
| 541 | * clean Cleanup automatical created files
|
|---|
| 542 | * test Run unit tests (if any)
|
|---|
| 543 | * publish Checkin source code, build jar and checkin plugin jar
|
|---|
| 544 | (requires proper entry for SVN commit message!)
|
|---|
| 545 | * install Install the plugin in current system
|
|---|
| 546 | * runjosm Install plugin and start josm
|
|---|
| 547 | * profilejosm Install plugin and start josm in profiling mode
|
|---|
| 548 |
|
|---|
| 549 | There are other targets, which usually should not be called manually.
|
|---|
| 550 | </echo>
|
|---|
| 551 | </target>
|
|---|
| 552 | </project>
|
|---|