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

Last change on this file since 36175 was 36173, checked in by taylor.smock, 2 years ago

See #23218: Use newer error_prone versions when compiling on java 11+

This should allow us to compile all plugins with Java 21 (specifically OpenData).

OpenData has some additional changes, since some of the new error_prone checks
blocked compilation.

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