-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildFeatureCommon.xml
237 lines (212 loc) · 11.3 KB
/
buildFeatureCommon.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="feature.common" basedir=".">
<target name="init">
<xmlproperty file="./feature.xml"/>
<property name="global.plugin.script" value="../org.eclipse.imp.update/exportPlugin.xml"/>
<property name="default.feature.script" value="../org.eclipse.imp.update/exportFeature.xml"/>
<propertyRegexp name="feature.version" input="${feature(version)}" regexp="(.*).qualifier" value="\1.${build.qualifier}"/>
<echo message="Building feature ${ant.project.name} for version ${feature.version}"/>
<property name="feature.id" value="${feature(id)}"/>
<property name="feature.temp.folder" value="${basedir}/feature.temp.folder"/>
<property name="feature.destination" value="${basedir}"/>
<loadfile property="plugins.ids" srcfile="feature.xml">
<filterchain>
<!-- Sometimes the PDE splits <plugin> elements into several lines, but the
subsequent filters assume the entire <plugin> element is all on one line. -->
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="[ \t]*(<plugin)[ \t\r\n]*" replace="\1 " flags="gs"/>
</tokenfilter>
<!-- Grab only the <plugin> elements from the feature manifest -->
<containsregex pattern="<plugin"/>
<!-- Grab the plugin ID from the <plugin> element -->
<replaceregex pattern="[ \t]*<plugin .*id="([^"]*)".*" replace="\1,"/>
<!-- Now concatenate all of the plugin IDs into a single comma-separated value, with
no intervening line separators. The trailing comma seems to do no harm. -->
<tokenfilter>
<filetokenizer/>
<replaceregex pattern=",[\r\n]* *" replace="," flags="gs"/>
</tokenfilter>
</filterchain>
</loadfile>
<echo message="Feature contains the following plugins: ${plugins.ids}"/>
</target>
<!-- This is the main target -->
<target name="build.feature" depends="init" description="Build the feature jar and all of the feature's constituent plugins">
<antcall target="build.feature.jar"/>
<antcall target="gather.plugin.jars"/>
</target>
<target name="build.feature.jar" depends="init" description="Build the feature jar for IMP for an update site.">
<property name="feature.base" value="${feature.temp.folder}"/>
<delete dir="${feature.temp.folder}"/>
<mkdir dir="${feature.temp.folder}"/>
<antcall target="gather.feature.parts" inheritAll="false">
<!-- <param name="arch" value="*"/>
<param name="ws" value="*"/>
<param name="nl" value="*"/>
<param name="os" value="*"/> -->
<param name="feature.base" value="${feature.temp.folder}"/>
</antcall>
<propertyRegexp name="all.builds.for.version" input="${feature.version}" regexp="(.*).${build.qualifier}" value="\1.*"/>
<echo message="Deleting old builds of feature ${feature.id} for version ${all.builds.for.version}"/>
<delete>
<fileset dir="${feature.destination}" includes="${feature.id}_${all.builds.for.version}.jar"/>
</delete>
<echo message="Deleting old builds of source feature ${feature.id} for version ${all.builds.for.version}"/>
<delete>
<fileset dir="${feature.destination}" includes="${feature.id}.source_${all.builds.for.version}.jar"/>
</delete>
<jar destfile="${feature.destination}/${feature.id}_${feature.version}.jar" basedir="${feature.temp.folder}/features/${feature.id}_${feature.version}"/>
<antcall target="build.source.feature"/>
<delete dir="${feature.temp.folder}"/>
<echo message="Feature jar build complete."/>
</target>
<!-- Copy the plugin jars to the 'plugins' folder so that exportUpdate script can see it -->
<target name="gather.plugin.jars" depends="build.all.plugins">
<delete failonerror="false">
<fileset dir="plugins" includes="*.jar"/>
</delete>
<mkdir dir="plugins"/>
<for param="plugin.id" values="${plugins.ids}">
<antcall target="copy.child">
<param name="plugin.id" value="${plugin.id}"/>
</antcall>
</for>
</target>
<target name="build.all.plugins" depends="init">
<for param="plugin.id" values="${plugins.ids}">
<antcall target="build.child">
<param name="plugin.id" value="${plugin.id}"/>
</antcall>
</for>
</target>
<target name="echo.child">
<echo message="Processing ${plugin.id}"/>
</target>
<target name="gather.feature.parts" depends="init" if="feature.base">
<property name="target.dir" value="${feature.base}/features/${feature.id}_${feature.version}"/>
<mkdir dir="${target.dir}"/>
<copy todir="${target.dir}" failonerror="true" overwrite="false">
<fileset dir="${basedir}">
<include name="feature.properties"/>
<include name="epl-v10.html"/>
<include name="license.html"/>
<include name="eclipse_update_120.jpg"/>
</fileset>
</copy>
<copy todir="${target.dir}" file="feature.xml">
<filterchain>
<replaceregex pattern="version=\"(.*)\.qualifier"" replace="version="\1.${build.qualifier}""/>
</filterchain>
</copy>
</target>
<target name="cruise.publish" depends="init">
<copy todir="../../artifacts" file="${feature.id}_${feature.version}.jar"/>
</target>
<!-- ========================================================================================= -->
<target name="build.child">
<available file="../${plugin.id}/exportPlugin.xml" property="plugin.script" value="./exportPlugin.xml"/>
<condition property="plugin.script" value="${global.plugin.script}">
<not>
<isset property="plugin.script"/>
</not>
</condition>
<echo message="Using plugin build script ${plugin.script} for ${plugin.id}"/>
<ant antfile="${plugin.script}" dir="../${plugin.id}" target="build.update.jar"/>
</target>
<target name="copy.child">
<tstamp>
<format property="build.time" pattern="yyyyMMddHHmm"/>
</tstamp>
<condition property="build.qualifier" value="v${build.time}">
<not>
<isset property="build.qualifier"/>
</not>
</condition>
<loadfile property="plugin.version" srcfile="../${plugin.id}/META-INF/MANIFEST.MF">
<filterchain>
<containsregex pattern="Bundle-Version:"/>
<replaceregex pattern="Bundle-Version: (.*)" replace="\1"/>
<replaceregex pattern="(.*)\.qualifier" replace="\1.${build.qualifier}"/>
<striplinebreaks/>
</filterchain>
</loadfile>
<echo message="Copying ${plugin.id} version ${plugin.version}"/>
<copy todir="plugins" file="../${plugin.id}/${plugin.id}_${plugin.version}.jar"/>
<copy todir="plugins" file="../${plugin.id}/${plugin.id}.source_${plugin.version}.jar"/>
</target>
<target name="build.source.feature" depends="init">
<filter token="feature.id" value="${feature.id}"/>
<filter token="feature.version" value="${feature.version}"/>
<filter token="provider.name" value="rfuhrer@watson.ibm.com"/>
<filter token="plugin.list" value=""/>
<property name="feature.manifest.file" value="${feature.temp.folder}/feature.xml"/>
<copy file="../org.eclipse.imp.update/SourceFeatureManifest.in" tofile="${feature.manifest.file}" filtering="true"/>
<for param="plugin.id" values="${plugins.ids}">
<antcall target="gen.plugin.source.line">
<param name="plugin.id" value="${plugin.id}"/>
<param name="file" value="${feature.manifest.file}"/>
</antcall>
</for>
<echo message="</feature>${line.separator}" file="${feature.manifest.file}" append="true"/>
<jar destfile="${feature.destination}/${feature.id}.source_${feature.version}.jar">
<fileset dir="${feature.temp.folder}" includes="feature.xml"/>
<fileset dir="." includes="feature.properties"/>
</jar>
</target>
<target name="gen.plugin.source.line">
<loadfile property="plugin.version" srcfile="../${plugin.id}/META-INF/MANIFEST.MF">
<filterchain>
<containsregex pattern="Bundle-Version:"/>
<replaceregex pattern="Bundle-Version: (.*)" replace="\1"/>
<replaceregex pattern="(.*)\.qualifier" replace="\1.${build.qualifier}"/>
<striplinebreaks/>
</filterchain>
</loadfile>
<echo file="${file}" append="true"
message=" <plugin id="${plugin.id}.source" version="${plugin.version}" unpack="false"/>${line.separator}"/>
</target>
<!-- ========================================================================================= -->
<target name="zip.distribution" depends="init" description="Create a zip containing all the plug-ins and features for the feature: ${feature.id}.">
<delete dir="${feature.temp.folder}"/>
<mkdir dir="${feature.temp.folder}"/>
<antcall target="gather.feature.parts">
<param name="arch" value="*"/>
<param name="ws" value="*"/>
<param name="nl" value="*"/>
<param name="include.children" value="true"/>
<param name="feature.base" value="${feature.temp.folder}"/>
<param name="os" value="aix,hpux,linux,macosx,qnx,solaris,win32"/>
</antcall>
<zip destfile="${feature.destination}/${feature.id}_${feature.version}.bin.dist.zip" basedir="${feature.temp.folder}" filesonly="false" whenempty="skip" update="false"/>
<delete dir="${feature.temp.folder}"/>
</target>
<target name="zip.sources" depends="init">
<delete dir="${feature.temp.folder}"/>
<mkdir dir="${feature.temp.folder}"/>
<antcall target="all.children">
<param name="destination.temp.folder" value="${feature.temp.folder}/plugins/${feature.id}.source_${feature.version}/src"/>
<param name="include.children" value="true"/>
<param name="target" value="gather.sources"/>
</antcall>
<zip destfile="${feature.destination}/${feature.id}_${feature.version}.src.zip" basedir="${feature.temp.folder}" filesonly="true" whenempty="skip" update="false"/>
<delete dir="${feature.temp.folder}"/>
</target>
<target name="clean" depends="init" description="Clean the feature: ${feature.id} of all the zips, jars and logs created.">
<delete file="${feature.destination}/${feature.id}_${feature.version}.jar"/>
<delete file="${feature.destination}/${feature.id}_${feature.version}.bin.dist.zip"/>
<delete file="${feature.destination}/${feature.id}_${feature.version}.log.zip"/>
<delete file="${feature.destination}/${feature.id}_${feature.version}.src.zip"/>
<delete dir="${feature.temp.folder}"/>
<antcall target="all.children">
<param name="target" value="clean"/>
</antcall>
</target>
<!-- ========================================================================================= -->
<target name="gather.sources">
<antcall target="children">
<param name="destination.temp.folder" value="${feature.temp.folder}/plugins/${feature.id}.source_${feature.version}/src"/>
<param name="target" value="gather.sources"/>
</antcall>
</target>
</project>