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

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

fix checkstyle config

File size: 31.3 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 sourcepath="${plugin.src.dir}"
239 encoding="UTF-8"
240 windowtitle="JOSM-${ant.project.name}"
241 use="true"
242 private="true"
243 linksource="true"
244 author="false">
245 <classpath refid="plugin.classpath"/>
246 <link href="https://docs.oracle.com/javase/8/docs/api"/>
247 <link href="https://josm.openstreetmap.de/doc"/>
248 <doctitle><![CDATA[<h2>JOSM-${ant.project.name} - Javadoc</h2>]]></doctitle>
249 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/wiki/Plugins">JOSM Plugins</a>]]></bottom>
250 <arg value="-html5" if:set="isJava9" />
251 <arg value="--add-modules" if:set="isJava9" unless:set="isJava11" />
252 <arg value="java.activation,java.se.ee" if:set="isJava9" unless:set="isJava11" />
253 <arg value="--add-exports" if:set="isJava9" unless:set="noJavaFX" />
254 <arg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" unless:set="noJavaFX" />
255 </javadoc>
256 </target>
257 <!--
258 **********************************************************
259 ** revision - extracts the current revision number for the
260 ** file build.number and stores it in the XML property
261 ** version.*
262 **********************************************************
263 -->
264 <!--
265 ** Initializes the REVISION.XML file from SVN information
266 -->
267 <target name="init-svn-revision-xml" unless="skip-revision">
268 <exec append="false" output="REVISION.XML" executable="svn" failifexecutionfails="false" resultproperty="svn.info.result">
269 <env key="LANG" value="C"/>
270 <arg value="info"/>
271 <arg value="--xml"/>
272 <arg value="."/>
273 </exec>
274 <condition property="svn.info.fail">
275 <not>
276 <and>
277 <equals arg1="${svn.info.result}" arg2="0" />
278 <length file="REVISION.XML" when="greater" length="1" />
279 </and>
280 </not>
281 </condition>
282 </target>
283 <!--
284 ** Initializes the REVISION.XML file from git-svn information.
285 Obtains the revision from the git-svn-id field.
286 -->
287 <target name="init-git-svn-revision-xml" if="svn.info.fail" unless="skip-revision">
288 <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.svn.info.result">
289 <arg value="log"/>
290 <arg value="-1"/>
291 <arg value="--grep=git-svn-id"/>
292 <!--
293 %B: raw body (unwrapped subject and body)
294 %n: new line
295 %ai: author date, ISO 8601 format
296 -->
297 <arg value="--pretty=format:%B%n%ai"/>
298 <arg value="."/>
299 </exec>
300 <replaceregexp file="REVISION.XML" flags="s"
301 match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
302 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;"/>
303 <condition property="git.svn.fail">
304 <not>
305 <and>
306 <equals arg1="${git.svn.info.result}" arg2="0" />
307 <length file="REVISION.XML" when="greater" length="1" />
308 </and>
309 </not>
310 </condition>
311 </target>
312 <!--
313 ** Initializes the REVISION.XML file from git (w/o svn) information.
314 Uses Unix date as revision number.
315 -->
316 <target name="init-git-revision-xml" if="git.svn.fail" unless="skip-revision">
317 <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.info.result">
318 <arg value="log"/>
319 <arg value="-1"/>
320 <arg value="--pretty=format:%at%n%ai"/>
321 <arg value="."/>
322 </exec>
323 <replaceregexp file="REVISION.XML" flags="s"
324 match="\s*(\d*)\s+(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
325 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;"/>
326 <condition property="git.fail">
327 <not>
328 <and>
329 <equals arg1="${git.info.result}" arg2="0" />
330 <length file="REVISION.XML" when="greater" length="1" />
331 </and>
332 </not>
333 </condition>
334 </target>
335 <target name="init-revision-fallback" if="git.fail" unless="skip-revision">
336 <tstamp>
337 <format property="current.time" pattern="yyyy-MM-dd'T'HH:mm:ss.SSS" />
338 </tstamp>
339 <echo file="REVISION.XML"><![CDATA[<info><entry><commit revision="UNKNOWN"><date>${current.time}</date></commit></entry></info>]]></echo>
340 </target>
341 <target name="revision" depends="init-svn-revision-xml, init-git-svn-revision-xml, init-git-revision-xml, init-revision-fallback" unless="skip-revision">
342 <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
343 <delete file="REVISION.XML"/>
344 </target>
345 <!--
346 **********************************************************
347 ** clean - clean up the build environment
348 **********************************************************
349 -->
350 <target name="clean">
351 <delete dir="${plugin.build.dir}"/>
352 <delete dir="${plugin.doc.dir}"/>
353 <delete dir="${checkstyle-build.dir}"/>
354 <delete file="${plugin.jar}"/>
355 <delete file="${plugin.sources.jar}"/>
356 <delete file="${plugin.javadoc.jar}"/>
357 </target>
358 <!--
359 **********************************************************
360 ** install - install the plugin in your local JOSM installation
361 **********************************************************
362 -->
363 <target name="install" depends="dist">
364 <property environment="env"/>
365 <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins">
366 <and>
367 <os family="windows"/>
368 </and>
369 </condition>
370 <condition property="josm.plugins.dir" value="${user.home}/Library/JOSM/plugins">
371 <and>
372 <os family="mac"/>
373 </and>
374 </condition>
375 <condition property="josm.plugins.dir" value="${user.home}/.josm/plugins">
376 <and>
377 <not><os family="windows"/></not>
378 <not><os family="mac"/></not>
379 </and>
380 </condition>
381 <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
382 </target>
383 <!--
384 ************************** Publishing the plugin ***********************************
385 -->
386 <!--
387 ** extracts the JOSM release for the JOSM version in ../core and saves it in the
388 ** property ${coreversion.info.entry.revision}
389 **
390 -->
391 <target name="core-info">
392 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
393 <env key="LANG" value="C"/>
394 <arg value="info"/>
395 <arg value="--xml"/>
396 <arg value="../../core"/>
397 </exec>
398 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
399 <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
400 <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
401 <delete file="core.info.xml"/>
402 </target>
403 <!--
404 ** commits the source tree for this plugin
405 -->
406 <target name="commit-current">
407 <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
408 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
409 <env key="LANG" value="C"/>
410 <arg value="commit"/>
411 <arg value="-m"/>
412 <arg value="${commit.message}"/>
413 <arg value="."/>
414 </exec>
415 </target>
416 <!--
417 ** updates (svn up) the source tree for this plugin
418 -->
419 <target name="update-current">
420 <echo>Updating plugin source ...</echo>
421 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
422 <env key="LANG" value="C"/>
423 <arg value="up"/>
424 <arg value="."/>
425 </exec>
426 <echo>Updating ${plugin.jar} ...</echo>
427 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
428 <env key="LANG" value="C"/>
429 <arg value="up"/>
430 <arg value="${plugin.jar}"/>
431 </exec>
432 </target>
433 <!--
434 ** commits the plugin.jar
435 -->
436 <target name="commit-dist">
437 <echo>
438 ***** Properties of published ${plugin.jar} *****
439 Commit message : '${commit.message}'
440 Plugin-Mainversion: ${plugin.main.version}
441 JOSM build version: ${coreversion.info.entry.revision}
442 Plugin-Version : ${version.entry.commit.revision}
443 ***** / Properties of published ${plugin.jar} *****
444
445 Now commiting ${plugin.jar} ...
446 </echo>
447 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
448 <env key="LANG" value="C"/>
449 <arg value="-m"/>
450 <arg value="${commit.message}"/>
451 <arg value="commit"/>
452 <arg value="${plugin.jar}"/>
453 </exec>
454 </target>
455 <!-- ** make sure svn is present as a command line tool ** -->
456 <target name="ensure-svn-present">
457 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
458 <env key="LANG" value="C"/>
459 <arg value="--version"/>
460 </exec>
461 <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
462 <!-- return code not set at all? Most likely svn isn't installed -->
463 <condition>
464 <not>
465 <isset property="svn.exit.code"/>
466 </not>
467 </condition>
468 </fail>
469 <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
470 <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
471 <condition>
472 <isfailure code="${svn.exit.code}"/>
473 </condition>
474 </fail>
475 </target>
476
477 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
478 </target>
479
480 <path id="test.classpath">
481 <fileset dir="../00_core_test_lib">
482 <include name="**/*.jar"/>
483 </fileset>
484 <fileset dir="${plugin.test.dir}/lib" erroronmissingdir="no">
485 <include name="**/*.jar"/>
486 <exclude name="**/*-sources.jar"/>
487 <exclude name="**/*-javadoc.jar"/>
488 </fileset>
489 <fileset dir="lib" erroronmissingdir="no">
490 <include name="**/*.jar"/>
491 <exclude name="**/*-sources.jar"/>
492 <exclude name="**/*-javadoc.jar"/>
493 </fileset>
494 <pathelement path="${plugin.test.dir}/data"/>
495 <pathelement path="${josm.test.build.dir}/unit"/>
496 <pathelement path="${josm}"/>
497 <pathelement path="${plugin.jar}"/>
498 <pathelement path="${annotations.jar}"/>
499 </path>
500 <macrodef name="init-test-preferences">
501 <sequential>
502 <copy file="../00_core_test_config/preferences.template.xml" tofile="../00_core_test_config/unit-josm.home/preferences.xml"/>
503 <replace file="../00_core_test_config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
504 <replace file="../00_core_test_config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
505 </sequential>
506 </macrodef>
507 <target name="check-test">
508 <available file="${plugin.test.dir}" type="dir" property="test.present"/>
509 </target>
510 <target name="test-init" depends="check-test" if="test.present">
511 <mkdir dir="${plugin.test.dir}/build"/>
512 <mkdir dir="${plugin.test.dir}/build/unit"/>
513 <mkdir dir="${plugin.test.dir}/report"/>
514 <init-test-preferences/>
515 </target>
516 <target name="test-clean">
517 <delete dir="${plugin.test.dir}/build"/>
518 <delete dir="${plugin.test.dir}/report"/>
519 <delete file="${plugin.test.dir}/jacoco.exec" />
520 <delete file="../00_core_test_config/unit-josm.home/preferences.xml" />
521 <delete dir="../00_core_test_config/unit-josm.home/cache" failonerror="false"/>
522 </target>
523 <target name="test-compile" depends="test-init,dist" if="test.present">
524 <sequential>
525 <javac debug="on" includeantruntime="false" srcdir="${plugin.test.dir}/unit" destdir="${plugin.test.dir}/build/unit" encoding="UTF-8"
526 target="${java.lang.version}" source="${java.lang.version}">
527 <classpath>
528 <fileset refid="plugin.requires.jars"/>
529 <path refid="test.classpath"/>
530 </classpath>
531 <compilerarg value="-Xlint:all"/>
532 <compilerarg value="-Xlint:-serial"/>
533 </javac>
534 </sequential>
535 </target>
536 <target name="test" depends="dist, test-clean, test-compile" if="test.present"
537 description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
538 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="../00_core_tools/jacocoant.jar" />
539 <sequential>
540 <echo message="Running unit tests with JUnit"/>
541 <jacoco:coverage destfile="${plugin.test.dir}/jacoco.exec" enabled="${coverageByDefault}">
542 <junit printsummary="yes" fork="true" forkmode="once" dir="${basedir}">
543 <jvmarg value="-Dfile.encoding=UTF-8"/>
544 <jvmarg value="--add-modules" if:set="isJava9" unless:set="isJava11" />
545 <jvmarg value="java.activation,java.se.ee" if:set="isJava9" unless:set="isJava11" />
546 <jvmarg value="--add-opens" if:set="isJava9" />
547 <jvmarg value="java.base/java.lang.reflect=ALL-UNNAMED" if:set="isJava9" />
548 <jvmarg value="--add-opens" if:set="isJava9" />
549 <jvmarg value="java.desktop/javax.imageio.spi=ALL-UNNAMED" if:set="isJava9" />
550 <jvmarg value="--add-exports" if:set="isJava9" />
551 <jvmarg value="java.desktop/com.sun.imageio.spi=ALL-UNNAMED" if:set="isJava9" />
552 <sysproperty key="josm.home" value="../00_core_test_config/unit-josm.home"/>
553 <sysproperty key="josm.test.data" value="${plugin.test.dir}/data"/>
554 <sysproperty key="java.awt.headless" value="true"/>
555 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
556 <classpath>
557 <fileset refid="plugin.requires.jars"/>
558 <path refid="test.classpath"/>
559 <pathelement path="${plugin.test.dir}/build/unit"/>
560 </classpath>
561 <formatter type="plain"/>
562 <formatter type="xml"/>
563 <batchtest fork="yes" todir="${plugin.test.dir}/report">
564 <fileset dir="${plugin.test.dir}/build/unit" includes="**/*Test.class"/>
565 </batchtest>
566 </junit>
567 </jacoco:coverage>
568 </sequential>
569 </target>
570
571 <target name="checkstyle-compile">
572 <mkdir dir="${checkstyle-build.dir}"/>
573 <javac sourcepath="" srcdir="../00_core_tools/checkstyle/src" failonerror="true"
574 destdir="${checkstyle-build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on"
575 includeantruntime="false" createMissingPackageInfoClass="false"
576 encoding="UTF-8" classpath="${checkstyle.jar}">
577 </javac>
578 </target>
579 <target name="checkstyle" depends="checkstyle-compile">
580 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpath="${checkstyle.jar}:${checkstyle-build.dir}"/>
581 <checkstyle config="${basedir}/../checkstyle-config.xml">
582 <fileset dir="${basedir}/src" includes="**/*.java" excludes="boofcv/**/*.java,
583 com/google/**/*.java,
584 crosby/**/*.java,
585 edu/princeton/**/*.java,
586 net/boplicity/**/*.java,
587 org/apache/**/*.java,
588 org/dinopolis/**/*.java,
589 org/kaintoch/**/*.java,
590 org/marvinproject/**/*.java,
591 org/netbeans/**/*.java,
592 org/openstreetmap/josm/plugins/dataimport/io/tcx/**/*.java,
593 org/openstreetmap/josm/plugins/ohe/parser/**/*.java,
594 org/openstreetmap/josm/plugins/roadsigns/javacc/**/*.java,
595 org/osgeo/**/*.java,
596 pdfimport/pdfbox/operators/**/*.java
597 "/>
598 <fileset dir="${basedir}/test" includes="**/*.java" erroronmissingdir="false"/>
599 <formatter type="xml" toFile="checkstyle-josm-${ant.project.name}.xml"/>
600 </checkstyle>
601 </target>
602
603 <target name="spotbugs" depends="compile">
604 <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${spotbugs-ant.jar}"/>
605 <path id="spotbugs-classpath">
606 <fileset dir="../00_core_tools/spotbugs/">
607 <include name="*.jar"/>
608 </fileset>
609 </path>
610 <property name="spotbugs-classpath" refid="spotbugs-classpath"/>
611 <spotbugs output="xml"
612 outputFile="spotbugs-josm-${ant.project.name}.xml"
613 classpath="${spotbugs-classpath}"
614 pluginList=""
615 excludeFilter="../spotbugs-filter.xml"
616 effort="less"
617 reportLevel="low"
618 jvmargs="-Xmx3072m"
619 >
620 <auxClasspath refid="plugin.classpath" />
621 <sourcePath path="${basedir}/src" />
622 <class location="${plugin.build.dir}" />
623 </spotbugs>
624 </target>
625
626 <target name="runjosm" depends="install">
627 <java jar="${josm}" fork="true"/>
628 </target>
629
630 <target name="profilejosm" depends="install">
631 <nbprofiledirect>
632 </nbprofiledirect>
633 <java jar="${josm}" fork="true">
634 <jvmarg value="${profiler.info.jvmargs.agent}"/>
635 </java>
636 </target>
637 <!--
638 ** shows a help text
639 -->
640 <target name="help">
641 <echo>
642 You can use following targets:
643 * dist This default target builds the plugin jar file
644 * clean Cleanup automatical created files
645 * test Run unit tests (if any)
646 * publish Checkin source code, build jar and checkin plugin jar
647 (requires proper entry for SVN commit message!)
648 * install Install the plugin in current system
649 * runjosm Install plugin and start josm
650 * profilejosm Install plugin and start josm in profiling mode
651
652 There are other targets, which usually should not be called manually.
653 </echo>
654 </target>
655</project>
Note: See TracBrowser for help on using the repository browser.