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

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

see #josm16682 - new property Plugin-Minimum-Java-Version for openjfx plugin

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