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

Last change on this file since 36164 was 36151, checked in by taylor.smock, 16 months ago

Fix #8647: Add Garmin FIT parsing (as a plugin)

Documentation/files used for implementation:

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