Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7fac7775f426d2d07f94ec54791a0e9c48f54994 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<?xml version="1.0"?>
<project name="CDO">

	<property name="stream" value="4.0" />
	<property name="branch" value="branches/4.0-maintenance" />

	<condition property="properties.file" value="build.properties" else="local.properties">
		<isset property="server.build" />
	</condition>

	<condition property="mspec.file" value="build.mspec" else="local.mspec">
		<isset property="server.build" />
	</condition>

	<property file="${properties.file}" />
	<property environment="env" />

	<condition property="build.root" value="${env.WORKSPACE}" else="${basedir}/../build">
		<isset property="env.WORKSPACE" />
	</condition>

	<condition property="buckminster.loglevel" value="${env.BUCKMINSTER_LOGLEVEL}" else="INFO">
		<isset property="env.BUCKMINSTER_LOGLEVEL" />
	</condition>

	<condition property="clean.tools" value="true">
		<equals arg1="${env.CLEAN_TOOLS}" arg2="true" />
	</condition>

	<condition property="clean.tp" value="true">
		<equals arg1="${env.CLEAN_TP}" arg2="true" />
	</condition>

	<condition property="clean.workspace" value="true">
		<equals arg1="${env.CLEAN_WORKSPACE}" arg2="true" />
	</condition>

	<condition property="clean.output" value="true">
		<equals arg1="${env.CLEAN_OUTPUT}" arg2="true" />
	</condition>

	<condition property="zip.dropins" value="${env.ZIP_DROPINS}" else="true">
		<isset property="env.ZIP_DROPINS" />
	</condition>

	<condition property="site.pack200" value="${env.SITE_PACK200}" else="true">
		<isset property="env.SITE_PACK200" />
	</condition>

	<condition property="no.proxy" value="${env.no_proxy}, dev.eclipse.org" else="dev.eclipse.org">
		<isset property="env.no_proxy" />
	</condition>

	<!-- Default properties intended to be overridden by entries in the above property file -->
	<property name="tools" location="${build.root}/tools" />
	<property name="result" location="${build.root}/result" />
	<property name="workspace" location="${result}/workspace" />
	<property name="targetPlatformPath" location="${result}/tp" />
	<property name="buckminster.output.root" location="${result}/output" />
	<property name="buckminster.temp.root" location="${result}/temp" />
	<property name="buckminster.temp.zips" value="${buckminster.temp.root}/zips" />
	<property name="temp" location="${workspace}/_temp" />

	<!-- This macro executes the default application of an eclipse installation
			 that resides in the folder ${buildtools}/@app -->
	<macrodef name="eclipse.launch">
		<attribute name="app" />
		<element name="properties" optional="true" />
		<element name="args" optional="true" />
		<sequential>
			<!-- We assume that the eclipse installation is beneath ${buildtools} -->
			<property name="@{app}.deploy.dir" value="${tools}/@{app}" />

			<!-- Find the Eclipse launcher and assign its location to the @{app}.launcher property -->
			<pathconvert property="@{app}.launcher">
				<first count="1">
					<sort>
						<fileset dir="${@{app}.deploy.dir}/plugins" includes="**/org.eclipse.equinox.launcher_*.jar" />
						<reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
							<date />
						</reverse>
					</sort>
				</first>
			</pathconvert>

			<!-- Launch the eclipse application -->
			<java fork="true" jar="${@{app}.launcher}" dir="${@{app}.deploy.dir}" failonerror="true">
				<env key="no_proxy" value="${no.proxy}" />
				<properties />
				<!-- Uncomment to debug <jvmarg value="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y"/> -->
				<args />
			</java>
		</sequential>
	</macrodef>

	<macrodef name="buckminster">
		<attribute name="command" />
		<attribute name="workspace" default="${workspace}" />
		<element name="sysproperties" optional="true" />
		<element name="globargs" optional="true" />
		<element name="cmdargs" optional="true" />
		<sequential>
			<eclipse.launch app="buckminster">
				<properties>
					<sysproperty key="bugfix.288796" value="true" />
					<sysproperties />
				</properties>
				<args>
					<jvmarg value="-Xmx4096m" />
					<arg value="-data" />
					<arg value="@{workspace}" />
					<arg value="--loglevel" />
					<arg value="${buckminster.loglevel}" />
					<arg value="--displaystacktrace" />
					<globargs />
					<arg value="@{command}" />
					<arg value="-P" />
					<arg value="${properties.tmp}" />
					<cmdargs />
				</args>
			</eclipse.launch>
		</sequential>
	</macrodef>

	<target name="init.clean.tools" if="clean.tools">
		<antcall target="clean.tools" />
	</target>

	<target name="init.clean.tp" if="clean.tp">
		<antcall target="clean.tp" />
	</target>

	<target name="init.clean.workspace" if="clean.workspace">
		<antcall target="clean.workspace" />
	</target>

	<target name="init.clean.output" if="clean.output">
		<antcall target="clean.output" />
	</target>

	<target name="init.checks" depends="init.clean.tools,init.clean.tp,init.clean.workspace,init.clean.output">
		<available file="${tools}/director/director" property="director.exists" />
		<available file="${tools}/buckminster/buckminster" property="buckminster.exists" />

		<delete failonerror="false">
			<fileset dir="${result}">
				<include name="bom.xml" />
				<include name="test-report.xml" />
			</fileset>
		</delete>
	</target>

	<target name="get.director" unless="director.exists">
		<echo message="Fetching headless director application" />
		<tempfile destdir="${java.io.tmpdir}"
		          prefix="director-"
		          suffix=".zip"
		          property="director.zip"
		          deleteonexit="true" />
		<get src="${eclipse.downloads}/${director.path}" dest="${director.zip}" />
		<mkdir dir="${tools}" />
		<unzip src="${director.zip}" dest="${tools}" />
		<delete file="${director.zip}" />
	</target>

	<target name="install.buckminster" unless="buckminster.exists" depends="get.director">
		<echo message="Configuring headless buckminster with needed features" />
		<eclipse.launch app="director">
			<properties>
				<sysproperty key="eclipse.p2.mirrors" value="false" />
				<!--
				propagate the pack200 setting if defined
				<syspropertyset>
					<propertyref name="org.eclipse.update.jarprocessor.pack200" />
				</syspropertyset>
				-->
			</properties>
			<args>
				<arg value="-r" />
				<arg value="${eclipse.downloads}/${bm.headless.path}" />
				<arg value="-r" />
				<arg value="${bm.external.path}" />
				<arg value="-d" />
				<arg value="${tools}/buckminster" />
				<arg value="-p" />
				<arg value="Buckminster" />
				<arg value="-i" />
				<arg value="org.eclipse.buckminster.cmdline.product" />
				<arg value="-i" />
				<arg value="org.eclipse.buckminster.core.headless.feature.feature.group" />
				<arg value="-i" />
				<arg value="org.eclipse.buckminster.pde.headless.feature.feature.group" />
				<arg value="-i" />
				<arg value="org.eclipse.buckminster.subversive.headless.feature.feature.group" />
				<!--
				<arg value="-i" />
				<arg value="org.eclipse.buckminster.emma.headless.feature.feature.group" />
				-->
			</args>
		</eclipse.launch>
	</target>

	<target name="init.workspace" unless="workspace.exists">
		<mkdir dir="${result}" />
	</target>

	<target name="set.build.type.from.environment" unless="build.type">
		<!-- Set the build type to the value of the BUILD_TYPE environment variable if not empty -->
		<property name="env.BUILD_TYPE" value="" />
		<condition property="build.type" value="${env.BUILD_TYPE}">
			<length string="${env.BUILD_TYPE}" trim="true" when="greater" length="0" />
		</condition>
	</target>

	<target name="set.build.type.default.if.not.in.Hudson"
	        depends="set.build.type.from.environment"
	        unless="build.type">
		<!-- Set the build type to the default value of "N" if not running in Hudson -->
		<condition property="build.type" value="N">
			<not>
				<isset property="env.BUILD_URL" />
			</not>
		</condition>
	</target>

	<target name="set.build.type.from.Hudson.build.cause"
	        depends="set.build.type.default.if.not.in.Hudson"
	        unless="build.type">
		<!-- Infer the build type from the cause/trigger of the build as filed by Hudson:
				 build triggered by timer/schedule => I build
				 any other cause => N build -->
		<xmlproperty keeproot="false">
			<url url="${env.BUILD_URL}/api/xml?tree=actions[causes[shortDescription]]" />
		</xmlproperty>
		<loadresource property="build.trigger">
			<propertyresource name="action.cause.shortDescription" />
			<filterchain>
				<replaceregex pattern="^Started by " replace="" />
			</filterchain>
		</loadresource>
		<condition property="build.type" value="I" else="N">
			<equals arg1="${build.trigger}" arg2="timer" />
		</condition>
	</target>

	<target name="set.build.timestamp.from.environment" unless="build.timestamp">
		<condition property="build.timestamp" value="${env.BUILD_ID}">
			<isset property="env.BUILD_ID" />
		</condition>
	</target>

	<target name="set.build.timestamp" depends="set.build.timestamp.from.environment" unless="build.timestamp">
		<tstamp>
			<format property="build.timestamp" pattern="yyyy-MM-dd_HH-mm-ss" locale="en,US" />
		</tstamp>
	</target>

	<target name="init.build.properties" depends="set.build.type.from.Hudson.build.cause,set.build.timestamp">
		<tempfile destdir="${java.io.tmpdir}"
		          prefix="build-"
		          suffix=".xml"
		          deleteonexit="true"
		          property="build.info.file.name" />
		<!-- Create a file needed by Buckminster. Don't modify! -->
		<echoxml file="${build.info.file.name}">
			<build type="${build.type}" timestamp="${build.timestamp}" />
		</echoxml>
		<xmlproperty file="${build.info.file.name}" collapseattributes="true" />
		<echo message="Build type is: ${build.type}" />

		<condition property="build.nightly" value="true">
			<equals arg1="${build.type}" arg2="N" />
		</condition>

		<condition property="site.signing" value="false" else="true">
			<isset property="build.nightly" />
		</condition>

		<!-- Echo relevant properties to a temporary file so that Buckminster can read them -->
		<tempfile destdir="${java.io.tmpdir}"
		          prefix="build-"
		          suffix=".properties"
		          deleteonexit="true"
		          property="properties.tmp" />
		<echo message="Properties file is: ${properties.tmp}" />
		<echoproperties destfile="${properties.tmp}">
			<!-- We don't want these. basedir in particular will cause problems if passed explicitly -->
			<propertyset negate="true">
				<propertyref name="basedir" />
				<propertyref name="eclipse.home" />
				<propertyref name="properties.tmp" />
				<propertyref name="line.separator" />
				<propertyref name="path.separator" />
				<propertyref prefix="ant." />
				<propertyref prefix="file." />
				<propertyref prefix="java." />
				<propertyref prefix="sun." />
				<propertyref prefix="user." />
			</propertyset>
		</echoproperties>
	</target>

	<target name="provision" depends="init.checks,init.workspace,install.buckminster,init.build.properties">
		<echo message="Importing projects into workspace ${workspace} and binaries into target platform ${targetPlatformPath}" />
		<!--
		<buckminster command="setpref">
			<cmdargs>
				<arg value="targetPlatformPath=${targetPlatformPath}" />
			</cmdargs>
		</buckminster>
		-->

		<unzip dest="${workspace}"
		       src="${build.root}/org.eclipse.emf.cdo/releng/org.eclipse.emf.cdo.releng/hudson/workspace.zip" />

		<mkdir dir="${targetPlatformPath}" />
		<buckminster command="import">
			<cmdargs>
				<!--
				<arg value="-T" />
				<arg value="${build.root}/org.eclipse.emf.cdo/releng/org.eclipse.emf.cdo.releng/hudson/workspace.zip" />
				-->

				<arg value="-B" />
				<arg value="${result}/bom.xml" />

				<arg value="-P" />
				<arg value="${basedir}/${properties.file}" />

				<!-- Last arg: -->
				<arg value="${basedir}/${mspec.file}" />
			</cmdargs>
		</buckminster>

		<echo message="Creating a empty test report to make Hudson happy" />
		<copy file="${build.root}/org.eclipse.emf.cdo/releng/org.eclipse.emf.cdo.releng/hudson/test-report-empty.xml"
		      tofile="${result}/test-report.xml" />
	</target>

	<target name="build.workspace" depends="provision">
		<echo message="Building all projects in workspace ${workspace}" />
		<buckminster command="build">
			<cmdargs>
				<arg value="--thorough" />
			</cmdargs>
		</buckminster>

		<echo message="Setting build.qualifier" />
		<tempfile destdir="${java.io.tmpdir}"
		          prefix="build-qualifier"
		          suffix=".properties"
		          deleteonexit="true"
		          property="build.qualifier.file.name" />
		<java classname="org.eclipse.emf.cdo.releng.GenerateBuildQualifier" dir="${basedir}" fork="true">
			<classpath path="${workspace}/plugins/org.eclipse.emf.cdo.releng/bin" />
			<arg value="${build.type}" />
			<arg value="${build.timestamp}" />
			<arg value="${build.qualifier.file.name}" />
		</java>
		<property file="${build.qualifier.file.name}" />
	</target>

	<target name="site.p2" depends="build.workspace">
		<echo message="Performing org.eclipse.emf.cdo.site#site.p2" />
		<buckminster command="perform">
			<cmdargs>
				<arg value="org.eclipse.emf.cdo.site#site.p2" />
			</cmdargs>
		</buckminster>

		<pathconvert property="site.p2.dir">
			<dirset dir="${workspace}/_temp/">
				<filename name="org.eclipse.emf.cdo.site_${stream}.*-eclipse.feature/site.p2" />
			</dirset>
		</pathconvert>

		<property name="content.xml" value="${site.p2.dir}/content.xml" />
		<echo message="Extracting ${content.xml}" />
		<unzip src="${site.p2.dir}/content.jar" dest="${site.p2.dir}" />

		<antcall target="generate.buildinfos" />
		<antcall target="generate.bookmarks" />
		<antcall target="generate.index" />
		<!--<antcall target="generate.categories" />-->
		<antcall target="generate.zip.dropins" />

		<echo message="Deleting ${content.xml}" />
		<delete file="${content.xml}" />
	</target>

	<target name="generate.buildinfos">
		<echo message="Creating build-info.xml" />
		<echoxml file="${result}/build-info.xml">
			<build type="${build.type}"
			       timestamp="${build.timestamp}"
			       qualifier="${build.qualifier}"
			       hudson="${env.HUDSON_URL}"
			       revision="${env.SVN_REVISION}"
			       stream="${stream}"
			       branch="${branch}"
			       job="${env.JOB_NAME}"
			       number="${env.BUILD_NUMBER}"
			       trigger="${build.trigger}" />
		</echoxml>
	</target>

	<target name="generate.bookmarks">
		<echo message="Creating bookmarks.xml" />
		<xslt style="xsl/bom2bookmarks.xsl" in="${result}/bom.xml" out="${site.p2.dir}/bookmarks.tmp" />
		<replace file="${site.p2.dir}/bookmarks.tmp" token="http://dev.eclipse.org" value="file://to-be-removed" />
		<replace file="${site.p2.dir}/bookmarks.tmp" token="file:/home/data/httpd/" value="http://" />
		<!-- Note: The final bookmarks.xml creation takes place in a later Hudson build step! -->
	</target>

	<target name="generate.index">
		<echo message="Creating human readable index" />
		<xslt style="xsl/content2html.xsl" in="${content.xml}" out="${site.p2.dir}/index.html" />
		<xslt style="xsl/content2xml.xsl" in="${content.xml}" out="${site.p2.dir}/index.xml" />
	</target>

	<!-- DONE BY PROMOTION
	<target name="generate.categories">
		<property name="categories.repo" value="${site.p2.dir}/categories" />
		<property name="categories.xml" value="${categories.repo}/content.xml" />
		<echo message="Creating ${categories.xml}" />

		<xslt style="xsl/content2categories.xsl" in="${content.xml}" out="${categories.xml}" />
		<replaceregexp file="${categories.xml}" match="BUILD_QUALIFIER" replace="${build.qualifier}" byline="true" />

		<resourcecount property="requires.size">
			<tokens>
				<concat>
					<filterchain>
						<tokenfilter>
							<containsregex pattern="required namespace" />
							<linetokenizer />
						</tokenfilter>
					</filterchain>
					<fileset file="${categories.xml}" />
				</concat>
			</tokens>
		</resourcecount>
		<replaceregexp file="${categories.xml}" match="REQUIRES_SIZE" replace="${requires.size}" byline="true" />

		<zip destfile="${categories.repo}/content.jar">
			<fileset dir="${categories.repo}">
				<include name="content.xml" />
			</fileset>
		</zip>
		<delete file="${categories.xml}" />
	</target>
	-->

	<target name="generate.zip.dropins" if="zip.dropins">
		<mkdir dir="${buckminster.temp.zips}" />
		<delete failonerror="false" includeemptydirs="true">
			<fileset dir="${buckminster.temp.zips}" defaultexcludes="false">
				<include name="**/*" />
			</fileset>
		</delete>
		<copy todir="${buckminster.temp.zips}">
			<fileset dir="rootfiles">
				<include name="**/*" />
			</fileset>
		</copy>

		<copy todir="${buckminster.temp.zips}/features" flatten="true">
			<fileset dir="${temp}">
				<include name="*-eclipse.feature/jar/*" />
				<include name="*-eclipse.feature/source.jar/*" />
				<exclude name="org.eclipse.emf.cdo.site*/**/*" />
				<exclude name="org.eclipse.emf.cdo.epp*/**/*" />
				<exclude name="org.eclipse.emf.cdo.license*/**/*" />
			</fileset>
		</copy>

		<copy todir="${buckminster.temp.zips}/plugins" flatten="true">
			<fileset dir="${temp}">
				<include name="*-osgi.bundle/jar/*" />
				<include name="*-osgi.bundle/source.jar/*" />
			</fileset>
		</copy>

		<mkdir dir="${result}/zips" />
		<zip destfile="${result}/zips/dropins.zip">
			<fileset dir="${buckminster.temp.zips}">
				<include name="**/*" />
			</fileset>
		</zip>
	</target>

	<target name="test" depends="site.p2">
		<echo message="Running JUnit tests" />
		<buckminster command="junit">
			<cmdargs>
				<arg value="-l" />
				<arg value="org.eclipse.emf.cdo.tests/CDO AllTests.launch" />
				<arg value="-o" />
				<arg value="${result}/test-report.xml" />
				<arg value="--terseXML" />
				<arg value="--flatXML" />
			</cmdargs>
		</buckminster>
	</target>

	<target name="promote.sites" depends="provision">
		<echo message="Building all projects in workspace ${workspace}" />
		<buckminster command="build" />

		<echo message="Performing org.eclipse.emf.cdo.releng#promote" />
		<buckminster command="perform">
			<cmdargs>
				<arg value="org.eclipse.emf.cdo.releng#promote" />
			</cmdargs>
		</buckminster>
	</target>

	<target name="clean.tools">
		<delete dir="${tools}/director" includeemptydirs="true" failonerror="true" quiet="true" />
		<delete dir="${tools}/buckminster" includeemptydirs="true" failonerror="true" quiet="true" />
	</target>

	<target name="clean.tp">
		<delete dir="${targetPlatformPath}" includeemptydirs="true" failonerror="true" quiet="true" />
	</target>

	<target name="clean.workspace">
		<delete dir="${workspace}" includeemptydirs="true" failonerror="true" quiet="true" />
	</target>

	<target name="clean.output">
		<delete dir="${buckminster.output.root}" includeemptydirs="true" failonerror="true" quiet="true" />
		<delete dir="${buckminster.temp.root}" includeemptydirs="true" failonerror="true" quiet="true" />
	</target>

	<target name="clean.all" depends="clean.tools,clean.workspace,clean.tp,clean.output" />

</project>

Back to the top