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