blob: e355ca058049ac17a9806bf7b1a0b050b890cf53 [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 -->
15 <property
16 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"/>
73 <!--
74 ==================================================================================
75 Primary Task: unpackUpdateJarsAndCreateZippedPackages This task
76 takes a zip file of update jars, which is created by PDE build
77 process, and "converts" it to a traditional zip file, processing
78 the jars with pack200 for better compression on update sites.
79 ==================================================================================
80 -->
81 <target
82 name="unpackUpdateJarsAndCreateZippedPackages"
83 depends="init">
84 <!--
85 ==================================================================================
86 1. make "backup" copy of original zip, if debugging, since
87 might be needed for comparison
88 ==================================================================================
89 -->
90 <antcall
91 target="makeBackupCopyForDebugging"/>
92 <!--
93 add pack.properties file that specifies effort level, and
94 files not to sign We don't have to do this if not
95 normalizing and not signing
96 -->
97 <antcall
98 target="updatePackPropertiesFile"/>
99 <!--
100 ==================================================================================
101 2. normalize jars here, from a zip file of update jars. The
102 normalized jars are put in zip file of same name, in a
103 directory named normalized
104 ==================================================================================
105 -->
106 <echo
107 level="info"
108 message="normalize jars if desired ..."/>
109 <antcall
110 target="normalizeJarFiles"/>
111 <echo
112 level="info"
113 message="normalized jars: ${normalizeJarFiles}"/>
114 <!--
115 ==================================================================================
116 3. sign the jars in archive file, if desired
117 ==================================================================================
118 -->
119 <ant
120 antfile="${wtp.builder.home}/scripts/build/signjars.xml"/>
121 <!--
122 ==================================================================================
123 4. unzip the normalized jars in the zip file produced in
124 step 1., to the directory {tmpsite} for further processing.
125 plugins and features end up in {tmpsite}/eclipse
126 ==================================================================================
127 -->
128 <echo
129 level="info"
130 message="unzip normalized update jars to a holding place"/>
131 <echo
132 level="info"
133 message="tmpsite: ${tmpsite}"/>
134 <echo
135 level="info"
136 message="archiveDir: ${archiveDir}"/>
137 <echo
138 level="info"
139 message="archiveName: ${archiveName}"/>
140 <unzip
141 dest="${tmpsite}"
142 src="${archiveDir}/${archiveName}"/>
143 <!--
144 ==================================================================================
145 5. copy all update jars to a common update site directory,
146 if desired. Note: overwite is false to avoid "touching"
147 files already produced and processed by previous steps in a
148 larger build process. This means the repository *must* be
149 completely clean before the larger process starts.
150 ==================================================================================
151 -->
152 <antcall
153 target="makeCopyForUpdate"/>
154 <!--
155 ==================================================================================
156 6. for modularity, pack200 is done here, optionally. The
157 resulting gz files are produced in update site directory.
158 This is optional since processing is expensive to do for
159 every build. Only need when ready to declare an update site,
160 and, for exmaple, no need to do for "local" or HEAD builds
161 since developers wouldn't normally need it for a quick check
162 of a build.
163 ==================================================================================
164 -->
165 <echo
166 level="info"
167 message="create pack files if desired ..."/>
168 <antcall
169 target="createPackFilesIfDesired"/>
170 <echo
171 level="info"
172 message="created pack files: ${packJarFiles}"/>
173 <!--
174 7. create a site.xml file, by merging a template site.xml
175 with the feature versions produced by PDE build
176 -->
177 <antcall
178 target="createSiteFiles"/>
179
180 <!-- 8. now generate P2 meta data for that P2 repo -->
181 <echo
182 level="info"
183 message="Generating p2 metadata for P2 repo."/>
184 <antcall
185 target="generateP2Metadata"/>
186 <!--
187 ==================================================================================
188 9. now create traditional zip file of unpacked jars. This
189 type of "unpack" is not related to pack200, but instead
190 means to unpack those jars that are supposed to be unpacked
191 based on feature defintion, if the plugin's unpack attribute
192 is set to true in the feature
193 ==================================================================================
194 -->
195 <!-- use releng task of unpackUpdateJars -->
196 <unpackUpdateJars
197 site="${tmpsite}/eclipse"
198 output="${tmpsite}/unpacked/eclipse"/>
199 <!--
200 add copy of legal doc's here, product.ini, etc., before
201 re-zipping
202 -->
203 <copy
204 todir="${tmpsite}/unpacked/eclipse"
205 overwrite="false">
206 <fileset
207 dir="${wtp.builder.home}/rootfiles">
208 </fileset>
209 </copy>
210 <!--
211 delete the zip file of update jars we started with, which we
212 are about to re-create as traditional zip file
213 -->
214 <delete
215 file="${buildDirectory}/${buildLabel}/${archiveName}"/>
216 <mkdir
217 dir="${buildDirectory}/${buildLabel}"/>
218 <!--
219 recreate zip file now, same name, traditional content, which
220 is mix of folders and jars
221 -->
222
223 <zip
224 destfile="${buildDirectory}/${buildLabel}/${archiveName}"
225 basedir="${tmpsite}/unpacked"
226 update="false"
227 duplicate="preserve"/>
228 <!-- always produce checksum files for any zips produced -->
229 <antcall
230 target="createChecksums"/>
231 <!--
232 ==================================================================================
233 10. can now remove tmpsite as no longer needed, unless
234 debugging
235 ==================================================================================
236 -->
237 <antcall
238 target="deleteTmpSite"/>
239 </target>
240 <!--
241 ==============================================================================================
242 Utility and Helper tasks
243 ==============================================================================================
244 -->
245 <target
246 name="init"
247 depends="check.sign">
248 <condition
249 property="verboseIfDebug"
250 value="-verbose"
251 else="">
252 <istrue
253 value="${debugOptimization}"/>
254 </condition>
255 <condition
256 property="logIfDebug"
257 value="-debug -consolelog"
258 else="">
259 <istrue
260 value="${debugOptimization}"/>
261 </condition>
262 <condition
263 property="keepIfDebug"
264 value="true">
265 <istrue
266 value="${debugOptimization}"/>
267 </condition>
268 <!-- don't normalize if signing, since then it's done by signing -->
269 <condition
270 property="doNormalize"
271 value="true">
272 <and>
273 <istrue
274 value="${normalizeJarFiles}"/>
275 <not>
276 <equals
277 arg1="${doSign}"
278 arg2="true"
279 trim="true"
280 casesensitive="false"/>
281 </not>
282 </and>
283 </condition>
284 <condition
285 property="doPack"
286 value="true">
287 <and>
288 <istrue
289 value="${packJarFiles}"/>
290 <istrue
291 value="${createP2repo}"/>
292 <and>
293 <or>
294 <istrue
295 value="${normalizeJarFiles}"/>
296 <istrue
297 value="${doSign}"/>
298 </or>
299 </and>
300 </and>
301 </condition>
302 <condition
303 property="excludeFromRepoZip"
304 value="site.xml">
305 <isfalse
306 value="${doPack}"/>
307 </condition>
308 <condition
309 property="excludeFromRepoZip"
310 value="site.xml,plugins/*.jar,features/*.jar">
311 <istrue
312 value="${doPack}"/>
313 </condition>
314 <condition
315 property="archiveDir"
316 value="${tmpsite}/normalized">
317 <istrue
318 value="${doPack}"/>
319 </condition>
320 <condition
321 property="archiveDir"
322 value="${buildDirectory}/${buildLabel}">
323 <isfalse
324 value="${doPack}"/>
325 </condition>
326 <condition
327 property="doP2Repo"
328 value="true">
329 <available
330 file="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
331 </condition>
332 <!-- echo important values, so it's documneted in build logs -->
333 <echo
334 message="doPack: ${doPack}"/>
335 <echo
336 message="packJarFiles: ${packJarFiles}"/>
337 <echo
338 message="normalizeJarFiles: ${normalizeJarFiles}"/>
339 <echo
340 message="doSign: ${doSign}"/>
341 <echo
342 message="doNormalize: ${doNormalize}"/>
343 <echo
344 message="doP2Repo: ${doP2Repo}"/>
345 </target>
346 <target
347 name="deleteTmpSite"
348 unless="keepIfDebug">
349 <delete
350 dir="${tmpsite}"/>
351 </target>
352 <target
353 name="normalizeJarFiles"
354 if="doNormalize"
355 depends="init">
356 <!--
357 stick with JAVA5 for signing/packing for now ... I've heard
358 rumors of some 'compatibility' issues with JAVA6?
359 -->
360 <echo
361 message="Starting normalizeJarFiles"/>
362 <echo
363 message="archiveDir: ${archiveDir}"/>
364 <java
365 jar="${eclipse.launcher}"
366 fork="true"
367 jvm="${env.JAVA_5_HOME}/bin/java"
368 failonerror="true"
369 maxmemory="512m"
370 dir="${buildDirectory}">
371 <jvmarg
372 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
373 <arg
374 line="${logIfDebug}"/>
375 <arg
376 line="-application org.eclipse.update.core.siteOptimizer"/>
377 <!--
378 note: this -processAll option is critical in this first
379 step. For various reasons, jarProcessor is written to
380 not act on any jar if the jar is not "marked", or if not
381 told explicitly to to processAll. There are ways where
382 not all are literally processed, such as using
383 pack.properties (and others, see
384 http://wiki.eclipse.org/JarProcessor_Options).
385 -->
386 <arg
387 line="-jarProcessor ${verboseIfDebug} -processAll -outputDir ${archiveDir} -repack ${buildDirectory}/${buildLabel}/${archiveName}"/>
388 </java>
389 </target>
390 <target
391 name="createPackFilesIfDesired"
392 if="doPack"
393 depends="init">
394 <!--
395 stick with JAVA5 for signing/packing for now ... I've heard
396 rumors of some 'compatibility' issues with JAVA6?
397 -->
398 <!--
399 <java
400 jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
401 fork="true" jvm="${env.JAVA_5_HOME}/bin/java"
402 failonerror="true" maxmemory="512m" dir="${buildDirectory}">
403 <jvmarg
404 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/> <arg
405 line="${logIfDebug}"/> <arg line="-application
406 org.eclipse.update.core.siteOptimizer"/> <arg
407 line="-jarProcessor ${verboseIfDebug} -outputDir
408 ${buildDirectory}/${buildLabel}/repository -pack
409 ${buildDirectory}/${buildLabel}/repository"/> </java>
410 -->
411 <java
412 jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
413 fork="true"
414 jvm="${env.JAVA_5_HOME}/bin/java"
415 failonerror="true"
416 maxmemory="512m"
417 dir="${buildDirectory}">
418 <jvmarg
419 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
420 <arg
421 line="${logIfDebug}"/>
422 <arg
423 line="-application org.eclipse.update.core.siteOptimizer"/>
424 <arg
425 line="-jarProcessor ${verboseIfDebug} -outputDir ${buildDirectory}/${buildLabel}/${component}/repository -pack ${buildDirectory}/${buildLabel}/${component}/repository"/>
426 </java>
427 </target>
428 <!--
429 always make copy, since normally either normalized, or signed
430 (and normalized) TODO: (minor) tiny improvement in efficiency
431 could be made, for N-builds?, that are neither normalized nor
432 signed.
433 -->
434 <target
435 name="makeCopyForUpdate">
436 <mkdir
437 dir="${buildDirectory}/${buildLabel}/repository"/>
438 <copy
439 todir="${buildDirectory}/${buildLabel}/repository"
440 overwrite="false">
441 <fileset
442 dir="${tmpsite}/eclipse">
443 </fileset>
444 </copy>
445 <mkdir
446 dir="${buildDirectory}/${buildLabel}/${component}/repository"/>
447 <copy
448 todir="${buildDirectory}/${buildLabel}/${component}/repository"
449 overwrite="false">
450 <fileset
451 dir="${tmpsite}/eclipse">
452 </fileset>
453 </copy>
454 </target>
455 <target
456 name="makeBackupCopyForDebugging"
457 if="keepIfDebug">
458 <!--
459 temporary copy while confirming build to be able to do
460 side-by-side comparisons
461 -->
462 <mkdir
463 dir="${buildDirectory}/backuporiginalzips"/>
464 <copy
465 file="${buildDirectory}/${buildLabel}/${archiveName}"
466 todir="${buildDirectory}/backuporiginalzips"/>
467 </target>
468 <target
469 name="createChecksums">
470 <!--
471 This createChecksums task creates two files, for use in two
472 contexts. a. an x.md5 file, that has the name of the file in
473 the contents. This is good for some "third party"
474 executables, like md5summ, that expects the name in the
475 file. b. since ant does not deal well with md5 files with
476 anything in them other than the checksum, we provide same
477 thing in a file with an md5antformat extension, that has
478 only the checksum.
479 -->
480 <mkdir
481 dir="${buildDirectory}/${buildLabel}/checksum"/>
482 <checksum
483 file="${buildDirectory}/${buildLabel}/${archiveName}"
484 property="md5"/>
485 <echo
486 message="${md5} *${archiveName}"
487 file="${buildDirectory}/${buildLabel}/checksum/${archiveName}.md5"/>
488 <echo
489 message="${md5}"
490 file="${buildDirectory}/${buildLabel}/checksum/${archiveName}.md5antformat"/>
491 </target>
492 <target
493 name="check.sign">
494 <echo
495 message="sign: ${sign}"/>
496 <echo
497 message="env skip jar signing: ${env.SKIP_JAR_SIGNING}"/>
498 <echo
499 message="skip jar signing: ${SKIP_JAR_SIGNING}"/>
500 <condition
501 property="doSign">
502 <and>
503 <equals
504 arg1="${sign}"
505 arg2="true"
506 trim="true"
507 casesensitive="false"/>
508 <not>
509 <equals
510 arg1="${env.SKIP_JAR_SIGNING}"
511 arg2="true"
512 trim="true"
513 casesensitive="false"/>
514 </not>
515 <not>
516 <equals
517 arg1="${SKIP_JAR_SIGNING}"
518 arg2="true"
519 trim="true"
520 casesensitive="false"/>
521 </not>
522 </and>
523 </condition>
524 <echo
525 message="doSign: ${doSign}"/>
526 </target>
527
528 <!-- Call the p2 metadata generator on the update site. -->
529 <!-- TODO: do we need to pack200 files first? (create gz files?) -->
530 <target
531 name="generateP2Metadata"
532 depends="init"
533 if="doP2Repo">
534
535
536 <!-- 1. Generate the P2 metadata -->
537 <!--
538 initial generation now hanlded by
539 p2.gathering=true
540 in build.properties
541 -->
542 <!--
543 TODO: should "merge" component repos into main one here?
544 -->
545 <!--
546 2. Create zip of P2 repo. Note we put it in
547 'repoBaseLocation' for use by subsequent build steps TODO:
548 investigate a location outside a per-build location
549 -->
550 <mkdir
551 dir="${buildDirectory}/${buildLabel}/repos"/>
552 <zip
553 destfile="${buildDirectory}/${buildLabel}/repos/${component}-buildrepo-${buildLabel}.zip"
554 basedir="${buildDirectory}/${buildLabel}/${component}/repository/"
555 excludes="${excludeFromRepoZip}"
556 update="yes"
557 duplicate="preserve">
558 </zip>
559 <!--
560 <zip
561 destfile="${buildDirectory}/${buildLabel}/repos/${build.distribution}-buildrepo-${buildLabel}.zip"
562 basedir="${buildDirectory}/${buildLabel}/repository/"
563 excludes="${excludeFromRepoZip}" update="yes"
564 duplicate="preserve"> </zip>
565 -->
566 <!--
567 3. generate maps each step TODO: avoid double processing by
568 changing task so that if file exists, append to it
569 -->
570 <generateMapFiles
571 buildlabel="${buildLabel}"
572 inputFilePluginVersions="${buildDirectory}/finalPluginsVersions.properties"
573 inputFileFeatureVersions="${buildDirectory}/finalFeaturesVersions.properties"
574 p2MapFile="${buildDirectory}/${buildLabel}/Web-Tools-Platform-${buildLabel}.p2.map"
575 p2Repository="http://build.eclipse.org/webtools/committers/${projectname}/${buildLabel}/repository"/>
576 </target>
577 <target
578 name="createSiteFiles"
579 depends="init"
580 if="doP2Repo">
581 <property
582 name="sitexmlfile"
583 value="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
584 <property
585 file="${buildDirectory}/finalFeaturesVersions.properties"/>
586 <loadfile
587 property="sitefiletext"
588 srcFile="${sitexmlfile}">
589 <filterchain>
590 <expandproperties/>
591 </filterchain>
592 </loadfile>
593 <echo
594 message="${sitefiletext}"
595 file="${buildDirectory}/${buildLabel}/repository/site.xml"/>
596 <echo
597 message="${sitefiletext}"
598 file="${buildDirectory}/${buildLabel}/${component}/repository/site.xml"/>
599 </target>
600 <target
601 name="updatePackPropertiesFile"
602 if="doNormalize">
603 <updatePackProperties
604 archiveFilename="${buildDirectory}/${buildLabel}/${archiveName}"/>
605 </target>
606 <target
607 name="nodefault">
608 <echo
609 level="error"
610 message="There is no default target for this buildutililites.xml ant script."/>
611 </target>
612</project>