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

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

see #josm15560, see #josm16047 - include JAXB, removed in JDK11

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