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

Last change on this file since 29805 was 29694, checked in by bastik, 11 years ago

applied #josm8817 - Plugins don't compile if you use a non UTF-8 locale (patch by Gnonthgol)

File size: 13.0 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 - compiles 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" encoding="UTF-8">
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 <antcall target="additional-manifest" />
120 <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="MANIFEST">
121 <zipgroupfileset dir="${plugin.lib.dir}" includes="*.jar" erroronmissingdir="no"/>
122 </jar>
123 <delete file="MANIFEST" failonerror="no"/>
124 <antcall target="post-dist" />
125 </target>
126 <target name="post-dist">
127 <!-- to be overidden by plugins that need to perform additional tasks on resulting jar -->
128 </target>
129 <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${propery.name}">
130 <manifest file="MANIFEST" mode="update">
131 <attribute name="${manifest.attribute}" value="${propery.value}" />
132 </manifest>
133 </target>
134 <!-- target to add additional entries, empty in commons -->
135 <target name="additional-manifest">
136 </target>
137 <target name="check-manifest-attribute">
138 <condition property="have-${propery.name}">
139 <and>
140 <isset property="${propery.name}"/>
141 <not>
142 <equals arg1="${propery.value}" arg2=""/>
143 </not>
144 <not>
145 <equals arg1="${propery.value}" arg2="..."/>
146 </not>
147 </and>
148 </condition>
149 </target>
150 <!--
151 **********************************************************
152 ** revision - extracts the current revision number for the
153 ** file build.number and stores it in the XML property
154 ** version.*
155 **********************************************************
156 -->
157 <target name="revision">
158 <exec append="false" outputproperty="svn.revision.output" executable="svn" failifexecutionfails="false">
159 <env key="LANG" value="C"/>
160 <arg value="info"/>
161 <arg value="--xml"/>
162 <arg value="."/>
163 </exec>
164 <xmlproperty prefix="version" keepRoot="false" collapseAttributes="true">
165 <propertyresource name="svn.revision.output"/>
166 </xmlproperty>
167 </target>
168 <!--
169 **********************************************************
170 ** clean - clean up the build environment
171 **********************************************************
172 -->
173 <target name="clean">
174 <delete dir="${plugin.build.dir}"/>
175 <delete file="${plugin.jar}"/>
176 </target>
177 <!--
178 **********************************************************
179 ** install - install the plugin in your local JOSM installation
180 **********************************************************
181 -->
182 <target name="install" depends="dist">
183 <property environment="env"/>
184 <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
185 <and>
186 <os family="windows"/>
187 </and>
188 </condition>
189 <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
190 </target>
191 <!--
192 ************************** Publishing the plugin ***********************************
193 -->
194 <!--
195 ** extracts the JOSM release for the JOSM version in ../core and saves it in the
196 ** property ${coreversion.info.entry.revision}
197 **
198 -->
199 <target name="core-info">
200 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
201 <env key="LANG" value="C"/>
202 <arg value="info"/>
203 <arg value="--xml"/>
204 <arg value="../../core"/>
205 </exec>
206 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
207 <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
208 <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
209 <delete file="core.info.xml"/>
210 </target>
211 <!--
212 ** commits the source tree for this plugin
213 -->
214 <target name="commit-current">
215 <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
216 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
217 <env key="LANG" value="C"/>
218 <arg value="commit"/>
219 <arg value="-m"/>
220 <arg value="${commit.message}"/>
221 <arg value="."/>
222 </exec>
223 </target>
224 <!--
225 ** updates (svn up) the source tree for this plugin
226 -->
227 <target name="update-current">
228 <echo>Updating plugin source ...</echo>
229 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
230 <env key="LANG" value="C"/>
231 <arg value="up"/>
232 <arg value="."/>
233 </exec>
234 <echo>Updating ${plugin.jar} ...</echo>
235 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
236 <env key="LANG" value="C"/>
237 <arg value="up"/>
238 <arg value="../dist/${plugin.jar}"/>
239 </exec>
240 </target>
241 <!--
242 ** commits the plugin.jar
243 -->
244 <target name="commit-dist">
245 <echo>
246 ***** Properties of published ${plugin.jar} *****
247 Commit message : '${commit.message}'
248 Plugin-Mainversion: ${plugin.main.version}
249 JOSM build version: ${coreversion.info.entry.revision}
250 Plugin-Version : ${version.entry.commit.revision}
251 ***** / Properties of published ${plugin.jar} *****
252
253 Now commiting ${plugin.jar} ...
254 </echo>
255 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
256 <env key="LANG" value="C"/>
257 <arg value="-m"/>
258 <arg value="${commit.message}"/>
259 <arg value="commit"/>
260 <arg value="${plugin.jar}"/>
261 </exec>
262 </target>
263 <!-- ** make sure svn is present as a command line tool ** -->
264 <target name="ensure-svn-present">
265 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
266 <env key="LANG" value="C"/>
267 <arg value="--version"/>
268 </exec>
269 <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
270 <!-- return code not set at all? Most likely svn isn't installed -->
271 <condition>
272 <not>
273 <isset property="svn.exit.code"/>
274 </not>
275 </condition>
276 </fail>
277 <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
278 <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
279 <condition>
280 <isfailure code="${svn.exit.code}"/>
281 </condition>
282 </fail>
283 </target>
284
285 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
286 </target>
287
288 <target name="runjosm" depends="install">
289 <java jar="${josm}" fork="true">
290 </java>
291 </target>
292
293 <target name="profilejosm" depends="install">
294 <nbprofiledirect>
295 </nbprofiledirect>
296 <java jar="${josm}" fork="true">
297 <jvmarg value="${profiler.info.jvmargs.agent}"/>
298 </java>
299 </target>
300 <!--
301 ** shows a help text
302 -->
303 <target name="help">
304 <echo>
305 You can use following targets:
306 * dist This default target builds the plugin jar file
307 * clean Cleanup automatical created files
308 * publish Checkin source code, build jar and checkin plugin jar
309 (requires proper entry for SVN commit message!)
310 * install Install the plugin in current system
311 * runjosm Install plugin and start josm
312 * profilejosm Install plugin and start josm in profiling mode
313
314 There are other targets, which usually should not be called manually.
315 </echo>
316 </target>
317</project>
318
Note: See TracBrowser for help on using the repository browser.