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

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

refactoring

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