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

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

Fix build issues for Java 17+

It still fails to build with Java 11 -- errorprone needs to be an older version
for Java 11, and I suspect the ant maven library is not calculating the right
profiles.

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