source: osm/applications/editors/josm/plugins/build-common.xml@ 36325

Last change on this file since 36325 was 36325, checked in by taylor.smock, 7 weeks ago

See #23875: Use SNAPSHOT instead of 1.0-SNAPSHOT since that is what our scripts currently publish

This should fix the Jenkins build for plugins.

Note: Maven warns that this may break in the future, in which case we'll have to
change our processes.

File size: 44.8 KB
RevLine 
[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-->
[36315]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" xmlns:mvn="antlib:org.apache.maven.resolver.ant" >
[26341]14
[31508]15 <property name="josm" location="../../core/dist/josm-custom.jar"/>
[35411]16 <property name="josm.ivy" location="../../core/ivy.xml"/>
[35413]17 <property name="josm.ivysettings" location="../../core/ivysettings.xml"/>
[31508]18 <property name="josm.test.build.dir" location="../../core/test/build"/>
[35378]19 <property name="core.tools.ivy" location="../00_core_tools/ivy.xml"/>
[34409]20 <property name="plugin.tools.dir" location="../00_tools"/>
[30550]21 <property name="plugin.build.dir" location="build"/>
22 <property name="plugin.test.dir" location="test"/>
23 <property name="plugin.src.dir" location="src"/>
[34677]24 <property name="plugin.resources.dir" location="resources"/>
[34045]25 <property name="plugin.doc.dir" location="javadoc"/>
[30550]26 <property name="plugin.lib.dir" location="lib"/>
[26341]27 <!-- this is the directory where the plugin jar is copied to -->
[30550]28 <property name="plugin.dist.dir" location="../../dist"/>
[36308]29 <property name="java.lang.version" value="11" />
[34873]30 <property name="javadoc.executable" value="javadoc" />
[34703]31 <property name="manifest" value="MANIFEST"/>
32 <property name="manifest.unixoid" value="MANIFEST-unixoid"/>
33 <property name="manifest.windows" value="MANIFEST-windows"/>
34 <property name="manifest.osx" value="MANIFEST-osx"/>
[30550]35 <property name="plugin.jar" location="${plugin.dist.dir}/${ant.project.name}.jar"/>
[34703]36 <property name="plugin.unixoid.jar" location="${plugin.dist.dir}/${ant.project.name}-unixoid.jar"/>
37 <property name="plugin.windows.jar" location="${plugin.dist.dir}/${ant.project.name}-windows.jar"/>
38 <property name="plugin.osx.jar" location="${plugin.dist.dir}/${ant.project.name}-osx.jar"/>
[34244]39 <property name="plugin.sources.jar" location="${plugin.dist.dir}/${ant.project.name}-sources.jar"/>
40 <property name="plugin.javadoc.jar" location="${plugin.dist.dir}/${ant.project.name}-javadoc.jar"/>
[34581]41 <property name="ivy.home" location="${user.home}/.ant"/>
42 <property name="ivy.jar.dir" location="${ivy.home}/lib"/>
43 <property name="ivy.jar.file" location="${ivy.jar.dir}/ivy.jar"/>
[36033]44 <property name="ivy.version" value="2.5.1"/>
[36315]45 <property name="maven.artifact.resolver.version" value="1.5.1"/>
46 <property name="maven.artifact.resolver.parent.dir" value="${user.home}/.m2/repository/org/apache/maven/resolver/maven-resolver-ant-tasks/${maven.artifact.resolver.version}/"/>
47 <property name="maven.artifact.resolver.jar.file" value="${maven.artifact.resolver.parent.dir}/maven-resolver-ant-tasks-${maven.artifact.resolver.version}-uber.jar"/>
[35714]48 <property name="jacoco.inclbootstrapclasses" value="false" />
49 <property name="jacoco.inclnolocationclasses" value="false" />
50 <property name="junit.printsummary" value="on" />
[26341]51
[34703]52 <!-- For platform-specific stuff -->
53 <condition property="isWindows"><os family="Windows"/></condition>
54 <condition property="isUnix"><os family="Unix"/></condition>
55 <condition property="isMac"><os family="Mac"/></condition>
[34620]56 <!-- For Java specific stuff by version -->
[36151]57 <condition property="isJava14"><matches string="${ant.java.version}" pattern="1[4-9]|[2-9][0-9]" /></condition>
58 <condition property="isJava15"><matches string="${ant.java.version}" pattern="1[5-9]|[2-9][0-9]" /></condition>
59 <condition property="isJava17"><matches string="${ant.java.version}" pattern="1[7-9]|[2-9][0-9]" /></condition>
60 <condition property="isJava21"><matches string="${ant.java.version}" pattern="2[1-9]|[3-9][0-9]" /></condition>
[36176]61
62 <!-- set the javadoc location -->
[36308]63 <property name="javadoc.link" value="https://docs.oracle.com/en/java/javase/11/docs/api/" unless:set="isJava17"/>
[36176]64 <property name="javadoc.link" value="https://docs.oracle.com/en/java/javase/17/docs/api/" if:set="isJava17" unless:set="isJava21"/>
65 <property name="javadoc.link" value="https://docs.oracle.com/en/java/javase/21/docs/api/" if:set="isJava21"/>
66
[36151]67 <!-- Disable jacoco on Java 21+ (Jacoco does not yet support Java 21+) -->
[34363]68 <condition property="coverageByDefault">
69 <not>
[36151]70 <isset property="isJava21"/>
[34363]71 </not>
72 </condition>
[34376]73 <target name="-jaxb_windows" if="isWindows">
[34578]74 <property name="xjc" value="${plugin.tools.dir}${file.separator}jaxb-ri${file.separator}bin${file.separator}xjc.bat" />
[30699]75 </target>
[34376]76 <target name="-jaxb_linux" unless="isWindows">
[34578]77 <property name="xjc" value="${plugin.tools.dir}${file.separator}jaxb-ri${file.separator}bin${file.separator}xjc.sh" />
[34376]78 </target>
[30699]79
[30747]80 <!-- To be overriden in plugin build file before inclusion if other plugins are required -->
81 <fileset id="plugin.requires.jars" dir="${plugin.dist.dir}" includes="nothing"/>
82
[34409]83 <fileset id="jaxb.jars" dir="${plugin.tools.dir}/jaxb-ri/lib" includes="**/*.jar"/>
84
[32312]85 <path id="plugin.classpath">
86 <pathelement location="${josm}"/>
87 <fileset dir="${plugin.lib.dir}" erroronmissingdir="no">
88 <include name="**/*.jar"/>
89 <exclude name="**/*-sources.jar"/>
90 <exclude name="**/*-javadoc.jar"/>
[34703]91 <exclude name="**/*-unixoid.jar" unless="isUnix"/>
92 <exclude name="**/*-windows.jar" unless="isWindows"/>
93 <exclude name="**/*-osx.jar" unless="isMac"/>
[32312]94 </fileset>
95 <fileset refid="plugin.requires.jars"/>
[34409]96 <fileset refid="jaxb.jars"/>
[32312]97 </path>
98
[26341]99 <!--
100 **********************************************************
101 ** init - initializes the build
102 **********************************************************
103 -->
104 <target name="init">
105 <mkdir dir="${plugin.build.dir}"/>
106 </target>
107 <!--
108 **********************************************************
[29442]109 ** compile - compiles the source tree
[26341]110 **********************************************************
111 -->
[32322]112 <target name="pre-compile">
[35387]113 <!-- to be overridden by plugins that need to perform additional tasks before compiling -->
[32322]114 </target>
[35489]115 <target name="compile" depends="init, pre-compile, resolve-tools" unless="skip-compile">
[36315]116 <condition property="plugin.classpath.actual.defined">
117 <isreference refid="plugin.classpath.actual" type="path"/>
118 </condition>
119 <path id="plugin.classpath.actual" unless:set="plugin.classpath.actual.defined">
120 <path refid="plugin.classpath"/>
121 </path>
[28290]122 <echo message="compiling sources for ${plugin.jar} ..."/>
[36308]123 <path id="jdk.boot.classpath">
[35489]124 <path refid="errorprone_javac.classpath"/>
125 <fileset refid="jaxb.jars"/>
126 </path>
[34620]127 <javac srcdir="${plugin.src.dir}" debug="true" destdir="${plugin.build.dir}" includeantruntime="false"
[35765]128 encoding="UTF-8" release="${java.lang.version}" fork="yes">
[36308]129 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" unless:set="noErrorProne"/>
130 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED" unless:set="noErrorProne"/>
131 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED" unless:set="noErrorProne"/>
132 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED" unless:set="noErrorProne"/>
133 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED" unless:set="noErrorProne"/>
134 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED" unless:set="noErrorProne"/>
135 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" unless:set="noErrorProne"/>
136 <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED" unless:set="noErrorProne"/>
137 <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED" unless:set="noErrorProne"/>
[34620]138 <compilerarg line="-XDcompilePolicy=simple"/>
139 <compilerarg value="-processorpath"/>
[35489]140 <compilerarg pathref="errorprone.classpath"/>
[26341]141 <compilerarg value="-Xlint:deprecation"/>
142 <compilerarg value="-Xlint:unchecked"/>
[36308]143 <compilerarg value="-Xplugin:ErrorProne -Xep:StringSplitter:OFF -Xep:ReferenceEquality:OFF -Xep:InsecureCryptoUsage:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsHashCode:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF" />
[32737]144 <compilerarg line="-Xmaxwarns 1000"/>
[36315]145 <classpath refid="plugin.classpath.actual"/>
[26341]146 </javac>
147 </target>
148 <!--
149 **********************************************************
[29005]150 ** setup-dist - copies files for distribution
[28990]151 **********************************************************
152 -->
[29005]153 <target name="setup-dist-default">
[28990]154 <copy todir="${plugin.build.dir}/resources" failonerror="no" includeemptydirs="no">
[34677]155 <fileset dir="${plugin.resources.dir}"/>
[28990]156 </copy>
157 <copy todir="${plugin.build.dir}/images" failonerror="no" includeemptydirs="no">
158 <fileset dir="images"/>
159 </copy>
160 <copy todir="${plugin.build.dir}/data" failonerror="no" includeemptydirs="no">
161 <fileset dir="data"/>
162 </copy>
163 <copy todir="${plugin.build.dir}">
164 <fileset dir=".">
165 <include name="README"/>
[28996]166 <include name="LICENSE*"/>
167 <include name="*GPL*"/>
[34323]168 <exclude name="*.md"/>
[28990]169 </fileset>
170 </copy>
[29005]171 </target>
172 <target name="setup-dist">
[29007]173 <antcall target="setup-dist-default" />
[29005]174 </target>
175 <!--
176 **********************************************************
[34244]177 ** dist - creates the plugin jars
[29005]178 **********************************************************
179 -->
[34244]180 <target name="dist" depends="compile,javadoc,revision" unless="skip-dist">
[29005]181 <echo message="creating ${ant.project.name}.jar ... "/>
[29007]182 <antcall target="setup-dist" />
[34703]183 <delete failonerror="no">
184 <fileset dir="." includes="${manifest}*" />
185 </delete>
186 <manifest file="${manifest}" mode="update">
[28990]187 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
[35802]188 <attribute name="Plugin-Version" value="${version.entry.commit.revision}" unless:set="plugin.version"/>
189 <attribute name="Plugin-Version" value="${plugin.version}" if:set="plugin.version"/>
[28990]190 <attribute name="Plugin-Class" value="${plugin.class}" />
191 <attribute name="Plugin-Description" value="${plugin.description}" />
192 <attribute name="Plugin-Date" value="${version.entry.commit.date}" />
193 <attribute name="Author" value="${plugin.author}"/>
194 </manifest>
195 <antcall target="add-manifest-attribute">
196 <param name="manifest.attribute" value="Plugin-Link"/>
[30562]197 <param name="property.name" value="plugin.link"/>
198 <param name="property.value" value="${plugin.link}"/>
[28990]199 </antcall>
200 <antcall target="add-manifest-attribute">
201 <param name="manifest.attribute" value="Plugin-Icon"/>
[30562]202 <param name="property.name" value="plugin.icon"/>
203 <param name="property.value" value="${plugin.icon}"/>
[28990]204 </antcall>
205 <antcall target="add-manifest-attribute">
206 <param name="manifest.attribute" value="Plugin-Early"/>
[30562]207 <param name="property.name" value="plugin.early"/>
208 <param name="property.value" value="${plugin.early}"/>
[28990]209 </antcall>
210 <antcall target="add-manifest-attribute">
[34705]211 <param name="manifest.attribute" value="Plugin-Provides"/>
212 <param name="property.name" value="plugin.provides"/>
213 <param name="property.value" value="${plugin.provides}"/>
214 </antcall>
215 <antcall target="add-manifest-attribute">
[28990]216 <param name="manifest.attribute" value="Plugin-Requires"/>
[30562]217 <param name="property.name" value="plugin.requires"/>
218 <param name="property.value" value="${plugin.requires}"/>
[28990]219 </antcall>
220 <antcall target="add-manifest-attribute">
221 <param name="manifest.attribute" value="Plugin-Stage"/>
[30562]222 <param name="property.name" value="plugin.stage"/>
223 <param name="property.value" value="${plugin.stage}"/>
[28990]224 </antcall>
[30952]225 <antcall target="add-manifest-attribute">
226 <param name="manifest.attribute" value="Plugin-Canloadatruntime"/>
227 <param name="property.name" value="plugin.canloadatruntime"/>
228 <param name="property.value" value="${plugin.canloadatruntime}"/>
229 </antcall>
[34604]230 <antcall target="add-manifest-attribute">
231 <param name="manifest.attribute" value="Plugin-Minimum-Java-Version"/>
232 <param name="property.name" value="plugin.minimum.java.version"/>
233 <param name="property.value" value="${plugin.minimum.java.version}"/>
234 </antcall>
[29435]235 <antcall target="additional-manifest" />
[34651]236 <antcall target="build-jar" />
237 <jar destfile="${plugin.sources.jar}" basedir="${plugin.src.dir}" level="9"/>
238 <jar destfile="${plugin.javadoc.jar}" basedir="${plugin.doc.dir}" level="9"/>
[34703]239 <delete failonerror="no">
240 <fileset dir="." includes="${manifest}*" />
241 </delete>
[34651]242 <antcall target="post-dist" />
243 </target>
244 <target name="build-jar">
[34703]245 <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="${manifest}" manifestencoding="UTF-8" duplicate="preserve" level="9">
[31281]246 <restrict>
247 <not><or>
248 <name name="META-INF/maven/*"/>
249 <name name="META-INF/DEPENDENCIES"/>
250 <name name="META-INF/LICENSE"/>
251 <name name="META-INF/NOTICE"/>
[32175]252 <name name="META-INF/*.RSA"/>
253 <name name="META-INF/*.SF"/>
[34604]254 <name name="module-info.class"/>
[31281]255 </or></not>
256 <archives>
257 <zips>
258 <fileset dir="${plugin.lib.dir}" includes="*.jar" excludes="*-sources.jar, *-javadoc.jar" erroronmissingdir="no"/>
259 </zips>
260 </archives>
261 </restrict>
[28990]262 </jar>
263 </target>
[29007]264 <target name="post-dist">
[35387]265 <!-- to be overridden by plugins that need to perform additional tasks on resulting jar -->
[29007]266 </target>
[30562]267 <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${property.name}">
[34703]268 <manifest file="${manifest}" mode="update">
[30562]269 <attribute name="${manifest.attribute}" value="${property.value}" />
[28990]270 </manifest>
271 </target>
[29435]272 <!-- target to add additional entries, empty in commons -->
273 <target name="additional-manifest">
274 </target>
[28990]275 <target name="check-manifest-attribute">
[30562]276 <condition property="have-${property.name}">
[28990]277 <and>
[30562]278 <isset property="${property.name}"/>
[28990]279 <not>
[30562]280 <equals arg1="${property.value}" arg2=""/>
[28990]281 </not>
282 <not>
[30562]283 <equals arg1="${property.value}" arg2="..."/>
[28990]284 </not>
285 </and>
286 </condition>
287 </target>
[35340]288 <target name="pre-javadoc">
[35387]289 <!-- to be overridden by plugins that need to perform additional tasks before generating javadoc -->
[35340]290 </target>
[36315]291 <target name="javadoc" depends="pre-javadoc,pre-compile" unless="skip-javadoc">
292 <mkdir dir="${plugin.doc.dir}"/>
[34045]293 <javadoc destdir="${plugin.doc.dir}"
[34873]294 executable="${javadoc.executable}"
[34038]295 encoding="UTF-8"
296 windowtitle="JOSM-${ant.project.name}"
297 use="true"
298 private="true"
299 linksource="true"
300 author="false">
[36315]301 <classpath refid="plugin.classpath" unless:set="plugin.classpath.dependencies"/>
302 <classpath refid="plugin.classpath.dependencies" if:set="plugin.classpath.dependencies"/>
[34383]303 <sourcepath>
[34387]304 <pathelement path="${plugin.src.dir}" />
[34383]305 <pathelement path="gen" />
306 <pathelement path="includes" />
307 </sourcepath>
[34874]308 <link href="${javadoc.link}"/>
[34038]309 <link href="https://josm.openstreetmap.de/doc"/>
310 <doctitle><![CDATA[<h2>JOSM-${ant.project.name} - Javadoc</h2>]]></doctitle>
311 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/wiki/Plugins">JOSM Plugins</a>]]></bottom>
[34595]312 <arg line="-tag license:X" />
[36308]313 <arg value="-html5" />
314 <arg value="--add-exports" unless:set="noJavaFX" />
315 <arg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" unless:set="noJavaFX" />
[34038]316 </javadoc>
317 </target>
[28990]318 <!--
319 **********************************************************
[26341]320 ** revision - extracts the current revision number for the
321 ** file build.number and stores it in the XML property
322 ** version.*
323 **********************************************************
324 -->
[30161]325 <!--
326 ** Initializes the REVISION.XML file from SVN information
327 -->
[32334]328 <target name="init-svn-revision-xml" unless="skip-revision">
[30161]329 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false" resultproperty="svn.info.result">
[26341]330 <env key="LANG" value="C"/>
331 <arg value="info"/>
332 <arg value="--xml"/>
333 <arg value="."/>
334 </exec>
[32334]335 <condition property="svn.info.fail">
[33489]336 <not>
337 <and>
338 <equals arg1="${svn.info.result}" arg2="0" />
339 <length file="REVISION.XML" when="greater" length="1" />
340 </and>
341 </not>
[30161]342 </condition>
[26341]343 </target>
344 <!--
[30306]345 ** Initializes the REVISION.XML file from git-svn information.
346 Obtains the revision from the git-svn-id field.
[30161]347 -->
[32334]348 <target name="init-git-svn-revision-xml" if="svn.info.fail" unless="skip-revision">
[30306]349 <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.svn.info.result">
[30161]350 <arg value="log"/>
351 <arg value="-1"/>
352 <arg value="--grep=git-svn-id"/>
353 <!--
354 %B: raw body (unwrapped subject and body)
355 %n: new line
356 %ai: author date, ISO 8601 format
357 -->
358 <arg value="--pretty=format:%B%n%ai"/>
[31886]359 <arg value="."/>
[30161]360 </exec>
361 <replaceregexp file="REVISION.XML" flags="s"
362 match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
363 replace="&lt;info&gt;&lt;entry&gt;&lt;commit revision=&quot;\1&quot;&gt;&lt;date&gt;\2&lt;/date&gt;&lt;/commit&gt;&lt;/entry&gt;&lt;/info&gt;"/>
[30306]364 <condition property="git.svn.fail">
365 <not>
366 <and>
367 <equals arg1="${git.svn.info.result}" arg2="0" />
368 <length file="REVISION.XML" when="greater" length="1" />
369 </and>
370 </not>
371 </condition>
[30562]372 </target>
[30306]373 <!--
374 ** Initializes the REVISION.XML file from git (w/o svn) information.
375 Uses Unix date as revision number.
376 -->
[32334]377 <target name="init-git-revision-xml" if="git.svn.fail" unless="skip-revision">
[30309]378 <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.info.result">
[30306]379 <arg value="log"/>
380 <arg value="-1"/>
381 <arg value="--pretty=format:%at%n%ai"/>
[31886]382 <arg value="."/>
[30306]383 </exec>
384 <replaceregexp file="REVISION.XML" flags="s"
385 match="\s*(\d*)\s+(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
386 replace="&lt;info&gt;&lt;entry&gt;&lt;commit revision=&quot;\1&quot;&gt;&lt;date&gt;\2&lt;/date&gt;&lt;/commit&gt;&lt;/entry&gt;&lt;/info&gt;"/>
[30309]387 <condition property="git.fail">
388 <not>
389 <and>
390 <equals arg1="${git.info.result}" arg2="0" />
391 <length file="REVISION.XML" when="greater" length="1" />
392 </and>
393 </not>
394 </condition>
[30161]395 </target>
[32334]396 <target name="init-revision-fallback" if="git.fail" unless="skip-revision">
[30309]397 <tstamp>
398 <format property="current.time" pattern="yyyy-MM-dd'T'HH:mm:ss.SSS" />
399 </tstamp>
400 <echo file="REVISION.XML"><![CDATA[<info><entry><commit revision="UNKNOWN"><date>${current.time}</date></commit></entry></info>]]></echo>
401 </target>
[32311]402 <target name="revision" depends="init-svn-revision-xml, init-git-svn-revision-xml, init-git-revision-xml, init-revision-fallback" unless="skip-revision">
[30161]403 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
404 <delete file="REVISION.XML"/>
405 </target>
406 <!--
[26341]407 **********************************************************
408 ** clean - clean up the build environment
409 **********************************************************
410 -->
411 <target name="clean">
412 <delete dir="${plugin.build.dir}"/>
[34045]413 <delete dir="${plugin.doc.dir}"/>
[26341]414 <delete file="${plugin.jar}"/>
[34244]415 <delete file="${plugin.sources.jar}"/>
416 <delete file="${plugin.javadoc.jar}"/>
[26341]417 </target>
418 <!--
419 **********************************************************
420 ** install - install the plugin in your local JOSM installation
421 **********************************************************
422 -->
423 <target name="install" depends="dist">
424 <property environment="env"/>
[30907]425 <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins">
[26341]426 <and>
427 <os family="windows"/>
428 </and>
429 </condition>
[30896]430 <condition property="josm.plugins.dir" value="${user.home}/Library/JOSM/plugins">
431 <and>
432 <os family="mac"/>
433 </and>
434 </condition>
[35923]435 <condition property="josm.plugins.dir" value="${user.home}/.local/share/JOSM/plugins">
[30896]436 <and>
437 <not><os family="windows"/></not>
438 <not><os family="mac"/></not>
439 </and>
440 </condition>
[26341]441 <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
442 </target>
443 <!--
[32052]444 ************************** Publishing the plugin ***********************************
[26341]445 -->
446 <!--
[32052]447 ** extracts the JOSM release for the JOSM version in ../core and saves it in the
[26341]448 ** property ${coreversion.info.entry.revision}
449 **
450 -->
451 <target name="core-info">
452 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
453 <env key="LANG" value="C"/>
454 <arg value="info"/>
455 <arg value="--xml"/>
456 <arg value="../../core"/>
457 </exec>
458 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
459 <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
460 <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
461 <delete file="core.info.xml"/>
462 </target>
463 <!--
464 ** commits the source tree for this plugin
465 -->
466 <target name="commit-current">
467 <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
468 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
469 <env key="LANG" value="C"/>
470 <arg value="commit"/>
[28400]471 <arg value="-m"/>
472 <arg value="${commit.message}"/>
[26341]473 <arg value="."/>
474 </exec>
475 </target>
476 <!--
477 ** updates (svn up) the source tree for this plugin
478 -->
479 <target name="update-current">
480 <echo>Updating plugin source ...</echo>
481 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
482 <env key="LANG" value="C"/>
483 <arg value="up"/>
484 <arg value="."/>
485 </exec>
486 <echo>Updating ${plugin.jar} ...</echo>
487 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
488 <env key="LANG" value="C"/>
489 <arg value="up"/>
[34224]490 <arg value="${plugin.jar}"/>
[26341]491 </exec>
492 </target>
493 <!--
[32052]494 ** commits the plugin.jar
[26341]495 -->
496 <target name="commit-dist">
497 <echo>
498 ***** Properties of published ${plugin.jar} *****
[27960]499 Commit message : '${commit.message}'
[26341]500 Plugin-Mainversion: ${plugin.main.version}
501 JOSM build version: ${coreversion.info.entry.revision}
502 Plugin-Version : ${version.entry.commit.revision}
[27960]503 ***** / Properties of published ${plugin.jar} *****
504
[35386]505 Now committing ${plugin.jar} ...
[26341]506 </echo>
507 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
508 <env key="LANG" value="C"/>
[28400]509 <arg value="-m"/>
510 <arg value="${commit.message}"/>
[26341]511 <arg value="commit"/>
512 <arg value="${plugin.jar}"/>
513 </exec>
514 </target>
515 <!-- ** make sure svn is present as a command line tool ** -->
516 <target name="ensure-svn-present">
517 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
518 <env key="LANG" value="C"/>
519 <arg value="--version"/>
520 </exec>
521 <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
522 <!-- return code not set at all? Most likely svn isn't installed -->
523 <condition>
524 <not>
525 <isset property="svn.exit.code"/>
526 </not>
527 </condition>
528 </fail>
529 <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
530 <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
531 <condition>
532 <isfailure code="${svn.exit.code}"/>
533 </condition>
534 </fail>
535 </target>
[28807]536
[26341]537 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
538 </target>
[31281]539
[30550]540 <macrodef name="init-test-preferences">
541 <sequential>
[32326]542 <copy file="../00_core_test_config/preferences.template.xml" tofile="../00_core_test_config/unit-josm.home/preferences.xml"/>
543 <replace file="../00_core_test_config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
544 <replace file="../00_core_test_config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
[30550]545 </sequential>
546 </macrodef>
[32306]547 <target name="check-test">
548 <available file="${plugin.test.dir}" type="dir" property="test.present"/>
549 </target>
[35443]550 <target name="test-init" depends="check-test" if="test.present" unless="skip-test">
[30550]551 <mkdir dir="${plugin.test.dir}/build"/>
552 <mkdir dir="${plugin.test.dir}/build/unit"/>
553 <mkdir dir="${plugin.test.dir}/report"/>
[30562]554 <init-test-preferences/>
[35413]555 <ivy:settings file="${josm.ivysettings}" id="ivy.core.settings"/>
[35463]556 <ivy:resolve settingsRef="ivy.core.settings" file="${josm.ivy}" conf="test,jacocoant"/>
[36282]557 <!-- The following ivy:retrieve calls are for IDEs without Ivy support; since we don't have sync=true, these may not have the "latest" versions -->
558 <!--
[35463]559 <ivy:retrieve settingsRef="ivy.core.settings" pattern="../00_core_test_lib/[artifact].[ext]" conf="test"/>
560 <ivy:retrieve settingsRef="ivy.core.settings" pattern="../00_core_tools/[conf].[ext]" conf="jacocoant"/>
[36282]561 -->
562 <ivy:cachepath settingsRef="ivy.core.settings" pathid=".local.test.classpath" conf="test" />
563 <ivy:cachepath settingsRef="ivy.core.settings" pathid="jacocotest.classpath" conf="test,jacocoant"/>
564 <ivy:cachepath settingsRef="ivy.core.settings" pathid="jmockit.classpath" file="${josm.ivy}" conf="jmockit" transitive="false"/>
565 <ivy:cachepath settingsRef="ivy.core.settings" pathid="jacocoant.classpath" file="${josm.ivy}" conf="jacocoant"/>
566 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="${toString:jacocoant.classpath}"/>
[35411]567 <path id="test.classpath">
568 <!-- JMockit must be included before JUnit in the classpath -->
[36282]569 <path refid="jmockit.classpath"/>
570 <path refid="jacocotest.classpath"/>
571 <path refid=".local.test.classpath"/>
[35411]572 <fileset dir="${plugin.test.dir}/lib" erroronmissingdir="no">
573 <include name="**/*.jar"/>
574 <exclude name="**/*-sources.jar"/>
575 <exclude name="**/*-javadoc.jar"/>
576 </fileset>
577 <fileset dir="lib" erroronmissingdir="no">
578 <include name="**/*.jar"/>
579 <exclude name="**/*-sources.jar"/>
580 <exclude name="**/*-javadoc.jar"/>
581 </fileset>
582 <pathelement path="${plugin.resources.dir}"/>
583 <pathelement path="${plugin.test.dir}/data"/>
584 <pathelement path="${josm.test.build.dir}/unit"/>
585 <pathelement path="${josm}"/>
586 <pathelement path="${plugin.jar}"/>
587 </path>
[30550]588 </target>
589 <target name="test-clean">
590 <delete dir="${plugin.test.dir}/build"/>
591 <delete dir="${plugin.test.dir}/report"/>
592 <delete file="${plugin.test.dir}/jacoco.exec" />
[32326]593 <delete file="../00_core_test_config/unit-josm.home/preferences.xml" />
594 <delete dir="../00_core_test_config/unit-josm.home/cache" failonerror="false"/>
[30550]595 </target>
[35443]596 <target name="test-compile" depends="test-init,dist" if="test.present" unless="skip-test">
[30550]597 <sequential>
[34364]598 <javac debug="on" includeantruntime="false" srcdir="${plugin.test.dir}/unit" destdir="${plugin.test.dir}/build/unit" encoding="UTF-8"
[35765]599 release="${java.lang.version}">
[30550]600 <classpath>
[30747]601 <fileset refid="plugin.requires.jars"/>
[30562]602 <path refid="test.classpath"/>
[30550]603 </classpath>
[34703]604 <compilerarg value="-Xlint:all"/>
605 <compilerarg value="-Xlint:-serial"/>
[32926]606 </javac>
[30550]607 </sequential>
608 </target>
[35443]609 <target name="test" depends="dist, test-clean, test-compile" if="test.present" unless="skip-test"
[30747]610 description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
[30550]611 <sequential>
[30562]612 <echo message="Running unit tests with JUnit"/>
[36168]613 <jacoco:agent destfile="${plugin.test.dir}/jacoco.exec" enabled="${coverageByDefault}"
614 inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}"
615 property="jacocoagent" if:true="${coverageByDefault}"/>
[35714]616 <junitlauncher printsummary="${junit.printsummary}">
[35642]617 <classpath>
618 <fileset refid="plugin.requires.jars"/>
619 <path refid="test.classpath"/>
620 <pathelement path="${plugin.test.dir}/build/unit"/>
621 </classpath>
622 <testclasses outputDir="${plugin.test.dir}/report">
623 <fileset dir="${plugin.test.dir}/build/unit" includes="**/*Test.class"/>
[35963]624 <fork>
[35642]625 <jvmarg value="${jacocoagent}" if:set="jacocoagent" />
626 <jvmarg value="-Dfile.encoding=UTF-8"/>
[36282]627 <jvmarg value="-javaagent:${toString:jmockit.classpath}"/>
[35963]628 <jvmarg value="-Djunit.jupiter.extensions.autodetection.enabled=true"/>
629 <jvmarg value="-Djunit.jupiter.execution.parallel.enabled=true"/>
[36308]630 <jvmarg value="--add-opens" />
631 <jvmarg value="java.base/java.lang.reflect=ALL-UNNAMED" />
632 <jvmarg value="--add-opens" />
633 <jvmarg value="java.desktop/javax.imageio.spi=ALL-UNNAMED" />
634 <jvmarg value="--add-exports" />
635 <jvmarg value="java.desktop/com.sun.imageio.spi=ALL-UNNAMED" />
[35714]636 <jvmarg value="-XX:+ShowCodeDetailsInExceptionMessages" if:set="isJava14" unless:set="isJava15" />
[35642]637 <sysproperty key="josm.home" value="../00_core_test_config/unit-josm.home"/>
638 <sysproperty key="josm.test.data" value="${plugin.test.dir}/data"/>
639 <sysproperty key="java.awt.headless" value="true"/>
640 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
[35963]641 <sysproperty key="junit.jupiter.execution.parallel.enabled" value="${junit.jupiter.execution.parallel.enabled}" if:set="junit.jupiter.execution.parallel.enabled"/>
642 <sysproperty key="junit.jupiter.execution.parallel.mode.default" value="${junit.jupiter.execution.parallel.mode.default}" if:set="junit.jupiter.execution.parallel.mode.default"/>
643 <sysproperty key="junit.jupiter.execution.parallel.mode.classes.default" value="${junit.jupiter.execution.parallel.mode.classes.default}" if:set="junit.jupiter.execution.parallel.mode.classes.default"/>
644 </fork>
[35642]645 <listener type="legacy-plain" />
646 <listener type="legacy-xml" />
647 </testclasses>
648 </junitlauncher>
[30550]649 </sequential>
[30562]650 </target>
[31281]651
[36208]652 <target name="checkstyle" depends="resolve-tools">
[35379]653 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
654 <classpath refid="checkstyle.classpath"/>
655 </taskdef>
[34378]656 <checkstyle config="${basedir}/../checkstyle-config.xml">
[33061]657 <fileset dir="${basedir}/src" includes="**/*.java" excludes="boofcv/**/*.java,
658 com/google/**/*.java,
[32317]659 crosby/**/*.java,
660 edu/princeton/**/*.java,
661 net/boplicity/**/*.java,
662 org/apache/**/*.java,
663 org/dinopolis/**/*.java,
664 org/kaintoch/**/*.java,
665 org/marvinproject/**/*.java,
666 org/netbeans/**/*.java,
[34703]667 org/openstreetmap/josm/plugins/dataimport/io/tcx/**/*.java,
668 org/openstreetmap/josm/plugins/ohe/parser/**/*.java,
669 org/openstreetmap/josm/plugins/pdfimport/pdfbox/operators/**/*.java
670 org/openstreetmap/josm/plugins/roadsigns/javacc/**/*.java,
[32765]671 org/osgeo/**/*.java,
[34703]672 "/>
[32310]673 <fileset dir="${basedir}/test" includes="**/*.java" erroronmissingdir="false"/>
[36315]674 <formatter type="plain"/>
[32310]675 <formatter type="xml" toFile="checkstyle-josm-${ant.project.name}.xml"/>
676 </checkstyle>
677 </target>
678
[35389]679 <target name="spotbugs" depends="compile,resolve-tools">
[35377]680 <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${toString:spotbugs.classpath}"/>
[33591]681 <spotbugs output="xml"
682 outputFile="spotbugs-josm-${ant.project.name}.xml"
[35377]683 classpath="${toString:spotbugs.classpath}"
[32310]684 pluginList=""
[33591]685 excludeFilter="../spotbugs-filter.xml"
[34039]686 effort="less"
[32310]687 reportLevel="low"
[34463]688 nested="false"
[34462]689 jvmargs="-Xmx1024m"
[32310]690 >
[36315]691 <auxClasspath refid="plugin.classpath" unless:set="plugin.classpath.dependencies"/>
692 <auxClasspath refid="plugin.classpath.dependencies" if:set="plugin.classpath.dependencies"/>
[32310]693 <sourcePath path="${basedir}/src" />
[33932]694 <class location="${plugin.build.dir}" />
[33591]695 </spotbugs>
[32310]696 </target>
697
[28807]698 <target name="runjosm" depends="install">
[32311]699 <java jar="${josm}" fork="true"/>
[28807]700 </target>
701
702 <target name="profilejosm" depends="install">
703 <nbprofiledirect>
704 </nbprofiledirect>
705 <java jar="${josm}" fork="true">
706 <jvmarg value="${profiler.info.jvmargs.agent}"/>
707 </java>
708 </target>
[29004]709 <!--
[32052]710 ** shows a help text
[29004]711 -->
712 <target name="help">
713 <echo>
714 You can use following targets:
715 * dist This default target builds the plugin jar file
[35387]716 * clean Cleanup automatically created files
[31281]717 * test Run unit tests (if any)
[29004]718 * publish Checkin source code, build jar and checkin plugin jar
719 (requires proper entry for SVN commit message!)
720 * install Install the plugin in current system
721 * runjosm Install plugin and start josm
722 * profilejosm Install plugin and start josm in profiling mode
[32052]723
[29004]724 There are other targets, which usually should not be called manually.
725 </echo>
726 </target>
[34581]727 <!--
728 ** Ivy tasks
729 -->
[36315]730 <target name="is-ivy">
731 <condition property="isIvy">
732 <available file="ivy.xml"/>
733 </condition>
734 </target>
[34581]735 <target name="download-ivy">
736 <mkdir dir="${ivy.jar.dir}"/>
[35390]737 <get src="https://josm.openstreetmap.de/nexus/content/repositories/public/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
738 dest="${ivy.jar.file}"
739 usetimestamp="true"/>
[34581]740 </target>
741 <target name="init-ivy" depends="download-ivy">
742 <path id="ivy.lib.path">
743 <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
744 </path>
745 <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
746 </target>
[35389]747 <target name="resolve-tools" depends="init-ivy" description="Resolves tools using Apache Ivy">
[36173]748 <ivy:settings file="${josm.ivysettings}"/>
[35389]749 <ivy:resolve file="${core.tools.ivy}"/>
[35489]750 <ivy:cachepath file="${core.tools.ivy}" pathid="errorprone.classpath" conf="errorprone"/>
751 <ivy:cachepath file="${core.tools.ivy}" pathid="errorprone_javac.classpath" conf="errorprone_javac"/>
[35389]752 <ivy:cachepath file="${core.tools.ivy}" pathid="checkstyle.classpath" conf="checkstyle"/>
753 <ivy:cachepath file="${core.tools.ivy}" pathid="spotbugs.classpath" conf="spotbugs"/>
754 </target>
[34703]755 <target name="clean_ivy">
756 <delete failonerror="false">
757 <fileset dir="${plugin.lib.dir}">
758 <include name="**/*.jar"/>
759 <exclude name="**/*-custom.jar" />
760 </fileset>
761 </delete>
762 </target>
[36315]763 <target name="fetch-dependencies-ivy" depends="clean_ivy, init-ivy, is-ivy" if="isIvy">
[34703]764 <echo>fetching dependencies with ivy</echo>
[35766]765 <available property="plugin.ivysettings.exists" file="ivy_settings.xml"/>
766 <ivy:settings file="ivy_settings.xml" if:set="plugin.ivysettings.exists"/>
767 <ivy:settings file="${josm.ivysettings}" unless:set="plugin.ivysettings.exists"/>
[35463]768 <ivy:resolve />
[34703]769 <ivy:retrieve pattern="${plugin.lib.dir}/[artifact]-[revision](-[classifier]).[ext]" conf="default" />
770 </target>
[36315]771 <target name="ivy-checkdepsupdate" description="Display dependency updates on the console" depends="fetch-dependencies-ivy">
[35878]772 <ivy:checkdepsupdate/>
773 </target>
[36315]774 <!--
775 ** Maven tasks
776 -->
777 <target name="is-maven" depends="is-ivy">
778 <condition property="isMaven">
779 <and>
780 <available file="pom.xml"/>
781 <not>
782 <isset property="isIvy"/>
783 </not>
784 </and>
785 </condition>
786 </target>
787 <target name="download-maven" depends="is-maven" if="isMaven">
788 <mkdir dir="${maven.artifact.resolver.parent.dir}"/>
789 <get src="https://josm.openstreetmap.de/nexus/content/repositories/public/org/apache/maven/resolver/maven-resolver-ant-tasks/${maven.artifact.resolver.version}/maven-resolver-ant-tasks-${maven.artifact.resolver.version}-uber.jar"
790 dest="${maven.artifact.resolver.jar.file}"
791 usetimestamp="true"/>
792 </target>
793 <target name="init-maven" depends="is-maven,download-maven" if="isMaven">
794 <path id="maven.lib.path">
795 <fileset dir="${maven.artifact.resolver.parent.dir}" includes="*.jar"/>
796 </path>
797 <taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml" classpathref="maven.lib.path"/>
798 </target>
799 <target name="fetch-dependencies-maven" depends="is-maven,init-maven,clean_ivy" if="isMaven">
800 <mvn:pom file="pom.xml"/>
801 <mvn:pom file="pom.xml" id="pom"/>
802 <!-- This stanza is necessary since the maven resolver doesn't read repo settings from the pom.xml file -->
803 <!-- resolver.repositories makes it global -->
804 <mvn:remoterepos id="resolver.repositories">
805 <mvn:remoterepo id="JOSM" url="https://josm.openstreetmap.de/nexus/content/repositories/public/" />
[36325]806 <mvn:remoterepo id="JOSM-snapshots" url="https://josm.openstreetmap.de/nexus/content/repositories/snapshots/" snapshots="true" />
[36315]807 </mvn:remoterepos>
808 <mkdir dir="${plugin.lib.dir}"/>
809 <mvn:resolve>
810 <!-- For some reason, compile time josm-unittest dependencies get included -->
811 <mvn:dependencies pomRef="pom">
812 <mvn:exclusion groupId="org.openstreetmap.josm" artifactId="josm-unittest"/>
813 <mvn:exclusion groupId="org.junit.platform"/>
814 <mvn:exclusion groupId="org.junit.vintage"/>
815 <mvn:exclusion groupId="org.junit.jupiter"/>
816 </mvn:dependencies>
817 <mvn:files refid="lib.files" dir="${plugin.lib.dir}" layout="{artifactId}-{version}-{classifier}.{extension}" scopes="compile,!test"/>
818 </mvn:resolve>
819 <mvn:resolve>
820 <mvn:path refid="classpath.provided" scopes="provided"/>
821 </mvn:resolve>
822 <mvn:resolve>
823 <mvn:path refid="testlib.classpath" classpath="test"/>
824 </mvn:resolve>
825 <mvn:resolve>
826 <mvn:dependencies>
827 <mvn:dependency groupId="org.jacoco" artifactId="org.jacoco.ant" version="${pom.properties.jacoco.version}" classifier="nodeps" type="jar" scope="test"/>
828 </mvn:dependencies>
829 <mvn:path refid="jacocotest.classpath" classpath="test"/>
830 </mvn:resolve>
831 <mvn:resolve>
832 <mvn:dependencies>
833 <mvn:dependency groupId="com.puppycrawl.tools" artifactId="checkstyle" version="${pom.properties.checkstyle.version}" scope="compile"/>
834 </mvn:dependencies>
835 <mvn:path refid="checkstyle.classpath" classpath="compile"/>
836 </mvn:resolve>
837 <mvn:resolve>
838 <mvn:dependencies>
839 <mvn:dependency groupId="com.github.spotbugs" artifactId="spotbugs" version="${pom.properties.spotbugs.version}" scope="compile"/>
840 <mvn:dependency groupId="com.github.spotbugs" artifactId="spotbugs-ant" version="${pom.properties.spotbugs.version}" scope="compile"/>
841 </mvn:dependencies>
842 <mvn:path refid="spotbugs.classpath" classpath="compile"/>
843 </mvn:resolve>
[36325]844 <condition property="classpath.provided.present">
845 <isreference refid="classpath.provided" type="path"/>
846 </condition>
847 <path id="plugin.classpath.actual" unless:set="classpath.provided.present">
[36315]848 <path refid="plugin.classpath"/>
[36325]849 </path>
850 <path id="plugin.classpath.actual" if:set="classpath.provided.present">
851 <path refid="plugin.classpath"/>
[36315]852 <path refid="classpath.provided"/>
853 </path>
854 </target>
855
856 <target name="fetch_dependencies" depends="fetch-dependencies-ivy,fetch-dependencies-maven">
857 <!-- We can depend upon ivy and/or maven right now. -->
858 </target>
[26341]859</project>
Note: See TracBrowser for help on using the repository browser.