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