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