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