source: osm/applications/editors/josm/plugins/build-common.xml@ 29006

Last change on this file since 29006 was 29006, checked in by stoecker, 12 years ago

typo

File size: 12.7 KB
Line 
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=".">
14
15 <property name="josm" location="../../core/dist/josm-custom.jar"/>
16 <property name="plugin.build.dir" value="build"/>
17 <property name="plugin.src.dir" value="src"/>
18 <property name="plugin.lib.dir" value="lib"/>
19 <!-- this is the directory where the plugin jar is copied to -->
20 <property name="plugin.dist.dir" value="../../dist"/>
21 <property name="ant.build.javac.target" value="1.6"/>
22 <property name="ant.build.javac.source" value="1.6"/>
23 <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
24
25 <!--
26 **********************************************************
27 ** init - initializes the build
28 **********************************************************
29 -->
30 <target name="init">
31 <mkdir dir="${plugin.build.dir}"/>
32 </target>
33 <!--
34 **********************************************************
35 ** compile - complies the source tree
36 **********************************************************
37 -->
38 <target name="compile" depends="init">
39 <echo message="compiling sources for ${plugin.jar} ..."/>
40 <javac srcdir="src" debug="true" destdir="${plugin.build.dir}" includeantruntime="false">
41 <compilerarg value="-Xlint:deprecation"/>
42 <compilerarg value="-Xlint:unchecked"/>
43 <classpath>
44 <pathelement location="${josm}"/>
45 <fileset dir="${plugin.lib.dir}" erroronmissingdir="no">
46 <include name="**/*.jar"/>
47 </fileset>
48 </classpath>
49 </javac>
50 </target>
51 <!--
52 **********************************************************
53 ** setup-dist - copies files for distribution
54 **********************************************************
55 -->
56 <target name="setup-dist-default">
57 <copy todir="${plugin.build.dir}/resources" failonerror="no" includeemptydirs="no">
58 <fileset dir="resources"/>
59 </copy>
60 <copy todir="${plugin.build.dir}/images" failonerror="no" includeemptydirs="no">
61 <fileset dir="images"/>
62 </copy>
63 <copy todir="${plugin.build.dir}/data" failonerror="no" includeemptydirs="no">
64 <fileset dir="data"/>
65 </copy>
66 <copy todir="${plugin.build.dir}">
67 <fileset dir=".">
68 <include name="README"/>
69 <include name="LICENSE*"/>
70 <include name="*GPL*"/>
71 </fileset>
72 </copy>
73 </target>
74 <target name="setup-dist">
75 <antcall target="setup-dist-default" />
76 </target>
77 <!--
78 **********************************************************
79 ** dist - creates the plugin jar
80 **********************************************************
81 -->
82 <target name="dist" depends="compile,revision">
83 <echo message="creating ${ant.project.name}.jar ... "/>
84 <antcall target="setup-dist" />
85 <delete file="MANIFEST" failonerror="no"/>
86 <manifest file="MANIFEST" mode="update">
87 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
88 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
89 <attribute name="Plugin-Class" value="${plugin.class}" />
90 <attribute name="Plugin-Description" value="${plugin.description}" />
91 <attribute name="Plugin-Date" value="${version.entry.commit.date}" />
92 <attribute name="Author" value="${plugin.author}"/>
93 </manifest>
94 <antcall target="add-manifest-attribute">
95 <param name="manifest.attribute" value="Plugin-Link"/>
96 <param name="propery.name" value="plugin.link"/>
97 <param name="propery.value" value="${plugin.link}"/>
98 </antcall>
99 <antcall target="add-manifest-attribute">
100 <param name="manifest.attribute" value="Plugin-Icon"/>
101 <param name="propery.name" value="plugin.icon"/>
102 <param name="propery.value" value="${plugin.icon}"/>
103 </antcall>
104 <antcall target="add-manifest-attribute">
105 <param name="manifest.attribute" value="Plugin-Early"/>
106 <param name="propery.name" value="plugin.early"/>
107 <param name="propery.value" value="${plugin.early}"/>
108 </antcall>
109 <antcall target="add-manifest-attribute">
110 <param name="manifest.attribute" value="Plugin-Requires"/>
111 <param name="propery.name" value="plugin.requires"/>
112 <param name="propery.value" value="${plugin.requires}"/>
113 </antcall>
114 <antcall target="add-manifest-attribute">
115 <param name="manifest.attribute" value="Plugin-Stage"/>
116 <param name="propery.name" value="plugin.stage"/>
117 <param name="propery.value" value="${plugin.stage}"/>
118 </antcall>
119 <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="MANIFEST">
120 <zipgroupfileset dir="${plugin.lib.dir}" includes="*.jar" erroronmissingdir="no"/>
121 </jar>
122 <delete file="MANIFEST" failonerror="no"/>
123 </target>
124 <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${propery.name}">
125 <manifest file="MANIFEST" mode="update">
126 <attribute name="${manifest.attribute}" value="${propery.value}" />
127 </manifest>
128 </target>
129 <target name="check-manifest-attribute">
130 <condition property="have-${propery.name}">
131 <and>
132 <isset property="${propery.name}"/>
133 <not>
134 <equals arg1="${propery.value}" arg2=""/>
135 </not>
136 <not>
137 <equals arg1="${propery.value}" arg2="..."/>
138 </not>
139 </and>
140 </condition>
141 </target>
142 <!--
143 **********************************************************
144 ** revision - extracts the current revision number for the
145 ** file build.number and stores it in the XML property
146 ** version.*
147 **********************************************************
148 -->
149 <target name="revision">
150 <exec append="false" outputproperty="svn.revision.output" executable="svn" failifexecutionfails="false">
151 <env key="LANG" value="C"/>
152 <arg value="info"/>
153 <arg value="--xml"/>
154 <arg value="."/>
155 </exec>
156 <xmlproperty prefix="version" keepRoot="false" collapseAttributes="true">
157 <propertyresource name="svn.revision.output"/>
158 </xmlproperty>
159 </target>
160 <!--
161 **********************************************************
162 ** clean - clean up the build environment
163 **********************************************************
164 -->
165 <target name="clean">
166 <delete dir="${plugin.build.dir}"/>
167 <delete file="${plugin.jar}"/>
168 </target>
169 <!--
170 **********************************************************
171 ** install - install the plugin in your local JOSM installation
172 **********************************************************
173 -->
174 <target name="install" depends="dist">
175 <property environment="env"/>
176 <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
177 <and>
178 <os family="windows"/>
179 </and>
180 </condition>
181 <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
182 </target>
183 <!--
184 ************************** Publishing the plugin ***********************************
185 -->
186 <!--
187 ** extracts the JOSM release for the JOSM version in ../core and saves it in the
188 ** property ${coreversion.info.entry.revision}
189 **
190 -->
191 <target name="core-info">
192 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
193 <env key="LANG" value="C"/>
194 <arg value="info"/>
195 <arg value="--xml"/>
196 <arg value="../../core"/>
197 </exec>
198 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
199 <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
200 <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
201 <delete file="core.info.xml"/>
202 </target>
203 <!--
204 ** commits the source tree for this plugin
205 -->
206 <target name="commit-current">
207 <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
208 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
209 <env key="LANG" value="C"/>
210 <arg value="commit"/>
211 <arg value="-m"/>
212 <arg value="${commit.message}"/>
213 <arg value="."/>
214 </exec>
215 </target>
216 <!--
217 ** updates (svn up) the source tree for this plugin
218 -->
219 <target name="update-current">
220 <echo>Updating plugin source ...</echo>
221 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
222 <env key="LANG" value="C"/>
223 <arg value="up"/>
224 <arg value="."/>
225 </exec>
226 <echo>Updating ${plugin.jar} ...</echo>
227 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
228 <env key="LANG" value="C"/>
229 <arg value="up"/>
230 <arg value="../dist/${plugin.jar}"/>
231 </exec>
232 </target>
233 <!--
234 ** commits the plugin.jar
235 -->
236 <target name="commit-dist">
237 <echo>
238 ***** Properties of published ${plugin.jar} *****
239 Commit message : '${commit.message}'
240 Plugin-Mainversion: ${plugin.main.version}
241 JOSM build version: ${coreversion.info.entry.revision}
242 Plugin-Version : ${version.entry.commit.revision}
243 ***** / Properties of published ${plugin.jar} *****
244
245 Now commiting ${plugin.jar} ...
246 </echo>
247 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
248 <env key="LANG" value="C"/>
249 <arg value="-m"/>
250 <arg value="${commit.message}"/>
251 <arg value="commit"/>
252 <arg value="${plugin.jar}"/>
253 </exec>
254 </target>
255 <!-- ** make sure svn is present as a command line tool ** -->
256 <target name="ensure-svn-present">
257 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
258 <env key="LANG" value="C"/>
259 <arg value="--version"/>
260 </exec>
261 <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
262 <!-- return code not set at all? Most likely svn isn't installed -->
263 <condition>
264 <not>
265 <isset property="svn.exit.code"/>
266 </not>
267 </condition>
268 </fail>
269 <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
270 <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
271 <condition>
272 <isfailure code="${svn.exit.code}"/>
273 </condition>
274 </fail>
275 </target>
276
277 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
278 </target>
279
280 <target name="runjosm" depends="install">
281 <java jar="${josm}" fork="true">
282 </java>
283 </target>
284
285 <target name="profilejosm" depends="install">
286 <nbprofiledirect>
287 </nbprofiledirect>
288 <java jar="${josm}" fork="true">
289 <jvmarg value="${profiler.info.jvmargs.agent}"/>
290 </java>
291 </target>
292 <!--
293 ** shows a help text
294 -->
295 <target name="help">
296 <echo>
297 You can use following targets:
298 * dist This default target builds the plugin jar file
299 * clean Cleanup automatical created files
300 * publish Checkin source code, build jar and checkin plugin jar
301 (requires proper entry for SVN commit message!)
302 * install Install the plugin in current system
303 * runjosm Install plugin and start josm
304 * profilejosm Install plugin and start josm in profiling mode
305
306 There are other targets, which usually should not be called manually.
307 </echo>
308 </target>
309</project>
310
Note: See TracBrowser for help on using the repository browser.