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

Last change on this file since 34401 was 34387, checked in by donvip, 7 years ago

fix javadoc target

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