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

Last change on this file since 36312 was 36308, checked in by stoecker, 5 months ago

drop java 8 and 9

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