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

Last change on this file since 35384 was 35380, checked in by simon04, 5 years ago

Remove 00_core_tools/guava.jar

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