blob: 3bcc4cada128c395c96386749f56996cb1a6f8f6 [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 -->
david_williams6913d4d2010-04-03 05:05:16 +0000222 <zip
223 destfile="${buildDirectory}/${buildLabel}/${archiveName}"
224 basedir="${tmpsite}/unpacked"
225 update="false"
226 duplicate="preserve"/>
227 <!-- always produce checksum files for any zips produced -->
228 <antcall
229 target="createChecksums"/>
230 <!--
231 ==================================================================================
232 10. can now remove tmpsite as no longer needed, unless
233 debugging
234 ==================================================================================
235 -->
236 <antcall
237 target="deleteTmpSite"/>
238 </target>
239 <!--
240 ==============================================================================================
241 Utility and Helper tasks
242 ==============================================================================================
243 -->
244 <target
245 name="init"
246 depends="check.sign">
247 <condition
248 property="verboseIfDebug"
249 value="-verbose"
250 else="">
251 <istrue
252 value="${debugOptimization}"/>
253 </condition>
254 <condition
255 property="logIfDebug"
256 value="-debug -consolelog"
257 else="">
258 <istrue
259 value="${debugOptimization}"/>
260 </condition>
261 <condition
262 property="keepIfDebug"
263 value="true">
264 <istrue
265 value="${debugOptimization}"/>
266 </condition>
267 <!-- don't normalize if signing, since then it's done by signing -->
268 <condition
269 property="doNormalize"
270 value="true">
271 <and>
272 <istrue
273 value="${normalizeJarFiles}"/>
274 <not>
275 <equals
276 arg1="${doSign}"
277 arg2="true"
278 trim="true"
279 casesensitive="false"/>
280 </not>
281 </and>
282 </condition>
283 <condition
284 property="doPack"
285 value="true">
286 <and>
287 <istrue
288 value="${packJarFiles}"/>
289 <istrue
290 value="${createP2repo}"/>
291 <and>
292 <or>
293 <istrue
294 value="${normalizeJarFiles}"/>
295 <istrue
296 value="${doSign}"/>
297 </or>
298 </and>
299 </and>
300 </condition>
301 <condition
302 property="excludeFromRepoZip"
303 value="site.xml">
304 <isfalse
305 value="${doPack}"/>
306 </condition>
307 <condition
308 property="excludeFromRepoZip"
309 value="site.xml,plugins/*.jar,features/*.jar">
310 <istrue
311 value="${doPack}"/>
312 </condition>
313 <condition
314 property="archiveDir"
315 value="${tmpsite}/normalized">
316 <istrue
317 value="${doPack}"/>
318 </condition>
319 <condition
320 property="archiveDir"
321 value="${buildDirectory}/${buildLabel}">
322 <isfalse
323 value="${doPack}"/>
324 </condition>
325 <condition
326 property="doP2Repo"
327 value="true">
328 <available
329 file="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
330 </condition>
331 <!-- echo important values, so it's documneted in build logs -->
332 <echo
333 message="doPack: ${doPack}"/>
334 <echo
335 message="packJarFiles: ${packJarFiles}"/>
336 <echo
337 message="normalizeJarFiles: ${normalizeJarFiles}"/>
338 <echo
339 message="doSign: ${doSign}"/>
340 <echo
341 message="doNormalize: ${doNormalize}"/>
342 <echo
343 message="doP2Repo: ${doP2Repo}"/>
344 </target>
345 <target
346 name="deleteTmpSite"
347 unless="keepIfDebug">
348 <delete
349 dir="${tmpsite}"/>
350 </target>
351 <target
352 name="normalizeJarFiles"
353 if="doNormalize"
354 depends="init">
355 <!--
356 stick with JAVA5 for signing/packing for now ... I've heard
357 rumors of some 'compatibility' issues with JAVA6?
358 -->
359 <echo
360 message="Starting normalizeJarFiles"/>
361 <echo
362 message="archiveDir: ${archiveDir}"/>
363 <java
364 jar="${eclipse.launcher}"
365 fork="true"
366 jvm="${env.JAVA_5_HOME}/bin/java"
367 failonerror="true"
368 maxmemory="512m"
369 dir="${buildDirectory}">
370 <jvmarg
371 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
372 <arg
373 line="${logIfDebug}"/>
374 <arg
375 line="-application org.eclipse.update.core.siteOptimizer"/>
376 <!--
377 note: this -processAll option is critical in this first
378 step. For various reasons, jarProcessor is written to
379 not act on any jar if the jar is not "marked", or if not
380 told explicitly to to processAll. There are ways where
381 not all are literally processed, such as using
382 pack.properties (and others, see
383 http://wiki.eclipse.org/JarProcessor_Options).
384 -->
385 <arg
386 line="-jarProcessor ${verboseIfDebug} -processAll -outputDir ${archiveDir} -repack ${buildDirectory}/${buildLabel}/${archiveName}"/>
387 </java>
388 </target>
389 <target
390 name="createPackFilesIfDesired"
391 if="doPack"
392 depends="init">
393 <!--
394 stick with JAVA5 for signing/packing for now ... I've heard
395 rumors of some 'compatibility' issues with JAVA6?
396 -->
397 <!--
398 <java
399 jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
400 fork="true" jvm="${env.JAVA_5_HOME}/bin/java"
401 failonerror="true" maxmemory="512m" dir="${buildDirectory}">
402 <jvmarg
403 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/> <arg
404 line="${logIfDebug}"/> <arg line="-application
405 org.eclipse.update.core.siteOptimizer"/> <arg
406 line="-jarProcessor ${verboseIfDebug} -outputDir
407 ${buildDirectory}/${buildLabel}/repository -pack
408 ${buildDirectory}/${buildLabel}/repository"/> </java>
409 -->
410 <java
411 jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
412 fork="true"
413 jvm="${env.JAVA_5_HOME}/bin/java"
414 failonerror="true"
415 maxmemory="512m"
416 dir="${buildDirectory}">
417 <jvmarg
418 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
419 <arg
420 line="${logIfDebug}"/>
421 <arg
422 line="-application org.eclipse.update.core.siteOptimizer"/>
423 <arg
424 line="-jarProcessor ${verboseIfDebug} -outputDir ${buildDirectory}/${buildLabel}/${component}/repository -pack ${buildDirectory}/${buildLabel}/${component}/repository"/>
425 </java>
426 </target>
427 <!--
428 always make copy, since normally either normalized, or signed
429 (and normalized) TODO: (minor) tiny improvement in efficiency
430 could be made, for N-builds?, that are neither normalized nor
431 signed.
432 -->
433 <target
434 name="makeCopyForUpdate">
435 <mkdir
436 dir="${buildDirectory}/${buildLabel}/repository"/>
437 <copy
438 todir="${buildDirectory}/${buildLabel}/repository"
439 overwrite="false">
440 <fileset
441 dir="${tmpsite}/eclipse">
442 </fileset>
443 </copy>
444 <mkdir
445 dir="${buildDirectory}/${buildLabel}/${component}/repository"/>
446 <copy
447 todir="${buildDirectory}/${buildLabel}/${component}/repository"
448 overwrite="false">
449 <fileset
450 dir="${tmpsite}/eclipse">
451 </fileset>
452 </copy>
453 </target>
454 <target
455 name="makeBackupCopyForDebugging"
456 if="keepIfDebug">
457 <!--
458 temporary copy while confirming build to be able to do
459 side-by-side comparisons
460 -->
461 <mkdir
462 dir="${buildDirectory}/backuporiginalzips"/>
463 <copy
464 file="${buildDirectory}/${buildLabel}/${archiveName}"
465 todir="${buildDirectory}/backuporiginalzips"/>
466 </target>
467 <target
468 name="createChecksums">
469 <!--
470 This createChecksums task creates two files, for use in two
471 contexts. a. an x.md5 file, that has the name of the file in
472 the contents. This is good for some "third party"
473 executables, like md5summ, that expects the name in the
474 file. b. since ant does not deal well with md5 files with
475 anything in them other than the checksum, we provide same
476 thing in a file with an md5antformat extension, that has
477 only the checksum.
478 -->
479 <mkdir
480 dir="${buildDirectory}/${buildLabel}/checksum"/>
481 <checksum
482 file="${buildDirectory}/${buildLabel}/${archiveName}"
david_williams455e9842010-04-04 00:18:08 +0000483 todir="${buildDirectory}/${buildLabel}/checksum/"
david_williamsd86830b2010-04-04 01:31:34 +0000484 pattern="{0} *{1}"
485 fileext=".md5"
486 algorithm="MD5"/>
487 <checksum
488 file="${buildDirectory}/${buildLabel}/${archiveName}"
489 todir="${buildDirectory}/${buildLabel}/checksum/"
490 pattern="{0} *{1}"
491 fileext=".sha1"
492 algorithm="SHA1"/>
david_williams6913d4d2010-04-03 05:05:16 +0000493 </target>
494 <target
495 name="check.sign">
496 <echo
497 message="sign: ${sign}"/>
498 <echo
499 message="env skip jar signing: ${env.SKIP_JAR_SIGNING}"/>
500 <echo
501 message="skip jar signing: ${SKIP_JAR_SIGNING}"/>
502 <condition
503 property="doSign">
504 <and>
505 <equals
506 arg1="${sign}"
507 arg2="true"
508 trim="true"
509 casesensitive="false"/>
510 <not>
511 <equals
512 arg1="${env.SKIP_JAR_SIGNING}"
513 arg2="true"
514 trim="true"
515 casesensitive="false"/>
516 </not>
517 <not>
518 <equals
519 arg1="${SKIP_JAR_SIGNING}"
520 arg2="true"
521 trim="true"
522 casesensitive="false"/>
523 </not>
524 </and>
525 </condition>
526 <echo
527 message="doSign: ${doSign}"/>
528 </target>
529
530 <!-- Call the p2 metadata generator on the update site. -->
531 <!-- TODO: do we need to pack200 files first? (create gz files?) -->
532 <target
533 name="generateP2Metadata"
534 depends="init"
535 if="doP2Repo">
536
537
538 <!-- 1. Generate the P2 metadata -->
539 <!--
david_williamsd86830b2010-04-04 01:31:34 +0000540 initial generation now hanlded by p2.gathering=true in
541 build.properties
david_williams6913d4d2010-04-03 05:05:16 +0000542 -->
543 <!--
david_williamsd86830b2010-04-04 01:31:34 +0000544 TODO: should "merge" component repos into main one here?
david_williams6913d4d2010-04-03 05:05:16 +0000545 -->
546 <!--
547 2. Create zip of P2 repo. Note we put it in
548 'repoBaseLocation' for use by subsequent build steps TODO:
549 investigate a location outside a per-build location
550 -->
551 <mkdir
552 dir="${buildDirectory}/${buildLabel}/repos"/>
553 <zip
554 destfile="${buildDirectory}/${buildLabel}/repos/${component}-buildrepo-${buildLabel}.zip"
555 basedir="${buildDirectory}/${buildLabel}/${component}/repository/"
556 excludes="${excludeFromRepoZip}"
557 update="yes"
558 duplicate="preserve">
559 </zip>
560 <!--
561 <zip
562 destfile="${buildDirectory}/${buildLabel}/repos/${build.distribution}-buildrepo-${buildLabel}.zip"
563 basedir="${buildDirectory}/${buildLabel}/repository/"
564 excludes="${excludeFromRepoZip}" update="yes"
565 duplicate="preserve"> </zip>
566 -->
567 <!--
568 3. generate maps each step TODO: avoid double processing by
569 changing task so that if file exists, append to it
570 -->
571 <generateMapFiles
572 buildlabel="${buildLabel}"
573 inputFilePluginVersions="${buildDirectory}/finalPluginsVersions.properties"
574 inputFileFeatureVersions="${buildDirectory}/finalFeaturesVersions.properties"
575 p2MapFile="${buildDirectory}/${buildLabel}/Web-Tools-Platform-${buildLabel}.p2.map"
576 p2Repository="http://build.eclipse.org/webtools/committers/${projectname}/${buildLabel}/repository"/>
577 </target>
578 <target
579 name="createSiteFiles"
580 depends="init"
581 if="doP2Repo">
582 <property
583 name="sitexmlfile"
584 value="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
585 <property
586 file="${buildDirectory}/finalFeaturesVersions.properties"/>
587 <loadfile
588 property="sitefiletext"
589 srcFile="${sitexmlfile}">
590 <filterchain>
591 <expandproperties/>
592 </filterchain>
593 </loadfile>
594 <echo
595 message="${sitefiletext}"
596 file="${buildDirectory}/${buildLabel}/repository/site.xml"/>
597 <echo
598 message="${sitefiletext}"
599 file="${buildDirectory}/${buildLabel}/${component}/repository/site.xml"/>
600 </target>
601 <target
602 name="updatePackPropertiesFile"
603 if="doNormalize">
604 <updatePackProperties
605 archiveFilename="${buildDirectory}/${buildLabel}/${archiveName}"/>
606 </target>
607 <target
david_williams455e9842010-04-04 00:18:08 +0000608 name="createTraditionalZipFiles"
609 depends="init">
david_williamsd86830b2010-04-04 01:31:34 +0000610 <p2.repo2runnable>
611 <repository
612 location="file:/${buildDirectory}/${buildLabel}/${component}/runnable"/>
613 <source>
614 <repository
615 location="${p2.build.repo}"/>
616 </source>
617 </p2.repo2runnable>
618 <property
619 name="ziparchiveName"
620 value="${component}-${buildLabel}.zip"/>
621 <copy
622 todir="${buildDirectory}/${buildLabel}/${component}/runnable"
623 overwrite="false">
624 <fileset
625 dir="${wtp.builder.home}/rootfiles">
626 </fileset>
627 </copy>
628 <zip
629 destfile="${buildDirectory}/${buildLabel}/${ziparchiveName}">
630 <zipfileset
631 dir="${buildDirectory}/${buildLabel}/${component}/runnable"
632 excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
633 </zip>
634 <antcall
635 target="createChecksums">
636 <param
637 name="archiveName"
638 value="${ziparchiveName}"/>
639 </antcall>
640 </target>
david_williams455e9842010-04-04 00:18:08 +0000641 <target
david_williams6913d4d2010-04-03 05:05:16 +0000642 name="nodefault">
643 <echo
644 level="error"
645 message="There is no default target for this buildutililites.xml ant script."/>
646 </target>
647</project>