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

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

fix Ivy build of StreetSide (conflicts with build of wikipedia plugin hosted on GitHub)

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