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