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