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

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

tools update

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