forked from tschaub/suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.xml
369 lines (320 loc) · 13.8 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
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
361
362
363
364
365
366
367
368
369
<!--
Common build targets.
-->
<project name="common" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:sonar="antlib:org.sonar.ant">
<!-- handle environment variable overrides -->
<property environment="env"/>
<condition property="server.build_cat" value="${env.BUILD_CAT}">
<isset property="env.BUILD_CAT"/>
</condition>
<condition property="server.build_name" value="${env.BUILD_NAME}">
<isset property="env.BUILD_NAME"/>
</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"/>
<!-- Set up gt/gwc/gs versions based on majer version and suffix -->
<property name="gt.version" value="${gt.major_version}${server.minor_version}"/>
<property name="gwc.version" value="${gwc.major_version}${server.minor_version}"/>
<property name="gs.version" value="${gs.major_version}${server.minor_version}"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${common.basedir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- SonarQube sonar.boundlessgeo.com -->
<property name="sonar.host.url" value="${env.SONAR_HOST_URL}" />
<condition property="sonar.login" value="${env.SONAR_QUBE_TOKEN}">
<isset property="env.SONAR_QUBE_TOKEN"/>
</condition>
<property name="sonar.projectKey" value="org.sonarqube:sonarqube-scanner-ant" />
<property name="sonar.projectName" value="${ant.project.name}" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.sources" value="src" />
<property name="sonar.java.binaries" value="build" />
<property name="sonar.java.libraries" value="lib/*.jar" />
<target name="sonar" description="Sonar ${ant.project.name}">
<antcall target="mvn">
<param name="dir" value="${source.dir}"/>
<param name="flags" value="-Dsonar.host.url=${sonar.host.url} -Dsonar.login=${sonar.login}"/>
<param name="goals" value="sonar:sonar"/>
</antcall>
</target>
<!-- OWASP Dependency-Check -->
<!-- <property name="dependency-check.home" value="/opt/dependency-check-ant/"/>
<path id="dependency-check.path">
<pathelement location="${dependency-check.home}/dependency-check-ant.jar"/>
<fileset dir="${dependency-check.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<taskdef resource="dependency-check-taskdefs.properties">
<classpath refid="dependency-check.path" />
</taskdef>
<target name="dependency-check" description="Dependency-Check Analysis">
<dependency-check projectname="${ant.project.name}"
reportoutputdirectory="${basedir}"
reportformat="ALL">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</dependency-check>
</target> -->
<!--
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="server.build_date" pattern="yyyy-MM-dd'T'hh:mm:ssZ"/>
<format property="server.build_prettydate" pattern="E MMM dd, yyyy @ HH:mm z"/>
<format property="server.build_shortdate" pattern="E MMM dd, yyyy"/>
</tstamp>
</target>
<!--
Initializes git revision info.
-->
<target name="init-git">
<exec executable="git" outputproperty="server.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="server.build_branch"
input="${env.GIT_BRANCH}" regexp=".*/(.*)" select="\1"/>
<echo message="env.GIT_BRANCH = ${env.GIT_BRANCH}"/>
</then>
</if>
<condition property="server.build_branch" value="${env.GIT_BRANCH}">
<isset property="env.GIT_BRANCH"/>
</condition>
<if>
<not>
<isset property="server.build_branch"/>
</not>
<then>
<exec executable="git" outputproperty="server.build_branch"
failifexecutionfails="false">
<arg line="rev-parse --abbrev-ref HEAD"/>
</exec>
</then>
</if>
<echo message="server.build_rev = ${server.build_rev}"/>
<echo message="server.build_branch = ${server.build_branch}"/>
</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="server_version=${server.version}${line.separator}"
file="target/version.ini"/>
<echo message="build_branch=${server.build_branch}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_rev=${server.build_rev}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_shortdate=${server.build_shortdate}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_date=${server.build_date}${line.separator}"
file="target/version.ini" append="true"/>
<echo message="build_prettydate=${server.build_prettydate}${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"/>
<!--
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=""/>
<property name="artifact_file"
value="target/boundless-server-${name}-${server.build_rev}.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="EULA.txt"/>
</zip>
</target>
<!--
Assembles a geoserver extension artifact.
@param name The artifact name, default is name of project.
@param dir The directory from which files is relative to, default is target.
-->
<target name="assemble-extension" depends="init-target,init-git">
<property name="dir" value="target"/>
<property name="name" value="${ant.project.name}"/>
<property name="ext_file" value="target/boundless-server-geoserver-${name}-${server.build_rev}.zip"/>
<zip destfile="${ext_file}">
<fileset dir="${dir}/${name}"/>
</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}"/>
<property name="artifact_dir"
value="${server.build_root}/${server.build_branch}/${server.build_cat}/${path}"/>
<property name="artifact_file"
value="boundless-server-${name}-${server.build_rev}.zip"/>
<property name="artifact_link"
value="boundless-server-${name}-${server.build_name}.zip"/>
<mkdir dir="${artifact_dir}"/>
<copy file="target/${artifact_file}" todir="${artifact_dir}" overwrite="true"/>
<symlink resource="${artifact_dir}/${artifact_file}"
link="${artifact_dir}/${artifact_link}"
overwrite="true" failonerror="false"/>
<!--
clean up old artifacts for non-release builds
-->
<if>
<not>
<equals arg1="${server.build_cat}" arg2="release"/>
</not>
<then>
<sort id="all_artifacts">
<fileset dir="${artifact_dir}" includes="boundless-server-${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>
<!--
Publishes a geoserver extension.
@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-extension" depends="init-git">
<property name="name" value="${ant.project.name}"/>
<property name="path" value="geoserver-extensions"/>
<property name="extensions_dir"
value="${server.build_root}/${server.build_branch}/${server.build_cat}/${path}"/>
<antcall target="publish-artifact">
<param name="artifact_dir" value="${extensions_dir}/"/>
<param name="name" value="geoserver-${name}"/>
</antcall>
</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="-Dserver.version=${server.version}"/>
<arg line="-Dserver.build_branch=${server.build_branch}"/>
<arg line="-Dserver.build_rev=${server.build_rev}"/>
<arg line="-Dserver.build_date='${server.build_date}'"/>
<arg line="-Dserver.build_prettydate='${server.build_prettydate}'"/>
</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 server_version=${server.version} ${sphinx.flags} ${flags} -b ${builder} -d ${doctrees} ${srcdir} ${outdir}"/>
<exec executable="sphinx-build" dir="${dir}" failonerror="true">
<arg line="-A server_version=${server.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>