Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ef7536d5ce53986b34f2a20e23c13ad962c2357f (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
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2011 Obeo.
  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:
      Obeo - initial API and implementation

 $Id: promoter.xml,v 1.36 2012/03/21 08:40:06 sbouchet Exp $
-->
<project name="Promoter" default="main">
	<!--
	This promotion script helps to automatically promote the last sucessful build of tycho based build to correct location.
	
	Be sure to use at least ant 1.8.2 to launch this script.
	
	Ant 1.8.2 is located here : /shared/common/apache-ant-1.8.2/
	on build.eclipse.org, do a 
	$> export ANT_HOME=/shared/common/apache-ant-1.8.2/ 
	-->

	<property name="downloads.project.root" value="modeling/emft/eef" />
	<property name="build.root" value="/shared/jobs/emf-eef-1.1/lastSuccessful/archive/releng/org.eclipse.emf.eef.update/target/" />
	<property name="thirdPartyJarsDir" value="/shared/modeling/emf/eef/3rdPartyJars" />
	<property name="project.name" value="EEF" />
	<property name="final.updatesite.name" value="emf-eef-Update" />
	<property name="build.root.updatesite.name" value="org.eclipse.emf.eef.update.zip" />
	<property name="group.owner" value="modeling.emf.eef" />

	<!--# To permit automatic downloads of non-EPL compatible code, override this to property to "Y" -->
	<property name="thirdPartyDownloadLicenseAcceptance" value="Y" />

	<property name="downloads.root" value="/home/data/httpd/download.eclipse.org/" />
	<property name="downloads.area" value="${downloads.root}/${downloads.project.root}" />
	<property name="property.file.location" location="${build.root}/promotion/promote.properties" />
	<antversion property="antversion" />

	<!--
	most of the code comes from Athena CBI.
	see http://wiki.eclipse.org/Common_Build_Infrastructure
	-->
	<target name="check.ant-contrib" if="antContribJarUnavailable">
		<condition property="thirdPartyDownloadLicenseAcceptanceOK">
			<and>
				<isset property="thirdPartyDownloadLicenseAcceptance" />
				<or>
					<equals arg1="${thirdPartyDownloadLicenseAcceptance}" arg2="Y" />
					<equals arg1="${thirdPartyDownloadLicenseAcceptance}" arg2="I accept" />
					<equals arg1="${thirdPartyDownloadLicenseAcceptance}" arg2="&quot;I accept&quot;" />
				</or>
			</and>
		</condition>
		<antcall target="get.ant-contrib" />
		<available file="${thirdPartyJarsDir}/ant-contrib.jar" property="antContribJarAvailable" />
		<fail unless="antContribJarAvailable">Error! 

Ant-Contrib is required. Download it from http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip/download,
then place it in the following location. You can also redefine the path in the promote.properties file:

$${thirdPartyJarsDir}/ant-contrib.jar          = ${thirdPartyJarsDir}/ant-contrib.jar

Or, to download this automatically, see promoter.xml#thirdPartyDownloadLicenseAcceptance property.
		</fail>
	</target>

	<target name="get.ant-contrib" if="thirdPartyDownloadLicenseAcceptanceOK">
		<get src="http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip/download" dest="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip" usetimestamp="true" />
		<mkdir dir="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip_" />
		<unzip src="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip" dest="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip_" overwrite="true" />
		<mkdir dir="${thirdPartyJarsDir}" />
		<copy file="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip_/ant-contrib/ant-contrib-1.0b3.jar" tofile="${thirdPartyJarsDir}/ant-contrib.jar" failonerror="true" />
		<delete dir="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip_" includeemptydirs="true" quiet="true" />
		<delete file="${java.io.tmpdir}/ant-contrib-1.0b3-bin.zip" quiet="true" />
	</target>

	<target name="init">
		<fail message="Please use at least ant 1.8.0. Modify your ANT_HOME path to point to a correct location">
			<condition>
				<not>
					<contains string="${antversion}" substring="1.8" />
				</not>
			</condition>
		</fail>
		<condition property="antContribJarUnavailable">
			<not>
				<available file="${thirdPartyJarsDir}/ant-contrib.jar" type="file" />
			</not>
		</condition>
		<antcall target="check.ant-contrib" />
		<!-- This will fail if ant-contrib.jar cannot be found. You can install Ant-Contrib via RPM, or download it here:
				http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip/download
		-->
		<taskdef resource="net/sf/antcontrib/antlib.xml">
			<classpath>
				<pathelement location="${thirdPartyJarsDir}/ant-contrib.jar" />
			</classpath>
		</taskdef>
		<available file="${property.file.location}" property="propertyFileAvailable" />
		<fail message="property.file.location property must be defined" unless="propertyFileAvailable" />
	</target>

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

	<target name="init.properties">
		<fail message="build.qualifier property must be defined">
			<condition>
				<not>
					<and>
						<isset property="build.qualifier" />
						<length string="${build.qualifier}" trim="true" when="greater" length="0" />
					</and>
				</not>
			</condition>
		</fail>
		<propertyregex override="true" property="build.qualifier" input="${build.qualifier}" regexp="v" replace="" casesensitive="false" />
		<fail message="version property must be defined">
			<condition>
				<not>
					<and>
						<isset property="version" />
						<length string="${version}" trim="true" when="greater" length="0" />
					</and>
				</not>
			</condition>
		</fail>
		<if>
			<and>
				<isset property="build.alias" />
				<length string="${build.alias}" trim="true" when="greater" length="0" />
			</and>
			<then>
				<property name="final.version.qualifier" value="${build.alias}" />
			</then>
			<else>
				<property name="final.version.qualifier" value="${build.qualifier}" />
			</else>
		</if>
		<fail message="build.root property must be defined" unless="build.root" />
		<fail message="downloads.area property must be defined" unless="downloads.area" />
	</target>

	<target name="main" depends="init,load.properties,init.properties">

		<!-- publish into drops ( Zips ) -->
		<antcall target="-publish.build.drops" inheritall="true" />

		<!-- publish p2 repository -->
		<antcall target="-publish.build.repository" inheritall="true" />
	</target>

	<target name="-publish.build.drops">
		<property name="build.drop.directory" location="${downloads.area}/downloads/drops/${version}/${build.qualifier}" />

		<delete dir="${build.drop.directory}" />
		<mkdir dir="${build.drop.directory}" />

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

		<!-- rename UpdateSite zip package -->
		<move tofile="${build.drop.directory}/${final.updatesite.name}-${final.version.qualifier}.zip" file="${build.drop.directory}/${build.root.updatesite.name}" />

		<!-- genereate md5 checksums -->
		<checksum algorithm="MD5" fileext=".md5" format="MD5SUM">
			<fileset dir="${build.drop.directory}" />
		</checksum>

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

		<!-- chgrp -->
		<chgrp group="${group.owner}" type="both" verbose="true">
			<fileset refid="drop.resources" />
		</chgrp>

	</target>

	<target name="-publish.build.repository">
		<!-- determine the base version -->
		<propertyregex property="base.version" input="${version}" regexp="^(\d+\.\d+)\.\d+.*$" select="\1" casesensitive="false" />

		<!-- setup composite.repository.base and composite.type according to the build type -->
		<condition property="composite.repository.base" value="interim/${base.version}">
			<matches pattern="^I" string="${build.qualifier}" />
		</condition>
		<condition property="composite.repository.base" value="milestones/${base.version}">
			<matches pattern="^[MS]" string="${build.qualifier}" />
		</condition>
		<condition property="composite.repository.base" value="releases/${base.version}">
			<matches pattern="^R" string="${build.qualifier}" />
		</condition>
		<condition property="composite.repository.base" value="nightly/${base.version}">
			<matches pattern="^N" string="${build.qualifier}" />
		</condition>
		<condition property="composite.type" value="Interim">
			<matches pattern="^I" string="${build.qualifier}" />
		</condition>
		<condition property="composite.type" value="Milestones">
			<matches pattern="^[MS]" string="${build.qualifier}" />
		</condition>
		<condition property="composite.type" value="Releases">
			<matches pattern="^R" string="${build.qualifier}" />
		</condition>
		<condition property="composite.type" value="Nightly">
			<matches pattern="^N" string="${build.qualifier}" />
		</condition>

		<property name="composite.repository.directory" location="${downloads.area}/updates/${composite.repository.base}" />
		<property name="composite.repository.url" value="file:/${composite.repository.directory}" />
		<property name="build.repository.directory" location="${composite.repository.directory}/${build.qualifier}" />
		<property name="mirror.repository.path" value="${downloads.project.root}/updates/${composite.repository.base}/${build.qualifier}" />

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

		<!-- unzip update site to final location -->
		<unzip dest="${build.repository.directory}">
			<fileset dir="${build.root}">
				<filename name="*.zip" />
			</fileset>
		</unzip>

		<!-- adding p2.index -->
		<echo file="${build.repository.directory}/p2.index" message="version = 1${line.separator}metadata.repository.factory.order = content.xml,\!${line.separator}artifact.repository.factory.order = artifacts.xml,\!" />

		<!-- adding p2.mirrorsURL and p2.statsURI to the repository -->
		<unzip dest="${build.repository.directory}">
			<fileset file="${build.repository.directory}/artifacts.jar" />
		</unzip>

		<move file="${build.repository.directory}/artifacts.xml" tofile="${build.repository.directory}/artifacts.original.xml" />

		<xslt style="p2.xsl" in="${build.repository.directory}/artifacts.original.xml" out="${build.repository.directory}/artifacts.xml">
			<param name="mirrorsURL" expression="http://www.eclipse.org/downloads/download.php?file=${mirror.repository.path}&amp;format=xml" />
		</xslt>

		<zip destfile="${build.repository.directory}/artifacts.jar" basedir="${build.repository.directory}" includes="artifacts.xml" />

		<delete file="${build.repository.directory}/artifacts.xml" />
		<delete file="${build.repository.directory}/artifacts.original.xml" />

		<!-- add to composite repo -->
		<ant antfile="/shared/modeling/tools/promotion/manage-composite.xml" target="add" dir="${composite.repository.directory}">
			<property name="user.dir" value="${composite.repository.directory}" />
			<property name="child.repository" value="${build.qualifier}" />
			<property name="composite.name" value="${project.name} ${base.version} ${composite.type} Update Site" />
		</ant>

		<!-- add p2.index on top of composite repo is needed -->
		<if>
			<not>
				<available file="${composite.repository.directory}/p2.index" type="file" />
			</not>
			<then>
				<echo file="${composite.repository.directory}/p2.index" message="version = 1${line.separator}metadata.repository.factory.order = compositeContent.xml,\!${line.separator}artifact.repository.factory.order = compositeArtifacts.xml,\!" />
			</then>
		</if>

		<fileset id="repository.resources" dir="${composite.repository.directory}">
			<or>
				<filename name="compositeContent.*" />
				<filename name="compositeArtifacts.*" />
				<filename name="p2.index" />
				<filename name="${build.qualifier}/**" />
			</or>
		</fileset>

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

</project>

Back to the top