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

Last change on this file was 36208, checked in by taylor.smock, 2 months ago

Fix #23465: Remove custom checkstyle plugin

TopLevelJavadocCheck.java is duplicating functionality from MissingJavadocType.
Our custom class is from #14794 (closed 2017-10-16). The check that makes it
redundant was added in checkstyle 8.20 (released 2019-04-28).

This adds the missing javadocs for the more comprehensive checkstyle version.

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