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

Last change on this file since 34589 was 34581, checked in by donvip, 8 years ago

fix Ivy build of StreetSide (conflicts with build of wikipedia plugin hosted on GitHub)

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