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