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

Last change on this file since 34624 was 34620, checked in by donvip, 6 years ago

see #josm16498 - update build for Java 12

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