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