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

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

define ivy tasks for all plugins

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