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

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

see #josm15560, see #josm16047 - fix javac.compiler definition

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