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