blob: 4351cf6ce596dfc08ce5419e2b3bcddbc8e86adb [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_williamsdc454d32010-04-04 04:29:41 +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_williamse06113e2010-04-04 04:39:36 +000075 depends="init">
76<!--
david_williamsdc454d32010-04-04 04:29:41 +000077 if="doSign">
david_williamse06113e2010-04-04 04:39:36 +000078 -->
79 <!--
david_williamsdc454d32010-04-04 04:29:41 +000080 get zip for signing exclude content* artifacts* add
81 pack.properties send to eclipse and wait write over
82 p2.build.repo, but update content and artifacts files remove
83 temp file
84 -->
david_williams24902462010-04-04 04:54:38 +000085 <echo message="p2.build.repo: ${p2.build.repo}"/>
david_williamsdc454d32010-04-04 04:29:41 +000086 <zip
87 destfile="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip">
88 <zipfileset
david_williams6b723182010-04-04 05:04:17 +000089 dir="${buildDirectory}/${buildLabel}/${component}/repository/"
david_williamsdc454d32010-04-04 04:29:41 +000090 excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
91 </zip>
92 <updatePackProperties
93 archiveFilename="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"/>
94 <!--
95 comment out when debugging, for original zip files, before
96 updatePackProperties ran
97
98 <delete
99 file="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip.bak"/>
100 -->
david_williams6913d4d2010-04-03 05:05:16 +0000101 <!--
102 ==================================================================================
david_williamsdc454d32010-04-04 04:29:41 +0000103 sign the jars in archive file
david_williams6913d4d2010-04-03 05:05:16 +0000104 ==================================================================================
105 -->
david_williamsdc454d32010-04-04 04:29:41 +0000106 <!--
107 <ant
108 antfile="${wtp.builder.home}/scripts/build/signjars.xml">
109 <property
110 name="archiveName"
111 value="temp-${buildLabel}-${component}.zip"/>
112 </ant>
113 -->
114 <unzip
david_williams0b719c62010-04-04 05:09:59 +0000115 dest="${buildDirectory}/${buildLabel}/${component}/repository/"
116 src="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"/>
david_williams6913d4d2010-04-03 05:05:16 +0000117
david_williamsdc454d32010-04-04 04:29:41 +0000118
119 <!-- TODO we could add 'pack' to this task, if desierd -->
120 <p2.process.artifacts
121 repositoryPath="${p2.build.repo}"/>
122 <!--
123 remove our temp zip file, once tested, debugged <delete
124 file="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"/>
125 -->
david_williams6913d4d2010-04-03 05:05:16 +0000126 </target>
127 <!--
128 ==============================================================================================
129 Utility and Helper tasks
130 ==============================================================================================
131 -->
132 <target
133 name="init"
134 depends="check.sign">
135 <condition
136 property="verboseIfDebug"
137 value="-verbose"
138 else="">
139 <istrue
140 value="${debugOptimization}"/>
141 </condition>
142 <condition
143 property="logIfDebug"
144 value="-debug -consolelog"
145 else="">
146 <istrue
147 value="${debugOptimization}"/>
148 </condition>
149 <condition
150 property="keepIfDebug"
151 value="true">
152 <istrue
153 value="${debugOptimization}"/>
154 </condition>
155 <!-- don't normalize if signing, since then it's done by signing -->
156 <condition
157 property="doNormalize"
158 value="true">
159 <and>
160 <istrue
161 value="${normalizeJarFiles}"/>
162 <not>
163 <equals
164 arg1="${doSign}"
165 arg2="true"
166 trim="true"
167 casesensitive="false"/>
168 </not>
169 </and>
170 </condition>
171 <condition
172 property="doPack"
173 value="true">
174 <and>
175 <istrue
176 value="${packJarFiles}"/>
177 <istrue
178 value="${createP2repo}"/>
179 <and>
180 <or>
181 <istrue
182 value="${normalizeJarFiles}"/>
183 <istrue
184 value="${doSign}"/>
185 </or>
186 </and>
187 </and>
188 </condition>
189 <condition
190 property="excludeFromRepoZip"
191 value="site.xml">
192 <isfalse
193 value="${doPack}"/>
194 </condition>
195 <condition
196 property="excludeFromRepoZip"
197 value="site.xml,plugins/*.jar,features/*.jar">
198 <istrue
199 value="${doPack}"/>
200 </condition>
201 <condition
202 property="archiveDir"
203 value="${tmpsite}/normalized">
204 <istrue
205 value="${doPack}"/>
206 </condition>
207 <condition
208 property="archiveDir"
209 value="${buildDirectory}/${buildLabel}">
210 <isfalse
211 value="${doPack}"/>
212 </condition>
213 <condition
214 property="doP2Repo"
215 value="true">
216 <available
217 file="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
218 </condition>
219 <!-- echo important values, so it's documneted in build logs -->
220 <echo
221 message="doPack: ${doPack}"/>
222 <echo
223 message="packJarFiles: ${packJarFiles}"/>
224 <echo
225 message="normalizeJarFiles: ${normalizeJarFiles}"/>
226 <echo
227 message="doSign: ${doSign}"/>
228 <echo
229 message="doNormalize: ${doNormalize}"/>
230 <echo
231 message="doP2Repo: ${doP2Repo}"/>
232 </target>
david_williams6913d4d2010-04-03 05:05:16 +0000233 <target
234 name="normalizeJarFiles"
235 if="doNormalize"
236 depends="init">
237 <!--
238 stick with JAVA5 for signing/packing for now ... I've heard
239 rumors of some 'compatibility' issues with JAVA6?
240 -->
241 <echo
242 message="Starting normalizeJarFiles"/>
243 <echo
244 message="archiveDir: ${archiveDir}"/>
245 <java
246 jar="${eclipse.launcher}"
247 fork="true"
248 jvm="${env.JAVA_5_HOME}/bin/java"
249 failonerror="true"
250 maxmemory="512m"
251 dir="${buildDirectory}">
252 <jvmarg
253 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
254 <arg
255 line="${logIfDebug}"/>
256 <arg
257 line="-application org.eclipse.update.core.siteOptimizer"/>
258 <!--
259 note: this -processAll option is critical in this first
260 step. For various reasons, jarProcessor is written to
261 not act on any jar if the jar is not "marked", or if not
262 told explicitly to to processAll. There are ways where
263 not all are literally processed, such as using
264 pack.properties (and others, see
265 http://wiki.eclipse.org/JarProcessor_Options).
266 -->
267 <arg
268 line="-jarProcessor ${verboseIfDebug} -processAll -outputDir ${archiveDir} -repack ${buildDirectory}/${buildLabel}/${archiveName}"/>
269 </java>
270 </target>
271 <target
272 name="createPackFilesIfDesired"
273 if="doPack"
274 depends="init">
275 <!--
david_williamsdc454d32010-04-04 04:29:41 +0000276 stick with JAVA5 for signing/packing for now ... there are
277 'compatibility' issues with JAVA6?
david_williams6913d4d2010-04-03 05:05:16 +0000278 -->
david_williams6913d4d2010-04-03 05:05:16 +0000279 <java
280 jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
281 fork="true"
282 jvm="${env.JAVA_5_HOME}/bin/java"
283 failonerror="true"
284 maxmemory="512m"
285 dir="${buildDirectory}">
286 <jvmarg
287 value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
288 <arg
289 line="${logIfDebug}"/>
290 <arg
291 line="-application org.eclipse.update.core.siteOptimizer"/>
292 <arg
293 line="-jarProcessor ${verboseIfDebug} -outputDir ${buildDirectory}/${buildLabel}/${component}/repository -pack ${buildDirectory}/${buildLabel}/${component}/repository"/>
294 </java>
david_williamsdc454d32010-04-04 04:29:41 +0000295
296 <!-- TODO: need to udpate meta data! -->
david_williams6913d4d2010-04-03 05:05:16 +0000297 </target>
298 <!--
299 always make copy, since normally either normalized, or signed
300 (and normalized) TODO: (minor) tiny improvement in efficiency
301 could be made, for N-builds?, that are neither normalized nor
302 signed.
303 -->
304 <target
david_williams6913d4d2010-04-03 05:05:16 +0000305 name="createChecksums">
306 <!--
307 This createChecksums task creates two files, for use in two
308 contexts. a. an x.md5 file, that has the name of the file in
309 the contents. This is good for some "third party"
310 executables, like md5summ, that expects the name in the
311 file. b. since ant does not deal well with md5 files with
312 anything in them other than the checksum, we provide same
313 thing in a file with an md5antformat extension, that has
314 only the checksum.
315 -->
316 <mkdir
317 dir="${buildDirectory}/${buildLabel}/checksum"/>
318 <checksum
319 file="${buildDirectory}/${buildLabel}/${archiveName}"
david_williams455e9842010-04-04 00:18:08 +0000320 todir="${buildDirectory}/${buildLabel}/checksum/"
david_williamsd86830b2010-04-04 01:31:34 +0000321 pattern="{0} *{1}"
322 fileext=".md5"
323 algorithm="MD5"/>
324 <checksum
325 file="${buildDirectory}/${buildLabel}/${archiveName}"
326 todir="${buildDirectory}/${buildLabel}/checksum/"
327 pattern="{0} *{1}"
328 fileext=".sha1"
329 algorithm="SHA1"/>
david_williams6913d4d2010-04-03 05:05:16 +0000330 </target>
331 <target
332 name="check.sign">
333 <echo
334 message="sign: ${sign}"/>
335 <echo
336 message="env skip jar signing: ${env.SKIP_JAR_SIGNING}"/>
337 <echo
338 message="skip jar signing: ${SKIP_JAR_SIGNING}"/>
339 <condition
340 property="doSign">
341 <and>
342 <equals
343 arg1="${sign}"
344 arg2="true"
345 trim="true"
346 casesensitive="false"/>
347 <not>
348 <equals
349 arg1="${env.SKIP_JAR_SIGNING}"
350 arg2="true"
351 trim="true"
352 casesensitive="false"/>
353 </not>
354 <not>
355 <equals
356 arg1="${SKIP_JAR_SIGNING}"
357 arg2="true"
358 trim="true"
359 casesensitive="false"/>
360 </not>
361 </and>
362 </condition>
363 <echo
364 message="doSign: ${doSign}"/>
365 </target>
david_williams6913d4d2010-04-03 05:05:16 +0000366 <target
david_williams455e9842010-04-04 00:18:08 +0000367 name="createTraditionalZipFiles"
368 depends="init">
david_williamsd86830b2010-04-04 01:31:34 +0000369 <p2.repo2runnable>
370 <repository
371 location="file:/${buildDirectory}/${buildLabel}/${component}/runnable"/>
372 <source>
373 <repository
374 location="${p2.build.repo}"/>
375 </source>
376 </p2.repo2runnable>
377 <property
378 name="ziparchiveName"
379 value="${component}-${buildLabel}.zip"/>
380 <copy
381 todir="${buildDirectory}/${buildLabel}/${component}/runnable"
382 overwrite="false">
383 <fileset
384 dir="${wtp.builder.home}/rootfiles">
385 </fileset>
386 </copy>
387 <zip
388 destfile="${buildDirectory}/${buildLabel}/${ziparchiveName}">
389 <zipfileset
390 dir="${buildDirectory}/${buildLabel}/${component}/runnable"
391 excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
392 </zip>
393 <antcall
394 target="createChecksums">
395 <param
396 name="archiveName"
397 value="${ziparchiveName}"/>
398 </antcall>
399 </target>
david_williams455e9842010-04-04 00:18:08 +0000400 <target
david_williams6913d4d2010-04-03 05:05:16 +0000401 name="nodefault">
402 <echo
403 level="error"
404 message="There is no default target for this buildutililites.xml ant script."/>
405 </target>
406</project>