forked from tschaub/suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.xml
313 lines (273 loc) · 11.1 KB
/
common.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
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
<!--
Common build targets.
-->
<project name="common" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- handle environment variable overrides -->
<property environment="env"/>
<condition property="suite.build_cat" value="${env.BUILD_CAT}">
<isset property="env.BUILD_CAT"/>
</condition>
<condition property="suite.build_name" value="${env.BUILD_NAME}">
<isset property="env.BUILD_NAME"/>
</condition>
<condition property="suite.build_profile" value="${env.BUILD_PROFILE}">
<isset property="env.BUILD_PROFILE"/>
</condition>
<!-- first load settings defined by system property -->
<property file="${build.settings}"/>
<!-- next load module relative settings -->
<property file="local.properties"/>
<property file="build.properties"/>
<!-- in order to load properties in this directory we need to store the
path to this file, so that build.properties can be resolved -->
<dirname property="common.basedir" file="${ant.file.common}"/>
<!-- finally load settings defined in build directory -->
<property file="${common.basedir}/local.properties"/>
<property file="${common.basedir}/build.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${common.basedir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!--
Help task.
-->
<target name="help" description="Print help" depends="init-ant">
<exec executable="${ant.exe}">
<arg value="-p"/>
</exec>
</target>
<!--
Initializes build timestamps.
-->
<target name="init-time">
<tstamp>
<format property="suite.build_date" pattern="yyyy-MM-dd'T'hh:mm:ssZ"/>
<format property="suite.build_prettydate" pattern="E MMM dd, yyyy @ HH:mm z"/>
</tstamp>
</target>
<!--
Initializes git revision info.
-->
<target name="init-git">
<exec executable="git" outputproperty="suite.build_rev"
failifexecutionfails="false">
<arg line="rev-parse --short HEAD"/>
</exec>
<!-- initialize git branch, first grab from GIT_BRANCH variable, and
if not set fall back to rev-parse -->
<if>
<isset property="env.GIT_BRANCH"/>
<then>
<!-- hack to strip off origin prefix -->
<propertyregex property="suite.build_branch"
input="${env.GIT_BRANCH}" regexp=".*/(.*)" select="\1"/>
</then>
</if>
<condition property="suite.build_branch" value="${env.GIT_BRANCH}">
<isset property="env.GIT_BRANCH"/>
</condition>
<if>
<not>
<isset property="suite.build_branch"/>
</not>
<then>
<exec executable="git" outputproperty="suite.build_branch"
failifexecutionfails="false">
<arg line="rev-parse --abbrev-ref HEAD"/>
</exec>
</then>
</if>
</target>
<!--
Initializes ant executable.
-->
<target name="init-ant">
<condition property="ant.exe" value="ant.bat" else="ant">
<os family="windows"></os>
</condition>
</target>
<!--
Initializes maven executable.
-->
<target name="init-mvn">
<condition property="mvn.exe" value="mvn.bat" else="mvn">
<os family="windows"></os>
</condition>
</target>
<!--
Creates the target directory.
-->
<target name="init-target">
<mkdir dir="target"/>
</target>
<!--
Creates the target/version.ini file.
-->
<target name="init-buildinfo" depends="init-time,init-target,init-git">
<echo message="suite_version=${suite.version}${line.separator}"
file="target/version.ini"/>
<echo message="build_branch=${suite.build_branch}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_rev=${suite.build_rev}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_date=${suite.build_date}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_prettydate=${suite.build_prettydate}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_profile=${suite.build_profile}${line.separator}"
file="target/version.ini" append="true"/>
</target>
<!--
Initialization task. Every build file should call this.
-->
<target name="init" depends="init-buildinfo,init-ant"/>
<!--
Ivy dependency retrieval task.
@param dir Directory to copy dependencies to, defaults to "${basedir}/lib".
@param pattern Retrieval pattern, defaults to "${dir}/[artifact]-[revision].[ext]".
-->
<target name="retrieve">
<property name="dir" value="lib"/>
<property name="type" value="jar,bundle"/>
<property name="pattern" value="${dir}/[artifact]-[revision].[ext]"/>
<property name="conf" value="*"/>
<ivy:configure file="${common.basedir}/ivysettings.xml"/>
<ivy:resolve type="${type}" conf="${conf}"/>
<ivy:report todir="target/ivy-report"/>
<ivy:retrieve pattern="${pattern}" type="${type}" conf="${conf}"/>
</target>
<!--
Destroys the target directory.
-->
<target name="destroy-target">
<delete dir="target"/>
</target>
<target name="destroy" depends="destroy-target"/>
<!--
Assembles a build artifact.
@param name The artifact name, default is name of project.
@param includes The pattern determine files to be included in the archive, default is **/*.
@param excludes The pattern determine files to be excluded from the archive.
@param dir The directory from which files is relative to, default is target.
-->
<target name="assemble-artifact" depends="init-target,init-git">
<property name="dir" value="target"/>
<property name="name" value="${ant.project.name}"/>
<property name="includes" value="**/*"/>
<property name="excludes" value=""/>
<condition property="artifact_suffix"
value="-${suite.build_profile}" else="">
<not>
<equals arg1="${suite.build_profile}" arg2="basic"/>
</not>
</condition>
<property name="artifact_file"
value="target/suite-${name}-${suite.build_rev}${artifact_suffix}.zip"/>
<delete file="${artifact_file}"/>
<zip destfile="${artifact_file}">
<fileset dir="target" includes="version.ini"/>
<fileset dir="${dir}" includes="${includes}" excludes="${excludes}"/>
<fileset dir="${common.basedir}/.." includes="LICENSE.txt"/>
</zip>
</target>
<!--
Publishes a build artifact.
@param name The artifact name, default is name of project.
@param includes The pattern determine files to be included in the archive, default is **/*.
@param excludes The pattern determine files to be excluded from the archive.
@param dir The directory from which files is relative to, default is target.
-->
<target name="publish-artifact" depends="init-git">
<property name="name" value="${ant.project.name}"/>
<property name="path" value="${name}"/>
<condition property="artifact_suffix"
value="-${suite.build_profile}" else="">
<not>
<equals arg1="${suite.build_profile}" arg2="basic"/>
</not>
</condition>
<property name="artifact_dir"
value="${suite.build_root}/${suite.build_branch}/${suite.build_cat}/${path}"/>
<property name="artifact_file"
value="suite-${name}-${suite.build_rev}${artifact_suffix}.zip"/>
<mkdir dir="${artifact_dir}"/>
<copy file="target/${artifact_file}" todir="${artifact_dir}" overwrite="true"/>
<symlink resource="${artifact_dir}/${artifact_file}"
link="${artifact_dir}/suite-${name}-${suite.build_name}${artifact_suffix}.zip"
overwrite="true" failonerror="false"/>
<!--
clean up old artifacts for non-release builds
-->
<if>
<not>
<equals arg1="${suite.build_cat}" arg2="release"/>
</not>
<then>
<sort id="all_artifacts">
<fileset dir="${artifact_dir}" includes="suite-${name}-*.zip"/>
<date/>
</sort>
<last id="new_artifacts" count="6">
<resources refid="all_artifacts"/>
</last>
<delete>
<difference>
<resources refid="all_artifacts"/>
<resources refid="new_artifacts"/>
</difference>
</delete>
</then>
</if>
</target>
<!--
Runs a maven build.
@param dir Directory to build from, default is ${basedir}.
@param goals Goals to execute, default is "clean install".
@param flags Extra build flags, default is empty.
-->
<target name="mvn" depends="init-mvn">
<property name="dir" value="${basedir}"/>
<property name="flags" value=""/>
<property name="goals" value="clean install"/>
<condition property="mvn_settings" value="-s ${mvn.settings}" else="">
<isset property="mvn.settings"/>
</condition>
<condition property="mvn_offline" value="-o" else="">
<isset property="mvn.offline"/>
</condition>
<echo message="${mvn.exe} ${mvn.flags} ${mvn_settings} ${mvn_offline} ${flags} ${goals}"/>
<exec executable="${mvn.exe}" dir="${dir}" failonerror="true">
<arg line="${mvn_settings} ${mvn_offline} ${mvn.flags} ${flags} ${goals}"/>
<arg line="-Dsuite.version=${suite.version}"/>
<arg line="-Dsuite.build_branch=${suite.build_branch}"/>
<arg line="-Dsuite.build_rev=${suite.build_rev}"/>
<arg line="-Dsuite.build_date='${suite.build_date}'"/>
<arg line="-Dsuite.build_prettydate='${suite.build_prettydate}'"/>
<arg line="-Dsuite.build_profile=${suite.build_profile}"/>
</exec>
</target>
<!--
Runs a sphinx build.
@param builder Doc builder, default is "html"
@param doctrees Directory to store doctrees, default is "target/doctrees"
@param srcdir The source directory, the default is ".".
@param outdir The output directory, the default is target/{builder}
@param flags Additional sphinx build flags.
-->
<target name="sphinx">
<property name="builder" value="html"/>
<property name="doctrees" value="${basedir}/target/doctrees"/>
<property name="srcdir" value="."/>
<property name="outdir" value="${basedir}/target/${builder}"/>
<property name="flags" value=""/>
<echo message="sphinx-build -A suite_version=${suite.version} ${sphinx.flags} ${flags} -b ${builder} -d ${doctrees} ${srcdir} ${outdir}"/>
<exec executable="sphinx-build" dir="${dir}">
<arg line="-A suite_version=${suite.version} ${sphinx.flags} ${flags} -b ${builder} -d ${doctrees} ${srcdir} ${outdir}"/>
</exec>
</target>
<!--
Psudeo task that calls the main life cycle tasks in order.
-->
<target name="all" depends="clean,build,assemble,publish"/>
</project>