blob: 409711cb00d3f379fbc7c34b26823f4240192e19 [file] [log] [blame]
david_williams6913d4d2010-04-03 05:05:16 +00001<?xml version="1.0" encoding="UTF-8"?>
2<project
3 name="buildutilities"
4 default="nodefault"
5 basedir=".">
6
7 <!-- = = = standard properties pattern = = = -->
8 <!--
9 Note to be cross-platform, "environment variables" are only
10 appropriate for some variables, e.g. ones we set, since
11 properties are case sensitive, even if the environment variables
12 on your operating system are not, e.g. it will be ${env.Path}
13 not ${env.PATH} on Windows
14 -->
david_williamsa544b1f2010-04-04 03:17:30 +000015 <property
david_williams6913d4d2010-04-03 05:05:16 +000016 environment="env"/>
17 <!--
18 Let users override standard properties, if desired. If
19 directory, file, or some properties do not exist, then standard
20 properties will be used.
21 -->
22 <property
23 file="${env.LOCAL_BUILD_PROPERTIES_DIR}/${ant.project.name}.properties"/>
24
25 <!-- = = = end standard properties pattern = = = -->
26
27
28 <!-- if not otherwise set, use these default properties -->
29 <property
30 name="debugOptimization"
31 value="false"/>
32 <!--
33 We should not always normalize ("-repack") jars by default,
34 since in production we sign the jars (which does the -repack for
35 us) and not in production we don't really care so why spend the
36 extra time. For jars which are not supposed to be normalized,
37 such as pre-existing jars, they need to be added to the
38 pack.properties file (see the updatePackProperties task). Note:
39 signing does the -repack when we sign. This can be over-ridden
40 by the caller setting normalize to true, but there are know
41 known cases where we want to normalize (and eventually pack) the
42 jar files but not sign them.
43 -->
44 <property
45 name="normalizeJarFiles"
46 value="false"/>
47 <!--
48 we'll currently pack jar files, just as part of "debugging" to
49 help sanity check all is working as expected. Eventually we may
50 want to provide some service there jar files in the bundles
51 directory are packed ... but, there's no known use-case for this
52 so far
53 -->
54 <property
55 name="packJarFiles"
56 value="false"/>
57 <!--
58 Let tmp site be global. Note: we use this odd
59 "tmpsite-archiveName-temp" to make sure unique directories,
60 since in some cases these directories can not be deleted from
61 ant, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=142926,
62 and since directory names ending in .zip are misinterpreted by
63 jarProcessor, see
64 https://bugs.eclipse.org/bugs/show_bug.cgi?id=143385 But, its
65 handy to do as unique directories anyway, since if a larger
66 process calls this mulitiple times, on different zips, and if
67 debugging is turnned on, then all the tmpsite directories are
68 left on disk for post-build inspection.
69 -->
70 <property
71 name="tmpsite"
72 value="${buildDirectory}/tmpsite-${archiveName}-temp"/>
david_williams6913d4d2010-04-03 05:05:16 +000073 <target
david_williamsa544b1f2010-04-04 03:17:30 +000074 name="conditionAndSignJars"
david_williams6913d4d2010-04-03 05:05:16 +000075 depends="init">
david_williamsa544b1f2010-04-04 03:17:30 +000076 <!--
77 if="doSign">
78 -->
79 <!--
80
81 get zip for signing
82 exclude content* artifacts*
83 add pack.properties
84 send to eclipse and wait
85 write over p2.build.repo,
86 but update content and artifacts files
87 remove temp file
88 -->
89
90 <zip
91 destfile="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip">
92
93 <zipfileset
94 dir="${buildDirectory}/${buildLabel}/${component}/repository"
95 excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
david_williams2789eee2010-04-04 03:44:01 +000096
david_williamsa544b1f2010-04-04 03:17:30 +000097 </zip>
david_williams2789eee2010-04-04 03:44:01 +000098
99 <updatePackProperties
100 archiveFilename="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"/>
101
david_williamsb2fec472010-04-04 03:58:18 +0000102 <!-- comment out when debugging, for original zip files, before updatePackProperties ran -->
103 <delete file="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip.bak"/>
david_williams2789eee2010-04-04 03:44:01 +0000104
david_williams6913d4d2010-04-03 05:05:16 +0000105 <!--
106 ==================================================================================
david_williamsa544b1f2010-04-04 03:17:30 +0000107 sign the jars in archive file
david_williams6913d4d2010-04-03 05:05:16 +0000108 ==================================================================================
109 -->
david_williamsa544b1f2010-04-04 03:17:30 +0000110 <!--
david_williams6913d4d2010-04-03 05:05:16 +0000111 <ant
david_williamsa544b1f2010-04-04 03:17:30 +0000112 antfile="${wtp.builder.home}/scripts/build/signjars.xml" >
113
114 <property name="archiveName" value="temp-${buildLabel}-${component}.zip"/>
115 </ant>
116-->
117 <!-- remove our temp zip file, once tested, debugged -->
118
119 <!--
david_williams6913d4d2010-04-03 05:05:16 +0000120 ==================================================================================
david_williamsa544b1f2010-04-04 03:17:30 +0000121 for modularity, pack200 is done here, optionally. The
david_williams6913d4d2010-04-03 05:05:16 +0000122 resulting gz files are produced in update site directory.
123 This is optional since processing is expensive to do for
124 every build. Only need when ready to declare an update site,
125 and, for exmaple, no need to do for "local" or HEAD builds
126 since developers wouldn't normally need it for a quick check
127 of a build.
128 ==================================================================================
129 -->
130 <echo
131 level="info"
132 message="create pack files if desired ..."/>
133 <antcall
134 target="createPackFilesIfDesired"/>
135 <echo
136 level="info"
137 message="created pack files: ${packJarFiles}"/>
david_williams6913d4d2010-04-03 05:05:16 +0000138
david_williamsa544b1f2010-04-04 03:17:30 +0000139
david_williams6913d4d2010-04-03 05:05:16 +0000140 </target>
141 <!--
142 ==============================================================================================
143 Utility and Helper tasks
144 ==============================================================================================
145 -->
146 <target
147 name="init"
148 depends="check.sign">
149 <condition
150 property="verboseIfDebug"
151 value="-verbose"
152 else="">
153 <istrue
154 value="${debugOptimization}"/>
155 </condition>
156 <condition
157 property="logIfDebug"
158 value="-debug -consolelog"
159 else="">
160 <istrue
161 value="${debugOptimization}"/>
162 </condition>
163 <condition
164 property="keepIfDebug"
165 value="true">
166 <istrue
167 value="${debugOptimization}"/>
168 </condition>
169 <!-- don't normalize if signing, since then it's done by signing -->
170 <condition
171 property="doNormalize"
172 value="true">
173 <and>
174 <istrue
175 value="${normalizeJarFiles}"/>
176 <not>
177 <equals
178 arg1="${doSign}"
179 arg2="true"
180 trim="true"
181 casesensitive="false"/>
182 </not>
183 </and>
184 </condition>
185 <condition
186 property="doPack"
187 value="true">
188 <and>
189 <istrue
190 value="${packJarFiles}"/>
191 <istrue
192 value="${createP2repo}"/>
193 <and>
194 <or>
195 <istrue
196 value="${normalizeJarFiles}"/>
197 <istrue
198 value="${doSign}"/>
199 </or>
200 </and>
201 </and>
202 </condition>
203 <condition
204 property="excludeFromRepoZip"
205 value="site.xml">
206 <isfalse
207 value="${doPack}"/>
208 </condition>
209 <condition
210 property="excludeFromRepoZip"
211 value="site.xml,plugins/*.jar,features/*.jar">
212 <istrue
213 value="${doPack}"/>
214 </condition>
215 <condition
216 property="archiveDir"
217 value="${tmpsite}/normalized">
218 <istrue
219 value="${doPack}"/>
220 </condition>
221 <condition
222 property="archiveDir"
223 value="${buildDirectory}/${buildLabel}">
224 <isfalse
225 value="${doPack}"/>
226 </condition>
227 <condition
228 property="doP2Repo"
229 value="true">
230 <available
231 file="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
232 </condition>
233 <!-- echo important values, so it's documneted in build logs -->
234 <echo
235 message="doPack: ${doPack}"/>
236 <echo
237 message="packJarFiles: ${packJarFiles}"/>
238 <echo
239 message="normalizeJarFiles: ${normalizeJarFiles}"/>
240 <echo
241 message="doSign: ${doSign}"/>
242 <echo
243 message="doNormalize: ${doNormalize}"/>
244 <echo
245 message="doP2Repo: ${doP2Repo}"/>
246 </target>
david_williamsa544b1f2010-04-04 03:17:30 +0000247
david_williams6913d4d2010-04-03 05:05:16 +0000248 <target
249 name="normalizeJarFiles"
250 if="doNormalize"
251 depends="init">
252 <!--
253 stick with JAVA5 for signing/packing for now ... I've heard
254 rumors of some 'compatibility' issues with JAVA6?
255 -->
256 <echo
257 message="Starting normalizeJarFiles"/>
258 <echo
259 message="archiveDir: ${archiveDir}"/>
260 <java
261 jar="${eclipse.launcher}"
262 fork="true"
263 jvm="${env.JAVA_5_HOME}/bin/java"
264 failonerror="true"
265 maxmemory="512m"
266 dir="${buildDirectory}">
267 <jvmarg
268 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
269 <arg
270 line="${logIfDebug}"/>
271 <arg
272 line="-application org.eclipse.update.core.siteOptimizer"/>
273 <!--
274 note: this -processAll option is critical in this first
275 step. For various reasons, jarProcessor is written to
276 not act on any jar if the jar is not "marked", or if not
277 told explicitly to to processAll. There are ways where
278 not all are literally processed, such as using
279 pack.properties (and others, see
280 http://wiki.eclipse.org/JarProcessor_Options).
281 -->
282 <arg
283 line="-jarProcessor ${verboseIfDebug} -processAll -outputDir ${archiveDir} -repack ${buildDirectory}/${buildLabel}/${archiveName}"/>
284 </java>
285 </target>
286 <target
287 name="createPackFilesIfDesired"
288 if="doPack"
289 depends="init">
290 <!--
david_williamsa544b1f2010-04-04 03:17:30 +0000291 stick with JAVA5 for signing/packing for now ...
292 there are 'compatibility' issues with JAVA6?
david_williams6913d4d2010-04-03 05:05:16 +0000293 -->
david_williamsa544b1f2010-04-04 03:17:30 +0000294
david_williams6913d4d2010-04-03 05:05:16 +0000295 <java
296 jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
297 fork="true"
298 jvm="${env.JAVA_5_HOME}/bin/java"
299 failonerror="true"
300 maxmemory="512m"
301 dir="${buildDirectory}">
302 <jvmarg
303 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
304 <arg
305 line="${logIfDebug}"/>
306 <arg
307 line="-application org.eclipse.update.core.siteOptimizer"/>
308 <arg
309 line="-jarProcessor ${verboseIfDebug} -outputDir ${buildDirectory}/${buildLabel}/${component}/repository -pack ${buildDirectory}/${buildLabel}/${component}/repository"/>
310 </java>
david_williamsa544b1f2010-04-04 03:17:30 +0000311
312 <!-- TODO: need to udpate meta data! -->
313
david_williams6913d4d2010-04-03 05:05:16 +0000314 </target>
315 <!--
316 always make copy, since normally either normalized, or signed
317 (and normalized) TODO: (minor) tiny improvement in efficiency
318 could be made, for N-builds?, that are neither normalized nor
319 signed.
320 -->
321 <target
david_williams6913d4d2010-04-03 05:05:16 +0000322 name="createChecksums">
323 <!--
324 This createChecksums task creates two files, for use in two
325 contexts. a. an x.md5 file, that has the name of the file in
326 the contents. This is good for some "third party"
327 executables, like md5summ, that expects the name in the
328 file. b. since ant does not deal well with md5 files with
329 anything in them other than the checksum, we provide same
330 thing in a file with an md5antformat extension, that has
331 only the checksum.
332 -->
333 <mkdir
334 dir="${buildDirectory}/${buildLabel}/checksum"/>
335 <checksum
336 file="${buildDirectory}/${buildLabel}/${archiveName}"
david_williams455e9842010-04-04 00:18:08 +0000337 todir="${buildDirectory}/${buildLabel}/checksum/"
david_williamsd86830b2010-04-04 01:31:34 +0000338 pattern="{0} *{1}"
339 fileext=".md5"
340 algorithm="MD5"/>
341 <checksum
342 file="${buildDirectory}/${buildLabel}/${archiveName}"
343 todir="${buildDirectory}/${buildLabel}/checksum/"
344 pattern="{0} *{1}"
345 fileext=".sha1"
346 algorithm="SHA1"/>
david_williams6913d4d2010-04-03 05:05:16 +0000347 </target>
348 <target
349 name="check.sign">
350 <echo
351 message="sign: ${sign}"/>
352 <echo
353 message="env skip jar signing: ${env.SKIP_JAR_SIGNING}"/>
354 <echo
355 message="skip jar signing: ${SKIP_JAR_SIGNING}"/>
356 <condition
357 property="doSign">
358 <and>
359 <equals
360 arg1="${sign}"
361 arg2="true"
362 trim="true"
363 casesensitive="false"/>
364 <not>
365 <equals
366 arg1="${env.SKIP_JAR_SIGNING}"
367 arg2="true"
368 trim="true"
369 casesensitive="false"/>
370 </not>
371 <not>
372 <equals
373 arg1="${SKIP_JAR_SIGNING}"
374 arg2="true"
375 trim="true"
376 casesensitive="false"/>
377 </not>
378 </and>
379 </condition>
380 <echo
381 message="doSign: ${doSign}"/>
382 </target>
383
david_williams6913d4d2010-04-03 05:05:16 +0000384
385
david_williams6913d4d2010-04-03 05:05:16 +0000386 <target
david_williams455e9842010-04-04 00:18:08 +0000387 name="createTraditionalZipFiles"
388 depends="init">
david_williamsd86830b2010-04-04 01:31:34 +0000389 <p2.repo2runnable>
390 <repository
391 location="file:/${buildDirectory}/${buildLabel}/${component}/runnable"/>
392 <source>
393 <repository
394 location="${p2.build.repo}"/>
395 </source>
396 </p2.repo2runnable>
397 <property
398 name="ziparchiveName"
399 value="${component}-${buildLabel}.zip"/>
400 <copy
401 todir="${buildDirectory}/${buildLabel}/${component}/runnable"
402 overwrite="false">
403 <fileset
404 dir="${wtp.builder.home}/rootfiles">
405 </fileset>
406 </copy>
407 <zip
408 destfile="${buildDirectory}/${buildLabel}/${ziparchiveName}">
409 <zipfileset
410 dir="${buildDirectory}/${buildLabel}/${component}/runnable"
411 excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
412 </zip>
413 <antcall
414 target="createChecksums">
415 <param
416 name="archiveName"
417 value="${ziparchiveName}"/>
418 </antcall>
419 </target>
david_williams455e9842010-04-04 00:18:08 +0000420 <target
david_williams6913d4d2010-04-03 05:05:16 +0000421 name="nodefault">
422 <echo
423 level="error"
424 message="There is no default target for this buildutililites.xml ant script."/>
425 </target>
426</project>