Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0dd1889fb64824efee43075652dc4c01d91a24fc (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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Promoter / Publisher" default="publish.build">
	<property name="promoter.properties.file.name" value="promote.properties" />
	<property name="publisher.properties.file.name" value="publisher.properties" />

	<target name="-setup.promoter">
		<!-- <property name="promoter.setup.directory" location="${sp:output}" />
		<property name="promoter.properties.file" location="${promoter.setup.directory}/${promoter.properties.file.name}" />

		<mkdir dir="${promoter.setup.directory}" />-->
		<property environment="env." />

		<fail message="WORKSPACE not present in the environment, can't continue" unless="env.WORKSPACE" />
		<property name="promoter.properties.file" location="${env.WORKSPACE}/${promoter.properties.file.name}" />
		
		<!-- supply defaults -->
		<property name="build.id" value="" />
		<property name="hudson.build.id" value="" />
		<property name="must.publish.javadoc" value="false"/>

		<propertyfile file="${promoter.properties.file}" comment="Promoter script properties">
			<entry key="eclipse.home" value="${eclipse.home}" />
			<entry key="build.id" value="${build.id}" />
			<entry key="hudson.build.id" value="${hudson.build.id}" />
			<entry key="must.publish.doc" value="${manage.doc}" />
			<entry key="must.publish.javadoc" value="${manage.javadoc}" />
		</propertyfile>

		<!-- diagnostics
		<property environment="env." />
		<echoproperties destfile="${promoter.setup.directory}/all.properties" />
		-->
	</target>

	<target name="-locate.launcher.jar" unless="launcher.jar">
		<pathconvert property="launcher.jar">
			<first count="1">
				<sort>
					<fileset dir="${saved.eclipse.home}/plugins" includes="**/org.eclipse.equinox.launcher_*.jar" />
					<reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
						<date />
					</reverse>
				</sort>
			</first>
		</pathconvert>
	</target>

	<target name="setup.publisher">
		<property environment="env." />

		<fail message="WORKSPACE not present in the environment, can't continue" unless="env.WORKSPACE" />

		<!-- default publisher root -->
		<property name="publisher.root" location="${env.WORKSPACE}/publishroot" />

		<delete dir="${publisher.root}" />
		<mkdir dir="${publisher.root}" />

		<copy tofile="${publisher.root}/publisher.ant" file="${ant.file}" />

		<property name="promoter.properties.file" value="${env.WORKSPACE}/${promoter.properties.file.name}" />

		<!-- load the promoter properties using the PROMOTED_URL supplied by Hudson -->
		<property prefix="saved." file="${promoter.properties.file}" />

		<fail message="hudson.build.id not defined in ${promoter.properties.file}, can't continue">
			<condition>
				<not>
					<and>
						<isset property="saved.hudson.build.id" />
						<length string="${saved.hudson.build.id}" trim="true" when="greater" length="0" />
					</and>
				</not>
			</condition>
		</fail>

		<property name="build.root" location="${env.WORKSPACE}/../builds/${saved.hudson.build.id}" />

		<echoproperties destfile="${publisher.root}/${publisher.properties.file.name}">
			<propertyset>
				<propertyref builtin="commandline" />
				<propertyref prefix="saved." />
				<propertyref name="build.root" />
			</propertyset>
		</echoproperties>
	</target>

	<target name="publish.build">
		<fail message="build.archives property must be defined" unless="build.archives" />
		<property file="${publisher.properties.file.name}" />
		<property name="property.file.location" location="${build.archives}/${promoter.properties.file.name}" />
		<property name="property.load.prefix" value="saved." />

		<antcall target="publish.build.stage.2" inheritall="true" />
	</target>

	<target name="-setup.property.file.location" unless="property.file.location">
		<dirname property="script.directory" file="${ant.file}" />
		<property name="property.file.location" location="${script.directory}/${publisher.properties.file.name}" />
	</target>

	<target name="-load.properties.as.is" unless="property.load.prefix">
		<property file="${property.file.location}" />
	</target>

	<target name="-load.properties.with.prefix" if="property.load.prefix">
		<property prefix="${property.load.prefix}" file="${property.file.location}" />
	</target>

	<target name="-load.properties" depends="-load.properties.as.is,-load.properties.with.prefix" />

	<target name="publish.build.stage.2" depends="-setup.property.file.location,-load.properties,-locate.launcher.jar">
		<condition property="java.executable" value="${saved.java.home}/bin/java" else="java">
			<isset property="saved.java.home" />
		</condition>
		<tempfile property="publisher.workspace" prefix="workspace." destdir="${java.io.tmpdir}" />
		<echo>Used launcher: ${launcher.jar}</echo>
		<java jvm="${java.executable}" jar="${launcher.jar}" fork="true" failonerror="true">
			<syspropertyset>
				<propertyref builtin="commandline" />
				<propertyref name="property.file.location" />
				<propertyref name="property.load.prefix" />
			</syspropertyset>
			<arg value="-data" />
			<arg value="${publisher.workspace}" />
			<arg value="-configuration" />
			<arg value="${publisher.workspace}/configuration" />
			<arg value="-application" />
			<arg value="org.eclipse.ant.core.antRunner" />
			<arg value="-buildfile" />
			<arg value="${ant.file}" />
			<arg value="publish.build.from.framework" />
		</java>

		<!--
			somewhat more complicated than simple <delete dir="${publisher.workspace}" />
			but this way it does not produce the "Deleting directory" message
		-->
		<delete dir="${publisher.workspace}" includeemptydirs="true" quiet="true">
			<or>
				<type type="dir" />
				<type type="file" />
			</or>
		</delete>
	</target>

	<target name="-check.property.file.location">
		<fail message="property.file.location property must be defined" unless="property.file.location" />
	</target>

	<target name="publish.build.from.framework" depends="-check.property.file.location,-load.properties">
		<fail message="saved.build.id property must be defined">
			<condition>
				<not>
					<and>
						<isset property="saved.build.id" />
						<length string="${saved.build.id}" trim="true" when="greater" length="0" />
					</and>
				</not>
			</condition>
		</fail>
		<property file="${publisher.properties.file.name}" />
		<fail message="build.archives property must be defined" unless="build.archives" />
		<fail message="downloads.area property must be defined" unless="downloads.area" />
		<fail message="doc.area property must be defined" unless="doc.area" />
		<fail message="javadoc.area property must be defined" unless="javadoc.area" />

		<!-- defaults -->
		<property name="version" value="3.1.0" />
		<property name="packages.base" value="downloads" />
		<property name="tests.base" value="test.results" />
		<property name="doc.base" value="MDT-OCL.doc" />
		<property name="javadoc.base" value="MDT-OCL.javadoc" />
			
		<property name="packages.directory" location="${build.archives}/${packages.base}" />
		<property name="testresults.directory" location="${build.archives}/${tests.base}" />
		<property name="doc.directory" location="${build.archives}/${doc.base}" />
		<property name="javadoc.directory" location="${build.archives}/${javadoc.base}" />

		<property name="project.doc.directory" location="${doc.area}/${version}" />
		<property name="project.javadoc.directory" location="${javadoc.area}/${version}" />
		<property name="build.drop.directory" location="${downloads.area}/downloads/drops/${version}/${saved.build.id}" />
		<available file="${build.drop.directory}" type="dir" property="alreadyPromoted" />
		<antcall target="publish" inheritall="true" />
		<antcall target="echo-status" inheritall="true" />
	</target>

	<target name="publish" unless="alreadyPromoted">
		<!-- will fail if already exists -->
		<mkdir dir="${build.drop.directory}" />

		<echo>Remove existing nightly builds</echo>
		<delete verbose="true">
			<fileset dir="${downloads.area}/downloads/drops/${version}/">
				<type type="dir" />
				<include name="N*" />
			</fileset>
		</delete>

		<echo>Copying zip packages</echo>
		<copy todir="${build.drop.directory}">
			<fileset dir="${packages.directory}">
				<filename name="*.zip" />
			</fileset>
		</copy>

		<echo>Generating md5 checksums</echo>
		<checksum algorithm="MD5" fileext=".md5" format="MD5SUM">
			<fileset dir="${build.drop.directory}">
				<filename name="*.zip" />
			</fileset>
		</checksum>

		<echo>Generating SHA-512 checksums</echo>
		<checksum algorithm="SHA-512" fileext=".sha1" format="MD5SUM">
			<fileset dir="${build.drop.directory}">
				<filename name="*.zip" />
			</fileset>
		</checksum>

		<echo>Copying Test Results</echo>
		<mkdir dir="${build.drop.directory}/testresults" />
		<copy todir="${build.drop.directory}/testresults">
			<fileset dir="${testresults.directory}">
				<filename name="**/*.xml" />
			</fileset>
		</copy>

		<fileset id="drop.resources" dir="${build.drop.directory}">
			<or>
				<type type="dir" />
				<type type="file" />
			</or>
		</fileset>

		<!-- chgrp -->
		<antcall target="-change.group.owner" inheritall="true">
			<reference refid="drop.resources" torefid="change.group.owner.resources" />
		</antcall>

		<!-- strip the micro version and anything following it -->
		<buckminster.substitute value="${version}" pattern="^(\d+\.\d+)\.\d+.*$" replacement="$$1" property="base.version" />

		<!-- setup composite.repository.base appropriate to the build type -->
		<condition property="composite.repository.base" value="nightly/${version}">
			<matches pattern="^N" string="${saved.build.id}" />
		</condition>
		<condition property="composite.repository.base" value="maintenance/${version}/${saved.build.id}">
			<matches pattern="^M" string="${saved.build.id}" />
		</condition>
		<condition property="composite.repository.base" value="interim/${version}">
			<matches pattern="^I" string="${saved.build.id}" />
		</condition>
		<condition property="composite.repository.base" value="milestones/${version}/${saved.build.id}">
			<matches pattern="^S" string="${saved.build.id}" />
		</condition>
		<condition property="composite.repository.base" value="releases/${version}/${base.version}">
			<matches pattern="^R" string="${saved.build.id}" />
		</condition>

		<antcall target="-publish.build.repository" inheritall="true" />
		
		<!-- Prepare the property which will dictate if the javadoc will be published -->

		<condition property="publish.javadoc">
			<equals arg1="${saved.must.publish.javadoc}" arg2="true"/>
		</condition>
		<antcall target="-publish.javadoc" inheritall="true" />

		<condition property="publish.doc">
			<equals arg1="${saved.must.publish.doc}" arg2="true"/>
		</condition>
		<antcall target="-publish.doc" inheritall="true" />
	</target>

	<target name="-publish.build.repository" if="composite.repository.base">
		<property name="composite.repository.directory" location="${downloads.area}/updates/${composite.repository.base}" />
		<property name="composite.repository.url" value="file:/${composite.repository.directory}" />
		<!-- 
			without p2.composite.repository
		<property name="build.repository.directory" location="${composite.repository.directory}/${saved.build.id}" />
		 -->
		<property name="build.repository.directory" location="${composite.repository.directory}" />

		<deltree dir="${build.repository.directory}" />

		<unzip dest="${build.repository.directory}">
			<fileset dir="${packages.directory}">
				<filename name="*-Update*.zip" />
			</fileset>
		</unzip>

		<!--<p2.composite.repository destination="${composite.repository.url}">
			<add>
				<repository location="${saved.build.id}" />
			</add>
		</p2.composite.repository>-->


		<!-- change Group owner  -->
		<fileset id="repository.resources" dir="${composite.repository.directory}">
			<or>
				<filename name="compositeContent.*" />
				<filename name="compositeArtifacts.*" />
				<filename name="${saved.build.id}/**" />
			</or>
		</fileset>

		<antcall target="-change.group.owner" inheritall="true">
			<reference refid="repository.resources" torefid="change.group.owner.resources" />
		</antcall>
	</target>

	<target name="-change.group.owner" if="group.owner">
		<chgrp group="${group.owner}" type="both" verbose="true">
			<fileset refid="change.group.owner.resources" />
		</chgrp>
	</target>

	<target name="echo-status" if="alreadyPromoted">
		<echo>Build ${saved.build.id} already promoted, nothing to do...</echo>
	</target>
	
	<target name="-publish.doc" if="publish.doc">
		<echo>Remove existing doc from ${project.doc.directory}</echo>
		<delete verbose="true">
			<fileset dir="${project.doc.directory}"/>
		</delete>
		
		<dirset id="dist1.contents" dir="${doc.directory}/.." includes="*"/>
		<property name="prop.dist1.contents" refid="dist1.contents"/>
		<echo>${doc.directory}/..: ${prop.dist1.contents}</echo>
		
		<echo>Copying ${doc.directory}/ocl.pdf to ${project.doc.directory}</echo>
		<copy todir="${project.doc.directory}">
			<fileset dir="${doc.directory}">
				<filename name="ocl.pdf" />
			</fileset>
		</copy>
	</target>
	
	<target name="-publish.javadoc" if="publish.javadoc">
		<mkdir dir="${project.javadoc.directory}" />
		<echo>Remove existing javadoc from ${project.javadoc.directory}</echo>
		<delete verbose="true">
			<fileset dir="${project.javadoc.directory}"/>
		</delete>
		
		<dirset id="dist1.contents" dir="${javadoc.directory}/.." includes="*"/>
		<property name="prop.dist1.contents" refid="dist1.contents"/>
		<echo>${javadoc.directory}/..: ${prop.dist1.contents}</echo>
		
		<echo>Unzipping ${javadoc.directory}/MDT-OCL-javadoc.zip to ${project.javadoc.directory}</echo>
		<unzip dest="${project.javadoc.directory}">
			<fileset dir="${javadoc.directory}">
				<filename name="MDT-OCL-javadoc.zip" />
			</fileset>
		</unzip>
	</target>
</project>

Back to the top