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

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

see #josm16912 - fix manifest

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