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

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

add missing error_prone dependencies

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