source: osm/applications/editors/josm/plugins/scripting/build.xml@ 25030

Last change on this file since 25030 was 25019, checked in by guggis, 15 years ago
File size: 12.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3** This is the build file for the contour plugin
4**
5** Maintaining versions
6** ====================
7** see README.template
8**
9** Usage
10** =====
11** To build it run
12**
13** > ant dist
14**
15** To install the generated plugin locally (in your default plugin directory) run
16**
17** > ant install
18**
19** To build against the core in ../../core, create a correct manifest and deploy to
20** SVN,
21** set the properties commit.message and plugin.main.version
22** and run
23** > ant publish
24**
25**
26-->
27<project name="scripting" default="dist" basedir=".">
28
29 <property name="commit.message" value="Initial version" />
30 <property name="plugin.main.version" value="3751" />
31
32 <!--
33 ************************************************
34 ** should not be necessary to change the following properties
35 -->
36 <property name="josm" location="../../core/dist/josm-custom.jar" />
37 <property name="plugin.build.dir" value="build" />
38 <property name="plugin.src.dir" value="src" />
39 <!-- this is the directory where the plugin jar is copied to -->
40 <property name="plugin.dist.dir" value="../../dist" />
41 <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar" />
42
43 <path id="compile.path">
44 <pathelement location="${josm}"/>
45 <pathelement location="lib/groovy-all-1.7.7-SNAPSHOT.jar"/>
46 </path>
47
48 <!--
49 **********************************************************
50 ** init - initializes the build
51 **********************************************************
52 -->
53 <target name="init">
54 <mkdir dir="${plugin.build.dir}" />
55 </target>
56
57 <!--
58 **********************************************************
59 ** compile - complies the source tree
60 **********************************************************
61 -->
62 <target name="compile" depends="init">
63 <echo message="compiling sources for ${plugin.jar} ... " />
64 <javac srcdir="src" classpathref="compile.path" debug="true" destdir="${plugin.build.dir}">
65 <compilerarg value="-Xlint:deprecation" />
66 <compilerarg value="-Xlint:unchecked" />
67 </javac>
68 </target>
69
70 <!--
71 **********************************************************
72 ** dist - creates the plugin jar
73 **********************************************************
74 -->
75 <target name="dist" depends="compile,revision">
76 <echo message="creating ${plugin.jar} for version ${version.entry.commit.revision} ... " />
77 <copy todir="${plugin.build.dir}/images">
78 <fileset dir="images">
79 <include name="*.png" />
80 </fileset>
81 </copy>
82 <copy todir="${plugin.build.dir}/scripts">
83 <fileset dir="scripts">
84 <include name="*.groovy" />
85 </fileset>
86 </copy>
87
88 <copy todir="${plugin.build.dir}">
89 <fileset dir=".">
90 <include name="README" />
91 <include name="LICENSE" />
92 </fileset>
93 </copy>
94 <copy todir="${plugin.build.dir}">
95 <fileset dir="${plugin.src.dir}">
96 <include name="**/*.dtd" />
97 </fileset>
98 </copy>
99 <copy todir="${plugin.build.dir}/META-INF">
100 <fileset dir="resources">
101 <include name="mime.types" />
102 </fileset>
103 </copy>
104 <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
105 <manifest>
106 <attribute name="Author" value="Karl Guggisberg" />
107 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.scripting.ScriptingPlugin" />
108 <attribute name="Plugin-Date" value="${version.entry.commit.date}" />
109 <attribute name="Plugin-Description" value="Allows to run scripts in JOSM." />
110 <!-- <attribute name="Plugin-Icon" value="" /> -->
111 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/Scripting" />
112 <attribute name="Plugin-Mainversion" value="${plugin.main.version}" />
113 <attribute name="Plugin-Version" value="${version.entry.commit.revision}" />
114 </manifest>
115 </jar>
116 </target>
117
118 <!--
119 **********************************************************
120 ** revision - extracts the current revision number for the
121 ** file build.number and stores it in the XML property
122 ** version.*
123 **********************************************************
124 -->
125 <target name="revision">
126 <!-- extract the SVN revision information -->
127 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
128 <env key="LANG" value="C" />
129 <arg value="info" />
130 <arg value="--xml" />
131 <arg value="." />
132 </exec>
133 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true" />
134 <delete file="REVISION" />
135 </target>
136
137 <!--
138 **********************************************************
139 ** clean - clean up the build environment
140 **********************************************************
141 -->
142 <target name="clean">
143 <delete dir="${plugin.build.dir}" />
144 <delete file="${plugin.jar}" />
145 </target>
146
147 <!--
148 **********************************************************
149 ** install - install the plugin in your local JOSM installation
150 **********************************************************
151 -->
152 <target name="install" depends="dist">
153 <property environment="env" />
154 <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
155 <and>
156 <os family="windows" />
157 </and>
158 </condition>
159 <copy file="${plugin.jar}" todir="${josm.plugins.dir}" />
160 </target>
161
162 <!--
163 ************************** Publishing the plugin ***********************************
164 -->
165 <!--
166 ** extracts the JOSM release for the JOSM version in ../core and saves it in the
167 ** property ${coreversion.info.entry.revision}
168 **
169 -->
170 <target name="core-info">
171 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
172 <env key="LANG" value="C" />
173 <arg value="info" />
174 <arg value="--xml" />
175 <arg value="../../core" />
176 </exec>
177 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true" />
178 <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
179 <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
180 <delete file="core.info.xml" />
181 </target>
182
183 <!--
184 ** commits the source tree for this plugin
185 -->
186 <target name="commit-current">
187 <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
188 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
189 <env key="LANG" value="C" />
190 <arg value="commit" />
191 <arg value="-m '${commit.message}'" />
192 <arg value="." />
193 </exec>
194 </target>
195
196 <!--
197 ** updates (svn up) the source tree for this plugin
198 -->
199 <target name="update-current">
200 <echo>Updating plugin source ...</echo>
201 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
202 <env key="LANG" value="C" />
203 <arg value="up" />
204 <arg value="." />
205 </exec>
206 <echo>Updating ${plugin.jar} ...</echo>
207 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
208 <env key="LANG" value="C" />
209 <arg value="up" />
210 <arg value="../dist/${plugin.jar}" />
211 </exec>
212 </target>
213
214 <!--
215 ** commits the plugin.jar
216 -->
217 <target name="commit-dist">
218 <echo>
219***** Properties of published ${plugin.jar} *****
220Commit message : '${commit.message}'
221Plugin-Mainversion: ${plugin.main.version}
222JOSM build version: ${coreversion.info.entry.revision}
223Plugin-Version : ${version.entry.commit.revision}
224***** / Properties of published ${plugin.jar} *****
225
226Now commiting ${plugin.jar} ...
227</echo>
228 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
229 <env key="LANG" value="C" />
230 <arg value="-m '${commit.message}'" />
231 <arg value="commit" />
232 <arg value="${plugin.jar}" />
233 </exec>
234 </target>
235
236 <!-- ** make sure svn is present as a command line tool ** -->
237 <target name="ensure-svn-present">
238 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
239 <env key="LANG" value="C" />
240 <arg value="--version" />
241 </exec>
242 <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
243 <!-- return code not set at all? Most likely svn isn't installed -->
244 <condition>
245 <not>
246 <isset property="svn.exit.code" />
247 </not>
248 </condition>
249 </fail>
250 <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
251 <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
252 <condition>
253 <isfailure code="${svn.exit.code}" />
254 </condition>
255 </fail>
256 </target>
257
258 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
259 </target>
260
261 <!-- ************************************************************************************ -->
262 <!-- * Targets for compiling and running tests -->
263 <!-- ************************************************************************************ -->
264 <property name="eclipse.plugin.dir" value="C:\software\eclipse-3.6.1\plugins" />
265 <property name="test.build.dir" value="test/build" />
266
267 <path id="groovy.path">
268 <pathelement location="${eclipse.plugin.dir}/org.codehaus.groovy_1.7.5.xx-20100926-2000-e36-RC1\lib\groovy-all-1.7.5.jar" />
269 </path>
270
271 <path id="junit.path">
272 <pathelement location="${eclipse.plugin.dir}/org.junit_4.8.1.v4_8_1_v20100427-1100\junit.jar" />
273 </path>
274
275 <!-- groovy dependency: groovy fails unless hamcrest is on the path -->
276 <path id="hamcrest.path">
277 <pathelement location="test/lib/hamcrest-all-1.3.0RC2.jar" />
278 </path>
279
280 <path id="test.class.path">
281 <pathelement location="${josm}" />
282 <pathelement location="${plugin.build.dir}" />
283 <path refid="groovy.path" />
284 <path refid="junit.path" />
285 </path>
286
287 <path id="groovyc.path">
288 <path refid="junit.path" />
289 <path refid="groovy.path" />
290 <path refid="hamcrest.path" />
291 <pathelement location="${josm}" />
292 <pathelement location="${test.build.dir}" />
293 <pathelement location="${plugin.build.dir}" />
294 <!-- if we didn't explicitly put hamcrest on the class path, groovyc would
295 abort and report it is missing a hamcrest class -->
296 <pathelement location="test/lib/hamcrest-all-1.2.jar" />
297 </path>
298
299 <target name="test-clean">
300 <delete dir="${test.build.dir}" />
301 <mkdir dir="${test.build.dir}" />
302 </target>
303
304 <target name="test-compile" depends="compile,test-clean" description="Compiles the test files">
305
306 <available classname="org.codehaus.groovy.ant.Groovy" classpathref="groovyc.path" property="groovy.present" />
307 <fail message="Groovy not found. Make sure groovy is on the classpath. Check 'groovy.path' in this build file." unless="groovy.present" />
308
309 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.path" />
310
311 <echo message="compiling test infrastructur for ${plugin.jar} ... " />
312 <javac srcdir="test/src" classpathref="test.class.path" debug="true" destdir="${test.build.dir}" includes="org/openstreetmap/josm/plugins/contourmerge/fixtures/**/*">
313 <compilerarg value="-Xlint:deprecation" />
314 <compilerarg value="-Xlint:unchecked" />
315 </javac>
316
317 <echo message="compiling groovy test cases for ${plugin.jar} ... " />
318 <groovyc srcdir="test/src" destdir="${test.build.dir}" classpathref="groovyc.path">
319 </groovyc>
320
321 <echo message="compiling java test cases for ${plugin.jar} ... " />
322 <javac srcdir="test/src" classpathref="test.class.path" debug="true" destdir="${test.build.dir}">
323 <compilerarg value="-Xlint:deprecation" />
324 <compilerarg value="-Xlint:unchecked" />
325 </javac>
326 </target>
327
328 <target name="test-run" depends="test-compile" description="Runs the junit tests">
329 <delete dir="test/output" />
330 <mkdir dir="test/output" />
331
332 <junit printsummary="true" failureproperty="junit.failure">
333 <classpath>
334 <path refid="groovyc.path" />
335 <pathelement location="test/config" />
336 <!-- required for test config file -->
337 <pathelement location="." />
338 <!-- required to load images from subdir 'images/' -->
339 </classpath>
340
341 <test todir="test/output" name='org.openstreetmap.josm.plugins.contourmerge.AllUnitTests'>
342 <formatter type="xml" />
343 </test>
344 </junit>
345 </target>
346
347 <target name="dev-install" depends="dist">
348 <copy file="${plugin.jar}" todir="C:/data/projekte/osm/josm-dev/plugins" />
349 </target>
350</project>
Note: See TracBrowser for help on using the repository browser.