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