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.19.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 | <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 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><equals arg1="${svn.info.result}" arg2="0" /></not>
|
---|
228 | </condition>
|
---|
229 | </target>
|
---|
230 | <!--
|
---|
231 | ** Initializes the REVISION.XML file from git-svn information.
|
---|
232 | Obtains the revision from the git-svn-id field.
|
---|
233 | -->
|
---|
234 | <target name="init-git-svn-revision-xml" if="svn.info.fail" unless="skip-revision">
|
---|
235 | <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.svn.info.result">
|
---|
236 | <arg value="log"/>
|
---|
237 | <arg value="-1"/>
|
---|
238 | <arg value="--grep=git-svn-id"/>
|
---|
239 | <!--
|
---|
240 | %B: raw body (unwrapped subject and body)
|
---|
241 | %n: new line
|
---|
242 | %ai: author date, ISO 8601 format
|
---|
243 | -->
|
---|
244 | <arg value="--pretty=format:%B%n%ai"/>
|
---|
245 | <arg value="."/>
|
---|
246 | </exec>
|
---|
247 | <replaceregexp file="REVISION.XML" flags="s"
|
---|
248 | match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
|
---|
249 | replace="<info><entry><commit revision="\1"><date>\2</date></commit></entry></info>"/>
|
---|
250 | <condition property="git.svn.fail">
|
---|
251 | <not>
|
---|
252 | <and>
|
---|
253 | <equals arg1="${git.svn.info.result}" arg2="0" />
|
---|
254 | <length file="REVISION.XML" when="greater" length="1" />
|
---|
255 | </and>
|
---|
256 | </not>
|
---|
257 | </condition>
|
---|
258 | </target>
|
---|
259 | <!--
|
---|
260 | ** Initializes the REVISION.XML file from git (w/o svn) information.
|
---|
261 | Uses Unix date as revision number.
|
---|
262 | -->
|
---|
263 | <target name="init-git-revision-xml" if="git.svn.fail" unless="skip-revision">
|
---|
264 | <exec append="false" output="REVISION.XML" executable="git" failifexecutionfails="false" resultproperty="git.info.result">
|
---|
265 | <arg value="log"/>
|
---|
266 | <arg value="-1"/>
|
---|
267 | <arg value="--pretty=format:%at%n%ai"/>
|
---|
268 | <arg value="."/>
|
---|
269 | </exec>
|
---|
270 | <replaceregexp file="REVISION.XML" flags="s"
|
---|
271 | match="\s*(\d*)\s+(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
|
---|
272 | replace="<info><entry><commit revision="\1"><date>\2</date></commit></entry></info>"/>
|
---|
273 | <condition property="git.fail">
|
---|
274 | <not>
|
---|
275 | <and>
|
---|
276 | <equals arg1="${git.info.result}" arg2="0" />
|
---|
277 | <length file="REVISION.XML" when="greater" length="1" />
|
---|
278 | </and>
|
---|
279 | </not>
|
---|
280 | </condition>
|
---|
281 | </target>
|
---|
282 | <target name="init-revision-fallback" if="git.fail" unless="skip-revision">
|
---|
283 | <tstamp>
|
---|
284 | <format property="current.time" pattern="yyyy-MM-dd'T'HH:mm:ss.SSS" />
|
---|
285 | </tstamp>
|
---|
286 | <echo file="REVISION.XML"><![CDATA[<info><entry><commit revision="UNKNOWN"><date>${current.time}</date></commit></entry></info>]]></echo>
|
---|
287 | </target>
|
---|
288 | <target name="revision" depends="init-svn-revision-xml, init-git-svn-revision-xml, init-git-revision-xml, init-revision-fallback" unless="skip-revision">
|
---|
289 | <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
|
---|
290 | <delete file="REVISION.XML"/>
|
---|
291 | </target>
|
---|
292 | <!--
|
---|
293 | **********************************************************
|
---|
294 | ** clean - clean up the build environment
|
---|
295 | **********************************************************
|
---|
296 | -->
|
---|
297 | <target name="clean">
|
---|
298 | <delete dir="${plugin.build.dir}"/>
|
---|
299 | <delete file="${plugin.jar}"/>
|
---|
300 | </target>
|
---|
301 | <!--
|
---|
302 | **********************************************************
|
---|
303 | ** install - install the plugin in your local JOSM installation
|
---|
304 | **********************************************************
|
---|
305 | -->
|
---|
306 | <target name="install" depends="dist">
|
---|
307 | <property environment="env"/>
|
---|
308 | <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins">
|
---|
309 | <and>
|
---|
310 | <os family="windows"/>
|
---|
311 | </and>
|
---|
312 | </condition>
|
---|
313 | <condition property="josm.plugins.dir" value="${user.home}/Library/JOSM/plugins">
|
---|
314 | <and>
|
---|
315 | <os family="mac"/>
|
---|
316 | </and>
|
---|
317 | </condition>
|
---|
318 | <condition property="josm.plugins.dir" value="${user.home}/.josm/plugins">
|
---|
319 | <and>
|
---|
320 | <not><os family="windows"/></not>
|
---|
321 | <not><os family="mac"/></not>
|
---|
322 | </and>
|
---|
323 | </condition>
|
---|
324 | <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
|
---|
325 | </target>
|
---|
326 | <!--
|
---|
327 | ************************** Publishing the plugin ***********************************
|
---|
328 | -->
|
---|
329 | <!--
|
---|
330 | ** extracts the JOSM release for the JOSM version in ../core and saves it in the
|
---|
331 | ** property ${coreversion.info.entry.revision}
|
---|
332 | **
|
---|
333 | -->
|
---|
334 | <target name="core-info">
|
---|
335 | <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
|
---|
336 | <env key="LANG" value="C"/>
|
---|
337 | <arg value="info"/>
|
---|
338 | <arg value="--xml"/>
|
---|
339 | <arg value="../../core"/>
|
---|
340 | </exec>
|
---|
341 | <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
|
---|
342 | <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
|
---|
343 | <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
|
---|
344 | <delete file="core.info.xml"/>
|
---|
345 | </target>
|
---|
346 | <!--
|
---|
347 | ** commits the source tree for this plugin
|
---|
348 | -->
|
---|
349 | <target name="commit-current">
|
---|
350 | <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
|
---|
351 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
352 | <env key="LANG" value="C"/>
|
---|
353 | <arg value="commit"/>
|
---|
354 | <arg value="-m"/>
|
---|
355 | <arg value="${commit.message}"/>
|
---|
356 | <arg value="."/>
|
---|
357 | </exec>
|
---|
358 | </target>
|
---|
359 | <!--
|
---|
360 | ** updates (svn up) the source tree for this plugin
|
---|
361 | -->
|
---|
362 | <target name="update-current">
|
---|
363 | <echo>Updating plugin source ...</echo>
|
---|
364 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
365 | <env key="LANG" value="C"/>
|
---|
366 | <arg value="up"/>
|
---|
367 | <arg value="."/>
|
---|
368 | </exec>
|
---|
369 | <echo>Updating ${plugin.jar} ...</echo>
|
---|
370 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
371 | <env key="LANG" value="C"/>
|
---|
372 | <arg value="up"/>
|
---|
373 | <arg value="../dist/${plugin.jar}"/>
|
---|
374 | </exec>
|
---|
375 | </target>
|
---|
376 | <!--
|
---|
377 | ** commits the plugin.jar
|
---|
378 | -->
|
---|
379 | <target name="commit-dist">
|
---|
380 | <echo>
|
---|
381 | ***** Properties of published ${plugin.jar} *****
|
---|
382 | Commit message : '${commit.message}'
|
---|
383 | Plugin-Mainversion: ${plugin.main.version}
|
---|
384 | JOSM build version: ${coreversion.info.entry.revision}
|
---|
385 | Plugin-Version : ${version.entry.commit.revision}
|
---|
386 | ***** / Properties of published ${plugin.jar} *****
|
---|
387 |
|
---|
388 | Now commiting ${plugin.jar} ...
|
---|
389 | </echo>
|
---|
390 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
391 | <env key="LANG" value="C"/>
|
---|
392 | <arg value="-m"/>
|
---|
393 | <arg value="${commit.message}"/>
|
---|
394 | <arg value="commit"/>
|
---|
395 | <arg value="${plugin.jar}"/>
|
---|
396 | </exec>
|
---|
397 | </target>
|
---|
398 | <!-- ** make sure svn is present as a command line tool ** -->
|
---|
399 | <target name="ensure-svn-present">
|
---|
400 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
|
---|
401 | <env key="LANG" value="C"/>
|
---|
402 | <arg value="--version"/>
|
---|
403 | </exec>
|
---|
404 | <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
|
---|
405 | <!-- return code not set at all? Most likely svn isn't installed -->
|
---|
406 | <condition>
|
---|
407 | <not>
|
---|
408 | <isset property="svn.exit.code"/>
|
---|
409 | </not>
|
---|
410 | </condition>
|
---|
411 | </fail>
|
---|
412 | <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
|
---|
413 | <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
|
---|
414 | <condition>
|
---|
415 | <isfailure code="${svn.exit.code}"/>
|
---|
416 | </condition>
|
---|
417 | </fail>
|
---|
418 | </target>
|
---|
419 |
|
---|
420 | <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
|
---|
421 | </target>
|
---|
422 |
|
---|
423 | <path id="test.classpath">
|
---|
424 | <fileset dir="../00_core_test_lib">
|
---|
425 | <include name="**/*.jar"/>
|
---|
426 | </fileset>
|
---|
427 | <fileset dir="${plugin.test.dir}/lib" erroronmissingdir="no">
|
---|
428 | <include name="**/*.jar"/>
|
---|
429 | <exclude name="**/*-sources.jar"/>
|
---|
430 | <exclude name="**/*-javadoc.jar"/>
|
---|
431 | </fileset>
|
---|
432 | <fileset dir="lib" erroronmissingdir="no">
|
---|
433 | <include name="**/*.jar"/>
|
---|
434 | <exclude name="**/*-sources.jar"/>
|
---|
435 | <exclude name="**/*-javadoc.jar"/>
|
---|
436 | </fileset>
|
---|
437 | <pathelement path="${plugin.test.dir}/data"/>
|
---|
438 | <pathelement path="${josm.test.build.dir}/unit"/>
|
---|
439 | <pathelement path="${josm}"/>
|
---|
440 | <pathelement path="${plugin.jar}"/>
|
---|
441 | <pathelement path="${annotations.jar}"/>
|
---|
442 | </path>
|
---|
443 | <macrodef name="init-test-preferences">
|
---|
444 | <sequential>
|
---|
445 | <copy file="../00_core_test_config/preferences.template.xml" tofile="../00_core_test_config/unit-josm.home/preferences.xml"/>
|
---|
446 | <replace file="../00_core_test_config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
|
---|
447 | <replace file="../00_core_test_config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
|
---|
448 | </sequential>
|
---|
449 | </macrodef>
|
---|
450 | <target name="check-test">
|
---|
451 | <available file="${plugin.test.dir}" type="dir" property="test.present"/>
|
---|
452 | </target>
|
---|
453 | <target name="test-init" depends="check-test" if="test.present">
|
---|
454 | <mkdir dir="${plugin.test.dir}/build"/>
|
---|
455 | <mkdir dir="${plugin.test.dir}/build/unit"/>
|
---|
456 | <mkdir dir="${plugin.test.dir}/report"/>
|
---|
457 | <init-test-preferences/>
|
---|
458 | </target>
|
---|
459 | <target name="test-clean">
|
---|
460 | <delete dir="${plugin.test.dir}/build"/>
|
---|
461 | <delete dir="${plugin.test.dir}/report"/>
|
---|
462 | <delete file="${plugin.test.dir}/jacoco.exec" />
|
---|
463 | <delete file="../00_core_test_config/unit-josm.home/preferences.xml" />
|
---|
464 | <delete dir="../00_core_test_config/unit-josm.home/cache" failonerror="false"/>
|
---|
465 | </target>
|
---|
466 | <target name="test-compile" depends="test-init,dist" if="test.present">
|
---|
467 | <sequential>
|
---|
468 | <javac debug="on" srcdir="${plugin.test.dir}/unit" destdir="${plugin.test.dir}/build/unit" encoding="UTF-8">
|
---|
469 | <classpath>
|
---|
470 | <fileset refid="plugin.requires.jars"/>
|
---|
471 | <path refid="test.classpath"/>
|
---|
472 | </classpath>
|
---|
473 | <compilerarg value="-Xlint:all"/>
|
---|
474 | <compilerarg value="-Xlint:-serial"/>
|
---|
475 | </javac>
|
---|
476 | </sequential>
|
---|
477 | </target>
|
---|
478 | <target name="test" depends="dist, test-clean, test-compile" if="test.present"
|
---|
479 | description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
|
---|
480 | <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="../00_core_tools/jacocoant.jar" />
|
---|
481 | <sequential>
|
---|
482 | <echo message="Running unit tests with JUnit"/>
|
---|
483 | <jacoco:coverage destfile="${plugin.test.dir}/jacoco.exec">
|
---|
484 | <junit printsummary="yes" fork="true" forkmode="once" dir="${basedir}">
|
---|
485 | <jvmarg value="-Dfile.encoding=UTF-8"/>
|
---|
486 | <sysproperty key="josm.home" value="../00_core_test_config/unit-josm.home"/>
|
---|
487 | <sysproperty key="josm.test.data" value="${plugin.test.dir}/data"/>
|
---|
488 | <sysproperty key="java.awt.headless" value="true"/>
|
---|
489 | <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
|
---|
490 | <classpath>
|
---|
491 | <fileset refid="plugin.requires.jars"/>
|
---|
492 | <path refid="test.classpath"/>
|
---|
493 | <pathelement path="${plugin.test.dir}/build/unit"/>
|
---|
494 | </classpath>
|
---|
495 | <formatter type="plain"/>
|
---|
496 | <formatter type="xml"/>
|
---|
497 | <batchtest fork="yes" todir="${plugin.test.dir}/report">
|
---|
498 | <fileset dir="${plugin.test.dir}/build/unit" includes="**/*Test.class"/>
|
---|
499 | </batchtest>
|
---|
500 | </junit>
|
---|
501 | </jacoco:coverage>
|
---|
502 | </sequential>
|
---|
503 | </target>
|
---|
504 |
|
---|
505 | <target name="checkstyle">
|
---|
506 | <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpath="${checkstyle.jar}"/>
|
---|
507 | <checkstyle config="../00_core_tools/checkstyle/josm_checks.xml">
|
---|
508 | <fileset dir="${basedir}/src" includes="**/*.java" excludes="boofcv/**/*.java,
|
---|
509 | com/google/**/*.java,
|
---|
510 | crosby/**/*.java,
|
---|
511 | edu/princeton/**/*.java,
|
---|
512 | net/boplicity/**/*.java,
|
---|
513 | org/apache/**/*.java,
|
---|
514 | org/dinopolis/**/*.java,
|
---|
515 | org/kaintoch/**/*.java,
|
---|
516 | org/marvinproject/**/*.java,
|
---|
517 | org/netbeans/**/*.java,
|
---|
518 | org/openstreetmap/josm/plugins/dataimport/io/tcx/**/*.java,
|
---|
519 | org/openstreetmap/josm/plugins/ohe/parser/**/*.java,
|
---|
520 | org/openstreetmap/josm/plugins/roadsigns/javacc/**/*.java,
|
---|
521 | org/osgeo/**/*.java,
|
---|
522 | pdfimport/pdfbox/operators/**/*.java
|
---|
523 | "/>
|
---|
524 | <fileset dir="${basedir}/test" includes="**/*.java" erroronmissingdir="false"/>
|
---|
525 | <formatter type="xml" toFile="checkstyle-josm-${ant.project.name}.xml"/>
|
---|
526 | </checkstyle>
|
---|
527 | </target>
|
---|
528 |
|
---|
529 | <target name="findbugs" depends="dist">
|
---|
530 | <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${findbugs-ant.jar}"/>
|
---|
531 | <path id="findbugs-classpath">
|
---|
532 | <fileset dir="../00_core_tools/findbugs/">
|
---|
533 | <include name="*.jar"/>
|
---|
534 | </fileset>
|
---|
535 | </path>
|
---|
536 | <property name="findbugs-classpath" refid="findbugs-classpath"/>
|
---|
537 | <findbugs output="xml"
|
---|
538 | outputFile="findbugs-josm-${ant.project.name}.xml"
|
---|
539 | classpath="${findbugs-classpath}"
|
---|
540 | pluginList=""
|
---|
541 | excludeFilter="../findbugs-filter.xml"
|
---|
542 | effort="default"
|
---|
543 | reportLevel="low"
|
---|
544 | >
|
---|
545 | <auxClasspath refid="plugin.classpath" />
|
---|
546 | <sourcePath path="${basedir}/src" />
|
---|
547 | <class location="${plugin.jar}" />
|
---|
548 | </findbugs>
|
---|
549 | </target>
|
---|
550 |
|
---|
551 | <target name="runjosm" depends="install">
|
---|
552 | <java jar="${josm}" fork="true"/>
|
---|
553 | </target>
|
---|
554 |
|
---|
555 | <target name="profilejosm" depends="install">
|
---|
556 | <nbprofiledirect>
|
---|
557 | </nbprofiledirect>
|
---|
558 | <java jar="${josm}" fork="true">
|
---|
559 | <jvmarg value="${profiler.info.jvmargs.agent}"/>
|
---|
560 | </java>
|
---|
561 | </target>
|
---|
562 | <!--
|
---|
563 | ** shows a help text
|
---|
564 | -->
|
---|
565 | <target name="help">
|
---|
566 | <echo>
|
---|
567 | You can use following targets:
|
---|
568 | * dist This default target builds the plugin jar file
|
---|
569 | * clean Cleanup automatical created files
|
---|
570 | * test Run unit tests (if any)
|
---|
571 | * publish Checkin source code, build jar and checkin plugin jar
|
---|
572 | (requires proper entry for SVN commit message!)
|
---|
573 | * install Install the plugin in current system
|
---|
574 | * runjosm Install plugin and start josm
|
---|
575 | * profilejosm Install plugin and start josm in profiling mode
|
---|
576 |
|
---|
577 | There are other targets, which usually should not be called manually.
|
---|
578 | </echo>
|
---|
579 | </target>
|
---|
580 | </project>
|
---|