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