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