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

Last change on this file since 35543 was 35489, checked in by simon04, 5 years ago

see #josm19334 - resolve error_prone using Ivy

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