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

Last change on this file since 36181 was 36176, checked in by taylor.smock, 15 months ago

Fix error_prone version issue and dependency updates (see #23218)

Plugins with an ivy_settings.xml file were not reading the error_prone version
from the core ivysettings.xml file. This removes redundant ivy_settings.xml files
and includes the core ivysettings.xml file in the remaining ivy_settings.xml
files.

Dependency updates:
apache-commons:

  • zstd-jni: 1.5.2-5 -> 1.5.5-6
  • commons-compress: 1.22 -> 1.24.0
  • commons-io: 2.11.0 -> 2.14.0
  • commons-lang3: 3.12.0 -> 3.13.0

apache-http:

  • httpclient5: 5.1.2 -> 5.2.1
  • Drops legacy httpcore, httpclient, and httpmime dependencies

ejml: 0.41 -> 0.43.1

  • ejml now requires Java 11

flatlaf: 3.2 -> 3.2.2
geotools: 28.2 -> 30.0

  • geotools now requires Java 11
  • 30.0 had some breaking API changes, but provided a migration script

jackson: 2.14.0 -> 2.15.3
jna: 5.12.1 -> 5.13.0
log4j: 2.19.0 -> 2.21.0
lwjgl: 3.3.1 -> 3.3.3
pbf:

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