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

Last change on this file since 35711 was 35711, checked in by Don-vip, 3 years ago

see #19724 - add Java 16 workaround suggested by Error Prone developers

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