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