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