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