Mercurial > hg > mercurial
annotate teamcity-common.xml @ 482:47fc9add99fe
fix compilation
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 01 Oct 2012 12:18:29 +0400 |
parents | 63fcc9b14221 |
children | 31a1aca3305c |
rev | line source |
---|---|
76 | 1 <?xml version="1.0" encoding="UTF-8"?> |
2 <project name="TeamCityPluginCommon"> | |
3 | |
4 <!-- | |
5 Tasks: | |
6 package.teamcity.plugin | |
7 deploy.teamcity.plugin | |
8 undeploy.teamcity.plugin | |
9 unpack.teamcity | |
10 | |
11 Targets: | |
12 check.teamcitydistribution | |
13 --> | |
14 | |
15 <property name="path.variable.teamcitydistribution" value="${teamcity.distribution}"/> | |
16 | |
17 <property name="teamcity.internal.default.out" value="dist"/> | |
18 | |
19 | |
20 <macrodef name="package.teamcity.plugin" description="packages TeamCity plugin"> | |
21 <attribute name="name" description="name of the plugin"/> | |
22 <attribute name="server.output" default="" description="path to compiled server plugin output"/> | |
23 <attribute name="agent.output" default="" description="path to compiled agent plugin output"/> | |
24 <attribute name="common.output" default="" description="path to compiled common plugin output"/> | |
25 <attribute name="out" default="${teamcity.internal.default.out}" description="directory to put prepared plugin zip into"/> | |
26 <attribute name="plugin.descriptor.file" default="${basedir}/teamcity-plugin.xml" description="path to teamcity-plugin.xml file"/> | |
27 <attribute name="common.jar.name" default="@{name}-common.jar" description="name of the shared jar between server and agent"/> | |
28 <attribute name="out.unpacked" default="@{out}/unpacked" | |
29 description="name of the directory to store unpacked plugin (not packed into zip)"/> | |
30 | |
31 <attribute name="server.lib.dir" default="" description="directory to get libs for the server part"/> | |
32 <attribute name="server.lib.includes" default="none should match" description="includes pattern of the files in the directory"/> | |
33 <attribute name="plugin.version" default="SNAPSHOT" | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
34 description="the version of the plugin to put into teamcity-plugin.xml instead of '@Plugin_Version@'"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
35 <attribute name="plugin.vendor" default="Unknown vendor" |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
36 description="name of the vendor to put into teamcity-plugin.xml instead of '@Plugin_Vendor@'"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
37 <attribute name="plugin.vendor.url" default="" |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
38 description="vendor URL to put into teamcity-plugin.xml instead of '@Plugin_Vendor_Url@'"/> |
76 | 39 |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
40 <element name="server-additional-files" optional="yes" description="fileset of the files to pack into root of the server plugin part"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
41 <element name="agent-additional-files" optional="yes" description="fileset of the files to pack into root of the agent plugin part"/> |
76 | 42 |
43 <sequential> | |
44 | |
45 <antcall target="check.already.defined"/> | |
46 | |
47 <property name="teamcity.internal.distrib.prep" value="${basedir}/temp/dist_prep"/> | |
48 <property name="teamcity.internal.distrib.prep.agent" value="${teamcity.internal.distrib.prep}/agent"/> | |
49 <property name="teamcity.internal.distrib.prep.common" value="${teamcity.internal.distrib.prep}/common"/> | |
50 <property name="teamcity.internal.distrib.prep.agent.jars" value="${teamcity.internal.distrib.prep.agent}/unpacked"/> | |
51 | |
52 | |
53 <!-- build jars --> | |
54 | |
55 <delete dir="@{out.unpacked}" quiet="true"/> | |
56 <delete dir="${teamcity.internal.distrib.prep}" quiet="true"/> | |
57 | |
58 <mkdir dir="@{out.unpacked}"/> | |
59 | |
60 <condition property="common.needed"> | |
61 <length string="@{common.output}" when="greater" length="0"/> | |
62 </condition> | |
63 <condition property="server.needed"> | |
64 <length string="@{server.output}" when="greater" length="0"/> | |
65 </condition> | |
66 <condition property="agent.needed"> | |
67 <length string="@{agent.output}" when="greater" length="0"/> | |
68 </condition> | |
69 | |
70 <condition property="plugin.descriptor.file.needed"> | |
71 <and> | |
72 <available file="@{plugin.descriptor.file}"/> | |
73 <length string="@{plugin.descriptor.file}" when="greater" length="0"/> | |
74 </and> | |
75 </condition> | |
76 | |
77 <mkdir dir="${teamcity.internal.distrib.prep.common}"/> | |
78 <antcall target="prepare.common.part"> | |
79 <param name="common.output" value="@{common.output}"/> | |
80 <param name="common.jar.path" value="${teamcity.internal.distrib.prep.common}/@{common.jar.name}"/> | |
81 </antcall> | |
82 | |
83 <antcall target="prepare.server.part"> | |
84 <param name="out.unpacked" value="@{out.unpacked}"/> | |
85 <param name="name" value="@{name}"/> | |
86 <param name="server.output" value="@{server.output}"/> | |
87 <param name="common.jar.path" value="${teamcity.internal.distrib.prep.common}/@{common.jar.name}"/> | |
88 <param name="lib.dir" value="@{server.lib.dir}"/> | |
89 <param name="lib.includes" value="@{server.lib.includes}"/> | |
90 </antcall> | |
91 | |
92 <antcall target="prepare.agent.part"> | |
93 <param name="out.unpacked" value="@{out.unpacked}"/> | |
94 <param name="name" value="@{name}"/> | |
95 <param name="agent.output" value="@{agent.output}"/> | |
96 <param name="common.jar.path" value="${teamcity.internal.distrib.prep.common}/@{common.jar.name}"/> | |
97 </antcall> | |
98 | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
99 <!-- copy additional agent files --> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
100 <mkdir dir="${teamcity.internal.distrib.prep.agent.jars}/@{name}" /> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
101 <copy todir="${teamcity.internal.distrib.prep.agent.jars}/@{name}"> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
102 <fileset dir="${basedir}" excludes="**"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
103 <agent-additional-files/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
104 </copy> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
105 |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
106 <antcall target="pack.agent.part"> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
107 <param name="out.unpacked" value="@{out.unpacked}"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
108 <param name="name" value="@{name}"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
109 </antcall> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
110 |
76 | 111 <!-- copy teamcity-plugin.xml --> |
112 <antcall target="prepare.plugin.descriptor.file"> | |
113 <param name="source" value="@{plugin.descriptor.file}"/> | |
114 <param name="dest" value="@{out.unpacked}/teamcity-plugin.xml"/> | |
115 <param name="plugin.version" value="@{plugin.version}"/> | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
116 <param name="plugin.vendor" value="@{plugin.vendor}"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
117 <param name="plugin.vendor.url" value="@{plugin.vendor.url}"/> |
76 | 118 </antcall> |
119 | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
120 <!-- copy additional server plugin files --> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
121 <copy todir="@{out.unpacked}"> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
122 <fileset dir="${basedir}" excludes="**"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
123 <server-additional-files/> |
76 | 124 </copy> |
125 | |
126 <!-- clean --> | |
127 <echo message="Cleaning..."/> | |
128 <delete dir="${teamcity.internal.distrib.prep}" quiet="true"/> | |
129 | |
130 <!-- package in zip --> | |
131 <echo message="Packaging zip..."/> | |
132 <delete file="@{out}/@{name}.zip" quiet="true"/> | |
133 <zip destfile="@{out}/@{name}.zip"> | |
134 <fileset dir="@{out.unpacked}"/> | |
135 </zip> | |
136 <echo message="To install the plugin, place '@{out}\@{name}.zip' into '.BuildServer/plugins' directory"/> | |
137 | |
138 </sequential> | |
139 </macrodef> | |
140 | |
141 <target name="check.teamcitydistribution" description="checks whether TeamCity distribution ready to be used by IDEA-generated build"> | |
142 <check.property name="path.variable.teamcitydistribution" | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
143 fail-message="Please define 'teamcity.distribution' or 'path.variable.teamcitydistribution' property (e.g. in build.properties file). The property should point to unpacked TeamCity .tar.gz or .exe distribution." |
76 | 144 /> |
145 | |
146 <condition property="teamcity.distribution.not.present"> | |
147 <not> | |
148 <and> | |
149 <available file="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib"/> | |
150 </and> | |
151 </not> | |
152 </condition> | |
153 <fail if="teamcity.distribution.not.present" | |
154 message="Cannot find TeamCity distribution at path '${path.variable.teamcitydistribution}'. The property 'teamcity.distribution' or 'path.variable.teamcitydistribution' should point to unpacked TeamCity .tar.gz or .exe distribution."/> | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
155 <echo message="Using ${path.variable.teamcitydistribution} as TeamCity distribution" /> |
76 | 156 </target> |
157 | |
158 <macrodef name="deploy.teamcity.plugin"> | |
159 <attribute name="name"/> | |
160 <attribute name="teamcity.data.path" default="${user.home}/.BuildServer" description="path to .BuildServer"/> | |
161 <attribute name="out" default="${teamcity.internal.default.out}" description="directory storing prepared plugin zip"/> | |
162 | |
163 <sequential> | |
164 <copy file="@{out}/@{name}.zip" todir="@{teamcity.data.path}/plugins" failonerror="true"/> | |
165 </sequential> | |
166 </macrodef> | |
167 | |
168 <macrodef name="undeploy.teamcity.plugin"> | |
169 <attribute name="name"/> | |
170 <attribute name="teamcity.data.path" default="${user.home}/.BuildServer" description="path to .BuildServer"/> | |
171 | |
172 <sequential> | |
173 <delete file="@{teamcity.data.path}/plugins/@{name}.zip" quiet="true"/> | |
174 </sequential> | |
175 </macrodef> | |
176 | |
177 | |
178 <macrodef name="unpack.teamcity" description="TeamCity distribution unpacking"> | |
179 <attribute name="distribution.dir" default="${basedir}/teamcity-dist" | |
180 description="path to put unpacked TeamCity distribution into. Warning: the content of the directory will be deleted!"/> | |
181 <attribute name="teamcity.data.path" default="${user.home}/.BuildServer" description="path to .BuildServer"/> | |
182 <attribute name="teamcity.tar.gz-location" default="${basedir}" description="path where TeamCity-NNNN.tar.gz file resides"/> | |
183 | |
184 <sequential> | |
185 <delete dir="@{distribution.dir}" quiet="true"/> | |
186 <mkdir dir="@{distribution.dir}"/> | |
187 | |
188 <!-- TODO: issue error if there are several matching files --> | |
189 | |
190 <untar compression="gzip" dest="@{distribution.dir}"> | |
191 <fileset dir="@{teamcity.tar.gz-location}"> | |
192 <include name="*.tar.gz"/> | |
193 </fileset> | |
194 </untar> | |
195 | |
196 <move todir="@{distribution.dir}"> | |
197 <fileset dir="@{distribution.dir}\TeamCity"> | |
198 <include name="**"/> | |
199 </fileset> | |
200 </move> | |
201 </sequential> | |
202 </macrodef> | |
203 | |
204 | |
205 <!-- ** Implementation ** --> | |
206 | |
207 <macrodef name="check.property"> | |
208 <attribute name="name"/> | |
209 <attribute name="fail-message" default=""/> | |
210 <attribute name="check-path" default=""/> | |
211 <sequential> | |
212 <condition property="is.configured.@{name}"> | |
213 <not> | |
214 <and> | |
215 <isset property="@{name}"/> | |
216 <length string="${@{name}}" when="greater" length="0"/> | |
217 </and> | |
218 </not> | |
219 </condition> | |
220 <fail if="is.configured.@{name}" | |
221 message="Property '@{name}' not defined. @{fail-message}"/> | |
222 </sequential> | |
223 </macrodef> | |
224 | |
225 | |
226 <target name="prepare.common.part" if="common.needed"> | |
227 <jar destfile="${common.jar.path}"> | |
228 <fileset dir="${common.output}"/> | |
229 </jar> | |
230 </target> | |
231 | |
232 | |
233 <target name="prepare.server.part" if="server.needed"> | |
234 <mkdir dir="${out.unpacked}/server"/> | |
235 | |
236 <jar destfile="${out.unpacked}/server/${name}.jar"> | |
237 <fileset dir="${server.output}"/> | |
238 </jar> | |
239 | |
240 <copy todir="${out.unpacked}/server" failonerror="false"> | |
241 <fileset file="${common.jar.path}"/> | |
242 <fileset dir="${lib.dir}" includes="${lib.includes}"/> | |
243 </copy> | |
244 </target> | |
245 | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
246 <target name="pack.agent.part" if="agent.needed"> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
247 <zip destfile="${out.unpacked}/agent/${name}.zip"> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
248 <fileset dir="${teamcity.internal.distrib.prep.agent.jars}"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
249 </zip> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
250 </target> |
76 | 251 |
252 <target name="prepare.agent.part" if="agent.needed"> | |
253 <!-- prepare.agent.part --> | |
254 <mkdir dir="${teamcity.internal.distrib.prep.agent}"/> | |
255 <mkdir dir="${teamcity.internal.distrib.prep.agent.jars}/${name}/lib"/> | |
256 <mkdir dir="${out.unpacked}/agent"/> | |
257 | |
258 <jar destfile="${teamcity.internal.distrib.prep.agent.jars}/${name}/lib/${name}.jar"> | |
259 <fileset dir="${agent.output}"/> | |
260 </jar> | |
261 | |
262 <copy todir="${teamcity.internal.distrib.prep.agent.jars}/${name}/lib" failonerror="false"> | |
263 <fileset file="${common.jar.path}"/> | |
264 </copy> | |
265 </target> | |
266 | |
267 <target name="prepare.plugin.descriptor.file" if="plugin.descriptor.file.needed"> | |
268 <echo message="Copying plugin descriptor file '${source}' to '${dest}'."/> | |
269 <copy file="${source}" tofile="${dest}" failonerror="false"/> | |
270 | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
271 <echo message="Replacing '@Plugin_Version@', '@Plugin_Vendor@' and '@Plugin_Vendor_Url@' in the copied plugin descriptor file."/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
272 <replace file="${dest}"> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
273 <replacefilter token="@version@" value="${plugin.version}"/> |
104 | 274 <replacefilter token="@Plugin_Version@" value="${plugin.version}"/> |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
275 <replacefilter token="@Plugin_Vendor@" value="${plugin.vendor}"/> |
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
276 <replacefilter token="@Plugin_Vendor_Url@" value="${plugin.vendor.url}"/> |
76 | 277 </replace> |
278 </target> | |
279 | |
280 <target name="check.already.defined"> | |
281 <condition property="already.defined"> | |
282 <isset property="teamcity.internal.distrib.prep"/> | |
283 </condition> | |
284 <fail if="already.defined" | |
285 message="It seems you are trying to use the script several times in the same context. This script does not support such use. Please call this script as a separate Ant process, via 'ant' task."/> | |
286 </target> | |
287 | |
108
63fcc9b14221
update teamcity-common.xml and teamcity-plugin.xml
C:\Users\pavel.sher\AppData\Roaming\The Bat!
parents:
104
diff
changeset
|
288 </project> |