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

Last change on this file since 35929 was 35923, checked in by stoecker, 3 years ago

proper plugins dir

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