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