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