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

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

allow to specify javadoc link

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