Skip to main content
summaryrefslogtreecommitdiffstats
blob: 92485bf8c54c79f701b3267dc1dcdc9f4bf30abf (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
<project default="run" name="org.eclipse.osee.server.releng/build.xml - Run a OSEE build using the Athena CBI">

	<target name="init">
		<property environment="env" />
		<tstamp>
			<format property="buildTimestamp" pattern="yyyyMMddHHmm" />
		</tstamp>

		<condition property="forceContextQualifier" value="v${buildTimestamp}">
			<not>
				<isset property="forceContextQualifier" />
			</not>
		</condition>

		<!-- set properties from hudson parameters, useful with ant build -->
		<condition property="isInHudson" value="true">
			<or>
				<contains string="${user.dir}" substring="hudson" />
				<contains string="${user.name}" substring="hudson" />
				<contains string="${user.home}" substring="hudson" />
			</or>
		</condition>

		<!-- Hudson default path if WORKSPACE not set -->
		<dirname property="user.dir.parent" file="${user.dir}" />
		<condition property="WORKSPACE" value="${user.dir.parent}">
			<and>
				<istrue value="${isInHudson}" />
				<not>
					<isset property="WORKSPACE" />
				</not>
			</and>
		</condition>

		<!-- Local default path if WORKSPACE not set -->
		<condition property="WORKSPACE" value="${java.io.tmpdir}">
			<and>
				<isfalse value="${isInHudson}" />
				<not>
					<isset property="WORKSPACE" />
				</not>
			</and>
		</condition>

		<condition property="version" value="${VERSION}">
			<isset property="VERSION" />
		</condition>
		<condition property="buildType" value="${BUILDTYPE}">
			<isset property="BUILDTYPE" />
		</condition>
		<condition property="projectid" value="${PROJECTID}">
			<isset property="PROJECTID" />
		</condition>
		<condition property="fetchTag" value="${FETCHTAG}">
			<isset property="FETCHTAG" />
		</condition>
		<condition property="buildAlias" value="${BUILDALIAS}">
			<isset property="BUILDALIAS" />
		</condition>

		<property file="build.properties" />

		<condition property="buildType" value="N">
			<not>
				<isset property="buildType" />
			</not>
		</condition>

		<!-- calculate workspaceDir as parent of this folder, the project's .releng folder (relengBuilderDir) -->
		<property name="relengBuilderDir" value="${basedir}" />
		<dirname file="${relengBuilderDir}" property="workspaceDir" />

		<!-- can build in /tmp, eg., in /tmp/build, or in workspace, eg.,	${WORKSPACE}/build -->
		<property name="writableBuildRoot" value="${WORKSPACE}/build" />
		<property name="buildDir" value="${writableBuildRoot}/athena" />
		<condition property="relengCommonBuilderDir" value="${workspaceDir}/org.eclipse.dash.common.releng">
			<not>
				<isset property="relengCommonBuilderDir" />
			</not>
		</condition>

		<condition property="relengBaseBuilderDir" value="${workspaceDir}/org.eclipse.releng.basebuilder">
			<not>
				<isset property="relengBaseBuilderDir" />
			</not>
		</condition>

		<condition property="isGitSourceDirSet">
			<isset property="gitSourceDir" />
		</condition>

		<taskdef resource="net/sf/antcontrib/antlib.xml">
			<classpath>
				<pathelement path="${classpath}" />
				<pathelement location="${relengCommonBuilderDir}/lib/ant-contrib.jar" />
				<pathelement location="${relengBuilderDir}/lib/ant-contrib.jar" />
				<pathelement location="${thirdPartyJarsDir}/ant-contrib.jar" />
				<pathelement location="/usr/share/java/ant-contrib.jar" />
			</classpath>
		</taskdef>

		<echo message="JAVA_HOME = ${JAVA_HOME}" />
		<echo message="JAVE 6.0 HOME: ${JAVA60_HOME}" />
		<echo message="WORKSPACE = ${WORKSPACE}" />
		<echo message="isInHudson = ${isInHudson}" />
		<echo message="relengCommonBuilderDir = ${relengCommonBuilderDir}" />
		<echo message="relengBaseBuilderDir = ${relengBaseBuilderDir}" />
		<echo message="writableBuildRoot = ${writableBuildRoot}" />
		<echo message="buildDir = ${buildDir}" />
		<echo message="fetchTag = ${fetchTag}" />
		<echo message="forceContextQualifier = ${forceContextQualifier}" />
		<echo message="GitSourceDir = ${gitSourceDir}" />
	</target>


	<target name="run" depends="init,createLocalSourceWorkspaceFromMaps,build,createSnapshot,cleanUp">
	</target>

	<target name="build">
		<antcall target="setHttpProxy" />
		<ant antfile="${relengCommonBuilderDir}/buildAll.xml" target="runEclipse" dir="${relengCommonBuilderDir}" inheritrefs="true" inheritall="true" />
	</target>

	<target name="setHttpProxy" if="http.proxyHost">
		<echo message="proxy: - ${http.proxyHost}:${http.proxyPort}" />
		<setproxy nonproxyhosts="${http.nonProxyHosts}" proxyhost="${http.proxyHost}" proxyport="${http.proxyPort}" />
	</target>

	<target name="cleanUp">
		<delete dir="${buildDir}/eclipse" failonerror="false" />
		<delete dir="${buildDir}/testing" failonerror="false" />
		<delete dir="${buildDir}/compilelogs" failonerror="false" />
		<delete dir="${buildDir}/testresults/consolelogs" failonerror="false" />
		<delete dir="${buildDir}/testresults/html" failonerror="false" />
		<delete>
			<fileset dir="${writableBuildRoot}">
				<include name="**/*AllFeatures*.zip" />
				<include name="**/*Master*.zip" />
				<include name="**/*SDK*.zip" />
			</fileset>
		</delete>
	</target>

	<target name="createSnapshot">
		<echo>Custom post build step CreateSnapshot</echo>
		<property environment="env" />

		<property name="BUILDTYPE" value="I" />
		<property name="buildFolder" value="${WORKSPACE}/build" />
		<property name="snapshotFolder" value="${buildFolder}/../snapshot/" />

		<echo>Build folder: ${buildFolder} </echo>
		<echo>Snapshot folder: ${snapshotFolder}</echo>
		<echo>Buildtype: ${BUILDTYPE}</echo>
		<echo>Job: ${env.JOB_NAME}</echo>

		<delete quiet="true" dir="${snapshotFolder}" />

		<copy flatten="true" toDir="${snapshotFolder}" failonerror="true" includeemptydirs="false">
			<fileset dir="${buildFolder}" includes="athena/*-Update-*.zip" />
			<fileset dir="${buildFolder}" includes="athena/*-osgi-runtime-*.zip" />
			<fileset dir="${buildFolder}" includes="athena/*-Automated-Tests-*.zip" />
			<fileset dir="${buildFolder}" includes="athena/*-Javadoc-*.zip" />
		</copy>

		<available file="${snapshotFolder}" property="containsFile" />
		<antcall target="doMoveZip" inheritall="true" />
		<!--<antcall target="createUnitTestSnapshot" inheritall="true" />-->
	</target>

	<target name="doMoveZip" if="containsFile">
		<echo>Renaming file to ${zipPrefix}${incubation}-${BUILDTYPE}-Snapshot.zip</echo>
		<move includeemptydirs="false" tofile="${snapshotFolder}/${zipPrefix}-update${incubation}-${BUILDTYPE}-Snapshot.zip" filtering="true">
			<fileset dir="${snapshotFolder}" includes="*-Update-*.zip" />
		</move>
		<move includeemptydirs="false" tofile="${snapshotFolder}/${zipPrefix}-osgi-runtime${incubation}-${BUILDTYPE}-Snapshot.zip" filtering="true">
			<fileset dir="${snapshotFolder}" includes="*-osgi-runtime-*.zip" />
		</move>
		<move includeemptydirs="false" tofile="${snapshotFolder}/${zipPrefix}-javadoc${incubation}-${BUILDTYPE}-Snapshot.zip" filtering="true">
			<fileset dir="${snapshotFolder}" includes="*-Javadoc-*.zip" />
		</move>
	</target>

	<target name="createUnitTestSnapshot">
		<property name="snapshotTestZipArchive" value="${zipPrefix}-update-tests${incubation}-${BUILDTYPE}-Snapshot.zip" />

		<property name="fullTestSuite" value="${snapshotFolder}/full_test_suite-Snapshot.zip" />
		<property name="tempTestSnapFolder" value="${snapshotFolder}/test_snap_tmp" />

		<move includeemptydirs="false" tofile="${fullTestSuite}" filtering="true">
			<fileset dir="${snapshotFolder}">
				<filename name="*-Automated-Tests-*.zip" />
			</fileset>
		</move>

		<mkdir dir="${tempTestSnapFolder}" />
		<unzip src="${fullTestSuite}" dest="${tempTestSnapFolder}" />

		<pathconvert property="oseeClientUnitTestsZip" setonempty="false">
			<path>
				<fileset dir="${tempTestSnapFolder}/testing">
					<include name="*-junit-tests-*.zip" />
				</fileset>
			</path>
		</pathconvert>
		<move file="${oseeClientUnitTestsZip}" tofile="${snapshotFolder}/${snapshotTestZipArchive}" />

		<delete failonerror="false" file="${fullTestSuite}" />
		<delete failonerror="false" dir="${tempTestSnapFolder}" />
	</target>

	<target name="createLocalSourceWorkspaceFromMaps" depends="init" if="isGitSourceDirSet">
		<pathconvert property="mapFiles" setonempty="false" pathsep=";">
			<path>
				<fileset dir="${relengBuilderDir}/maps">
					<include name="*.map" />
				</fileset>
			</path>
		</pathconvert>

		<property name="localSourceCheckoutDir" value="${buildDir}/localBuildSources" />

		<mkdir dir="${localSourceCheckoutDir}/features" />
		<mkdir dir="${localSourceCheckoutDir}/plugins" />

		<for param="aMapFile" delimiter=";" list="${mapFiles}">
			<sequential>
				<processMapFile file="@{aMapFile}" sourceDir="${gitSourceDir}" targetDir="${localSourceCheckoutDir}" />
			</sequential>
		</for>
	</target>

	<macrodef name="processMapFile">
		<attribute name="file" />
		<attribute name="sourceDir" />
		<attribute name="targetDir" />
		<sequential>
			<var name="data" unset="true" />
			<loadfile property="data" srcfile="@{file}">
				<filterchain>
					<linecontains>
						<contains value="SVN" />
					</linecontains>
				</filterchain>
			</loadfile>

			<for param="line.data" delimiter="${line.separator}" list="${data}" trim="true">
				<sequential>
					<propertyregex property="resourceName" input="@{line.data}" defaultvalue="" regexp="[^,]+$" select="\0" casesensitive="false" override="true" />
					<symlink link="@{targetDir}/${resourceName}" resource="@{sourceDir}/${resourceName}" overwrite="true" />
				</sequential>
			</for>
		</sequential>
	</macrodef>
</project>

Back to the top