summaryrefslogtreecommitdiffstats
blob: 504ec9aac00642ba74783d3ffa4ade22b2241688 (plain)
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
<?xml version="1.0"?>
<!--
 Copyright (c) 2010 Stephan Herrmann and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
 http://www.eclipse.org/legal/epl-v10.html

 Contributors:
     Stephan Herrmann - initial API and implementation
-->
<project name="Main Object Teams Build and Test Automation" default="INFO">

	<target name="showGivenProperties" 
			description="Show values of all properties that should be passed from our caller.">
		<echo>Properties passed into this script:
------------------------------------------------------------------------------
path of eclipse SDK:
		eclipse-app.tgz  = ${eclipse-app.tgz}
eclipse SDK build qualifier:
		eclipse.sdk.qualifier = ${eclipse.sdk.qualifier}
path of eclipse test framework:
		eclipse.tests.zip= ${eclipse.tests.zip}
path of published updates:
		published.updates= ${published.updates}
should sources be built (true|false)?
		do.build.all     = ${do.build.all}
should test be run (true|false)?
		do.run.tests     = ${do.run.tests}
directory for tempory files during testing:
		test.tmpDir		 = ${test.tmpDir}
------------------------------------------------------------------------------
		</echo>
	</target>

	<target name="setupProperties" depends="showGivenProperties">
		
		<dirname property="_toplevelDir" file="${ant.file}"/>

		<!-- main configuration file (version dependent names etc.): -->
		<loadproperties srcfile="${_toplevelDir}/run.properties" />

		<!-- ======== Directories (indentation shows structure): ======== -->
		<!--    build scripts: -->
		<property name="OTScriptDir" value="${_toplevelDir}" />
			<property name="buildfile"          value="${OTScriptDir}/build.xml" />
			<property name="builder-otcompiler" value="${OTScriptDir}/OT-Compiler" />
			<property name="builder-otdt"       value="${OTScriptDir}/OTDT-Build" />
			
		<!--	directories for the build: -->
		<property name="build.root.dir" value="${user.dir}/build-root" />
			<!-- These names are hard coded in pde-build: -->
			<property name="buildDirectory"		value="${build.root.dir}/src" />
			<property name="baseLocation"   	value="${build.root.dir}/eclipse" />
	
		<!--	directories for testing: -->
		<property name="test.root.dir" value="${user.dir}/test-root" />
			<!-- This name is used in individual test.xml of test plugins: -->
			<property name="test.eclipseDir" value="${test.root.dir}/eclipse" />

		<!--	directories for update sites: -->
		<property name="otdtUpdatesDir" 		value="${user.dir}/updateSite"/>
		<property name="testsUpdatesDirBase" 	value="${user.dir}/updateSiteTests"/>
			<!-- will have sub directories "eclipse" and "otdt" -->

		<!-- ======== Insert SDK build qualifier into our configuration files: ======== -->
		<copy file="${map.file.path}.in" tofile="${map.file.path}">
			<filterset>
				<filter token="SDK_QUALIFIER" value="${eclipse.sdk.qualifier}"/>
			</filterset>
		</copy>
        <!-- Insert SDK build qualifier into our configuration file: -->
        <copy file="${OTScriptDir}/test.properties.in" tofile="${OTScriptDir}/test.properties" overwrite="true">
                <filterset>
                        <filter token="SDK_QUALIFIER" value="${eclipse.sdk.qualifier}"/>
                </filterset>
        </copy>

        <!-- versions of test plugins: -->
        <loadproperties srcfile="${OTScriptDir}/test.properties" />

		<!-- ======== More Configuration Details: ======== -->
		<!-- maybe obsolete: file prefix to distinguish output files. -->
		<property name="file-id" value="XXX" />
		
		<!-- Configure Java for STAGE 1 and STAGE 2 building: -->
		<property name="vm" value="java" />
		<property name="vm.args" value="-Xmx912m" />

		<property name="installmode" value="clean" />
	
		<property name="saxon.jar.name" value="saxon8.jar" />
		<property name="saxon.jar.path" value="${user.home}/.ant/lib/${saxon.jar.name}" />
		<available file="${saxon.jar.path}" property="_hasSaxon.jar" />
		
		<!-- ant's os.arch is slightly different than osgi's arch -->
		<condition property="arch" value="x86_64"> <!-- HACK: hard coding 64-bit architecture -->
			<os arch="i386" />
		</condition>
		<condition property="arch" value="ppc64"> <!-- HACK: hard coding 64-bit architecture -->
			<os arch="ppc" />
		</condition>
		<condition property="arch" value="x86_64"> <!-- Map ant's arch to OSGi arch -->
			<os arch="amd64" />
		</condition>
		<!-- if not set above, set it to os.arch -->
		<property name="arch" value="${os.arch}" />

	</target>


	<target name="INFO">
		<echo>Usage:
	ant -f run.xml ot-junit-all   	 ->		runs OTDT Build and Testprocess
	ant -f run.xml ot-junit-otdt  	 ->		runs OTDT Build and Testprocess excluding jdt tests
	ant -f run.xml ot-junit-build 	 ->		runs just OTDT Buildprocess
	ant -f run.xml ot-compiler-build ->		just build the compiler
	ant -f run.xml ot-junit-run   	 ->		runs just OTDT Tests w/o TestSetup
		</echo>
	</target>

	<target name="ot-junit-all" depends="setupProperties,checkOS" description="Build all and run all tests.">
		<echo message="Starting BuildProcess and Testrun in ${build.root.dir}"/>
		<antcall target="verifyAntInstall"/>
		<antcall target="setupTests" />
		<antcall target="runAllTests"/>
	</target>

	<target name="ot-junit-otdt" depends="setupProperties,checkOS" description="Build all and run otdt  tests.">
		<echo message="Starting BuildProcess and Testrun in ${build.root.dir}"/>
		<antcall target="verifyAntInstall"/>
		<antcall target="setupTests" />
		<antcall target="runOTDTTests"/>
	</target>

	<target name="ot-junit-build" depends="setupProperties,checkOS" description="build everything without running tests">
		<echo message="Starting BuildProcess in ${build.root.dir}"/>
		<antcall target="verifyAntInstall"/>
		<antcall target="createOTDTEclipse"/>
		<antcall target="setupTests" />
	</target>

	<target name="ot-compiler-build" depends="setupProperties,checkOS" description="build only the compiler (for debugging the build)">
		<echo message="Starting BuildProcess in ${build.root.dir}"/>
		<antcall target="verifyAntInstall"/>
		<antcall target="createOTCompilerEclipse"/>
	</target>

	<target name="ot-junit-run" depends="setupProperties,checkOS" description="Run tests without building">
		<echo message="Starting Testrun ${test.root.dir}"/>
		<antcall target="runAllTests" />
	</target>

	<target name="ot-junit-run-ot" depends="setupProperties,checkOS" description="Run OT tests without building">
		<echo message="Starting Testrun ${test.root.dir}"/>
		<antcall target="runOTDTTests" />
	</target>

	<!-- =================== END Public Targets ==================== -->

	<!-- === Setup Targets: === -->
	
	<target name="verifyAntInstall" unless="_hasSaxon.jar">
		<copy failonerror="true" overwrite="false" file="${OTScriptDir}/${saxon.jar.name}" tofile="${saxon.jar.path}"></copy>
		<echo message="Needed to copy saxon8.jar to ${saxon.jar.path}. Please restart the build." />
		<echo message="For an explanation, see http://ant.apache.org/faq.html#delegating-classloader-1.6" />
		<fail message="See above. Please restart the build."/>
	</target>
	
	<!-- checks on which os ant is run, set ${os} and ${ws} accordingly -->
	<target name="determineOS">
		<condition property="os.isWindows">
			<os family="windows"/>
		</condition>

		<condition property="os.isLinux">
			<os name="Linux" />
		</condition>
	</target>

	<target name="checkOS" depends="determineOS,windows,linux"/>

	<target name="windows" if="os.isWindows">
		<echo message="OS is Windows"/>
		<property name="os" value="win32" />
		<property name="ws" value="win32" />
	</target>

	<target name="linux" unless="os.isWindows" >
		<echo message="OS is Linux"/>
		<!-- eclipse-app.tgz is already passed from the calling script -->
		<property name="os" value="linux" />
		<property name="ws" value="gtk" />
	</target>

	<target name="setupForCompile" depends="checkOS" unless="_hasCreatedOTDTEclipse">
		<antcall target="UnzipEclipse"/>
		<antcall target="AddPluginsToEclipse"/>
	</target>

	<target name="UnzipEclipse">
		<echo message="Extracting Eclipse (${eclipse-app.tgz}) in ${build.root.dir}..."/>
		<mkdir dir="${build.root.dir}"/>
		<untar compression="gzip" src="${eclipse-app.tgz}" dest="${build.root.dir}"/>
	</target>
	
	<target name="AddPluginsToEclipse" description="Add git.pde.build plugins to the base Eclipse">
		<mkdir dir="${baseLocation}/dropins/plugins"/>
		<copy file="${OTScriptDir}/lib/${git.pde.build}" todir="${baseLocation}/dropins/plugins" />
	</target>

	<!-- ==== BUILDING AND RUNNING: ==== -->

	<!-- ==== BUILD STAGE 1: ==== -->
	<!-- setting an empty inputstring is a workaround for http://issues.apache.org/bugzilla/show_bug.cgi?id=34461 -->
	<target name="createOTCompilerEclipse" depends="setupForCompile" description="create the bootstrapping Eclipse with OT/J compiler">
		<echo message="Invoke pdebuild for creating the OT-Compiler"/>
        <java
	        inputstring=""
	        dir="${baseLocation}" 
	        fork="true" 
	        classname="org.eclipse.equinox.launcher.Main"
	        classpath="${baseLocation}/plugins/${org.eclipse.equinox.launcher_jar}">
	            <arg value="-Dosgi.ws=${ws}"/>
	            <arg value="-Dosgi.os=${os}"/>
	            <arg value="-Dosgi.arch=${arch}"/>
	            <arg value="-application"/>
	            <arg value="org.eclipse.ant.core.antRunner"/>
	            <arg value="-buildfile"/>
	            <arg value="${buildfile}"/>
	            <arg value="-Dbuild.root.dir=${build.root.dir}"/>
	            <arg value="-DbaseLocation=${baseLocation}"/>
	            <arg value="-DOTScriptDir=${OTScriptDir}"/>
	            <arg value="-Drun.eclipseScriptDir=${run.eclipseScriptDir}"/>
	            <arg value="-Dbuilder=${builder-otcompiler}"/>
	            <arg value="-D${installmode}=true"/> <!-- <- obsolete? -->
		    	<arg value="-Dcomponent.short=OT-Compiler"/>
				<arg value="-DotdtUpdatesDir=${otdtUpdatesDir}"/>
	            <arg value="-Dconfigs=*,*,*"/>
	            <arg value="-Dbaseos=${os}"/>
	            <arg value="-Dbasews=${ws}"/>
	            <arg value="-Dbasearch=${arch}"/>
	            <arg value="-Dtest.root.dir=${test.root.dir}"/>
	            <arg value="-Dtest.eclipseDir=${test.eclipseDir}"/>
	            <arg value="-DmapVersionTag=${mapVersionTag}"/>
		    	<arg value="-Dmap.file.path=${map.file.path}"/>
	            <arg value="-Declipse-app.tgz=${eclipse-app.tgz}"/>
	            <arg value="-Declipse.tests.zip=${eclipse.tests.zip}"/>
	            <!--arg value="-verbose" /-->
	            <jvmarg value="${vm.args}"/>
        </java>
		<!-- Now we should have an update site with the patch feature, time to install it into base: -->
        <ant antfile="${OTScriptDir}/p2helper.xml" target="installFeature" dir="${baseLocation}">
            <property name="feature" value="org.eclipse.objectteams.otdt.core.patch.feature.group"/>
            <property name="sourceUpdatesDir" value="${otdtUpdatesDir}"/>
            <property name="targetEclipseDir" value="${baseLocation}"/>
        </ant>
    </target>

	<!-- ==== BUILD STAGE 2: ==== -->
	<!-- setting an empty inputstring is a workaround for http://issues.apache.org/bugzilla/show_bug.cgi?id=34461 -->
	<target name="createOTDTEclipse" depends="createOTCompilerEclipse" unless="_hasCreatedOTDTEclipse">
		
        <!-- Make org.eclipse.test.performance available while compiling test projects: -->
        <echo message="Pre-installing Eclipse Test Framework into OTCompilerEclipse..."/>
        <mkdir dir="${testsUpdatesDirBase}/eclipse"/>
        <unzip dest="${testsUpdatesDirBase}/eclipse" src="${eclipse.tests.zip}"/> 
        <ant antfile="${OTScriptDir}/p2helper.xml" target="installFeature" dir="${baseLocation}">
            <property name="feature" value="org.eclipse.test.feature.group"/>
            <property name="sourceUpdatesDir" value="${testsUpdatesDirBase}/eclipse"/>
            <property name="targetEclipseDir" value="${baseLocation}"/>
        </ant>
		
		<!-- pre-load updateSite with published releases: -->
        <mkdir dir="${otdtUpdatesDir}/plugins"/>
        <mkdir dir="${otdtUpdatesDir}/features"/>
        <exec executable="/bin/sh">
                <arg value="-c"/>
                <arg value="ln -s ${published.updates}/features/* ${otdtUpdatesDir}/features/"/>
        </exec>
        <exec executable="/bin/sh">
                <arg value="-c"/>
                <arg value="ln -s ${published.updates}/plugins/* ${otdtUpdatesDir}/plugins/"/>
        </exec>
		<!-- pre-load category-less metadata: -->
		<copy failonerror="false" flatten="true" toDir="${otdtUpdatesDir}">
	        <fileset dir="${user.dir}/metadata">
                       <include name="*.xml"/>
            </fileset>
    	</copy>
	
		<echo message="Invoke pdebuild for creating a full OTDT"/>
		<java
			inputstring=""
			dir="${baseLocation}" 
			fork="true" 
			classname="org.eclipse.equinox.launcher.Main"
			classpath="${baseLocation}/plugins/${org.eclipse.equinox.launcher_jar}">
				<arg value="-clean"/>
				<arg value="-Dosgi.ws=${ws}"/>
				<arg value="-Dosgi.os=${os}"/>
				<arg value="-Dosgi.arch=${arch}"/>
				<arg value="-application"/>
				<arg value="org.eclipse.ant.core.antRunner"/>
				<arg value="-buildfile"/>
				<arg value="${buildfile}"/>
				<arg value="-Dbuild.root.dir=${build.root.dir}"/>
				<arg value="-DbaseLocation=${baseLocation}"/>
				<arg value="-Drun.eclipseScriptDir=${run.eclipseScriptDir}"/>
				<arg value="-DOTScriptDir=${OTScriptDir}"/>
				<arg value="-Dbuilder=${builder-otdt}"/>
				<arg value="-D${installmode}=true"/>
				<arg value="-Dcomponent.short=OTDT-Build"/>
				<arg value="-DotdtUpdatesDir=${otdtUpdatesDir}"/>
				<arg value="-DtestsUpdatesDirBase=${testsUpdatesDirBase}"/>
				<arg value="-Dbaseos=${os}"/>
				<arg value="-Dbasews=${ws}"/>
				<arg value="-Dbasearch=${arch}"/>
				<arg value="-Dtest.root.dir=${test.root.dir}"/>
				<arg value="-Dtest.eclipseDir=${test.eclipseDir}"/>
				<arg value="-Dmap.file.path=${map.file.path}"/>
				<arg value="-DmapVersionTag=${mapVersionTag}"/>
				<arg value="-Ddo.run.tests=${do.run.tests}"/>
				<arg value="-Ddo.build.all=${do.build.all}"/>
				<arg value="-Declipse-app.tgz=${eclipse-app.tgz}"/>
				<arg value="-Declipse.tests.zip=${eclipse.tests.zip}"/>
				<!--arg value="-verbose" /-->
				<jvmarg value="${vm.args}"/>
				<!-- arg value="${verboseAnt}"/ -->
				<!-- arg value="-debug" / -->
		</java>
		<!-- At this point a local update site exists, thanks to p2gathering=true -->
		
        <ant antfile="${OTScriptDir}/p2helper.xml" target="patchMetadata" dir="${otdtUpdatesDir}"/>
		
		<property name="_hasCreatedOTDTEclipse" value="true" />
	</target>
	
	<!-- TESTING at STAGE 3: -->
	<target name="setupTests" depends="createOTDTEclipse" description="Install the tests into an fresh OTDT">
		<available file="${buildDirectory}/label.properties" property="label.properties.exists" />
		<ant antfile="${OTScriptDir}/test.xml" target="setupTests" dir="${build.root.dir}">
			<property name="os" value="${os}" />
			<property name="ws" value="${ws}" />
			<property name="arch" value="${arch}" />
			<property name="baseos" value="${os}" />
			<property name="basews" value="${ws}" />
			<property name="basearch" value="${arch}" />
			<property name="eclipse-app.tgz" value="${eclipse-app.tgz}" />
			<property file="${buildDirectory}/label.properties" />
			<property name="otdtUpdatesDir" value="${otdtUpdatesDir}" />
			<property name="testsUpdatesDirBase" value="${testsUpdatesDirBase}" />
		</ant>
	</target>

	<target name="runAllTests" description="Delegate to the next level script to perform the actual testing.">
		<ant antfile="${OTScriptDir}/test.xml" target="all" dir="${build.root.dir}">
			<property name="os" value="${os}" />
			<property name="ws" value="${ws}" />
			<property name="arch" value="${arch}" />
			<property name="baseos" value="${os}" />
			<property name="basews" value="${ws}" />
			<property name="basearch" value="${arch}" />
			<property name="otdtUpdatesDir" value="${otdtUpdatesDir}" />
			<property name="testsUpdatesDirBase" value="${testsUpdatesDirBase}" />
			<property name="test.tmpDir" value="${test.tmpDir}"/>
			<property name="vmargs" value="${vmargs}" />
		</ant>
	</target>

	<target name="runOTDTTests" description="Delegate to the next level script to perform the actual testing.">
		<ant antfile="${OTScriptDir}/test.xml" target="otdt-tests" dir="${build.root.dir}">
			<property name="os" value="${os}" />
			<property name="ws" value="${ws}" />
			<property name="arch" value="${arch}" />
			<property name="baseos" value="${os}" />
			<property name="basews" value="${ws}" />
			<property name="basearch" value="${arch}" />
			<property name="otdtUpdatesDir" value="${otdtUpdatesDir}" />
			<property name="testsUpdatesDirBase" value="${testsUpdatesDirBase}" />
			<property name="test.tmpDir" value="${test.tmpDir}"/>
			<property name="vmargs" value="${vmargs}" />
		</ant>
	</target>

	<!-- currently unused target name="collectResults">
		<ant target="collect" antfile="${test.root.dir}/library.xml" dir="${otresults}">
			<property name="includes" value="org.*.xml"/>
			<property name="output-file" value="AllTestSuites.xml"/>
		</ant>
	</target -->
	
</project>