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