KNOX-1182 - Removed lingering configuration, which is no longer used for RM-based...
[knox.git] / build.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <project name="Apache Knox Gateway" default="build" basedir=".">
19
20 <description>
21 Release build file for the Apache Knox Gateway
22 </description>
23
24 <property name="gateway-name" value="Apache Knox"/>
25 <property name="gateway-project" value="knox"/>
26 <property name="gateway-artifact" value="knox"/>
27 <property name="knoxshell-artifact" value="knoxshell"/>
28 <property name="gateway-version" value="1.1.0-SNAPSHOT"/>
29 <property name="release-manager" value="kminder"/>
30
31 <property name="gateway-home" value="${gateway-artifact}-${gateway-version}"/>
32
33 <property name="build-url" value="https://builds.apache.org/job/Knox-${gateway-version}/ws/target/${gateway-version}"/>
34
35 <property name="install.dir" value="install"/>
36 <property name="candidate.dir" value="candidate"/>
37
38 <property name="svn.release.path" value="https://dist.apache.org/repos/dist/release/${gateway-project}" />
39 <property name="svn.staging.path" value="https://dist.apache.org/repos/dist/dev/${gateway-project}" />
40 <condition property="isUnix">
41 <os family="unix"/>
42 </condition>
43
44 <condition property="isWindows">
45 <os family="windows"/>
46 </condition>
47
48 <condition property="mvn.cmd" value="mvn">
49 <os family="unix" />
50 </condition>
51 <condition property="mvn.cmd" value="mvn.bat">
52 <os family="windows" />
53 </condition>
54
55 <condition property="svn.cmd" value="svn">
56 <os family="unix" />
57 </condition>
58 <condition property="svn.cmd" value="svn">
59 <os family="windows" />
60 </condition>
61
62 <condition property="curl.cmd" value="curl">
63 <os family="unix" />
64 </condition>
65 <condition property="curl.cmd" value="curl">
66 <os family="windows" />
67 </condition>
68
69 <condition property="ng.cmd" value="ng">
70 <os family="unix" />
71 </condition>
72 <condition property="ng.cmd" value="ng">
73 <os family="windows" />
74 </condition>
75
76 <target name="_username">
77 <input message="" addproperty="username">
78 <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>
79 </input>
80 </target>
81
82 <target name="_password">
83 <input message="" addproperty="password">
84 <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>
85 </input>
86 </target>
87
88 <target name="_passphrase">
89 <input message="" addproperty="passphrase">
90 <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>
91 </input>
92 </target>
93
94 <target name="_init" description="Initialize the build.">
95 </target>
96
97 <target name="clean" depends="_init" description="Clean up any build artifacts.">
98 <delete dir="target"/>
99 <delete dir="${install.dir}"/>
100 <delete dir="${candidate.dir}"/>
101 </target>
102
103 <target name="build" depends="_init" description="Build the product.">
104 <exec executable="${mvn.cmd}">
105 <arg value="clean"/>
106 <arg value="install"/>
107 </exec>
108 </target>
109
110 <target name="build-notest" depends="_init" description="Build the product without running tests.">
111 <exec executable="${mvn.cmd}">
112 <arg value="-DskipTests"/>
113 <arg value="clean"/>
114 <arg value="install"/>
115 </exec>
116 </target>
117
118 <target name="verify" depends="_init" description="Perform the verification build.">
119 <exec executable="${mvn.cmd}">
120 <arg value="clean"/>
121 <arg value="verify"/>
122 </exec>
123 </target>
124 <target name="package" depends="_init" description="Build and package the product (aka verify).">
125 <exec executable="${mvn.cmd}">
126 <arg value="-Ppackage"/>
127 <arg value="clean"/>
128 <arg value="install"/>
129 </exec>
130 <copy todir="target/${gateway-version}">
131 <fileset file="CHANGES"/>
132 </copy>
133 </target>
134 <target name="quick-package" depends="_init" description="Build and package the product (aka verify).">
135 <exec executable="${mvn.cmd}">
136 <arg value="-DskipTests"/>
137 <arg value="-Ppackage"/>
138 <arg value="install"/>
139 </exec>
140 <copy todir="target/${gateway-version}">
141 <fileset file="CHANGES"/>
142 </copy>
143 </target>
144
145 <target name="daily" depends="full" description="Perform the daily build."/>
146 <target name="full" depends="_init" description="Perform a full build (aka daily).">
147 <exec executable="${mvn.cmd}">
148 <arg value="-Panalyze"/>
149 <arg value="-Prelease"/>
150 <arg value="site"/>
151 </exec>
152 </target>
153
154 <target name="post-build" depends="_init,_changes"/>
155
156 <target name="_changes" depends="_init">
157 <copy file="CHANGES" todir="target/${gateway-version}"/>
158 </target>
159
160 <target name="build-candidate">
161 <exec executable="${curl.cmd}">
162 <arg value="--silent"/>
163 <arg value="--request"/>
164 <arg value="POST"/>
165 <arg value="https://builds.apache.org/job/Knox-${gateway-version}/build?token=knox-remote-build-token"/>
166 </exec>
167 </target>
168
169 <target name="download-candidate" depends="_username,_password">
170 <mkdir dir="${candidate.dir}"/>
171 <get username="${username}" password="${password}" dest="${candidate.dir}">
172 <url url="${build-url}/knox-${gateway-version}.zip"/>
173 <url url="${build-url}/knox-${gateway-version}.zip.md5"/>
174 <url url="${build-url}/knox-${gateway-version}.zip.sha1"/>
175 <url url="${build-url}/knox-${gateway-version}-src.zip"/>
176 <url url="${build-url}/knox-${gateway-version}-src.zip.md5"/>
177 <url url="${build-url}/knox-${gateway-version}-src.zip.sha1"/>
178 <url url="${build-url}/knox-${gateway-version}.tar.gz"/>
179 <url url="${build-url}/knox-${gateway-version}.tar.gz.md5"/>
180 <url url="${build-url}/knox-${gateway-version}.tar.gz.sha1"/>
181 <url url="${build-url}/${knoxshell-artifact}-${gateway-version}.zip"/>
182 <url url="${build-url}/${knoxshell-artifact}-${gateway-version}.zip.md5"/>
183 <url url="${build-url}/${knoxshell-artifact}-${gateway-version}.zip.sha1"/>
184 <url url="${build-url}/${knoxshell-artifact}-${gateway-version}.tar.gz"/>
185 <url url="${build-url}/${knoxshell-artifact}-${gateway-version}.tar.gz.md5"/>
186 <url url="${build-url}/${knoxshell-artifact}-${gateway-version}.tar.gz.sha1"/>
187 <url url="${build-url}/CHANGES"/>
188 </get>
189 </target>
190
191 <target name="download-stage" depends="_username,_password">
192 <mkdir dir="${install.dir}"/>
193 <get dest="${install.dir}" username="${username}" password="${password}">
194 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.zip"/>
195 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.zip.md5"/>
196 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.zip.sha1"/>
197 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.zip.asc"/>
198 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}-src.zip"/>
199 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}-src.zip.md5"/>
200 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}-src.zip.sha1"/>
201 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}-src.zip.asc"/>
202 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.tar.gz"/>
203 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.tar.gz.md5"/>
204 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.tar.gz.sha1"/>
205 <url url="${svn.staging.path}/knox-${gateway-version}/knox-${gateway-version}.tar.gz.asc"/>
206 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.zip"/>
207 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.zip.md5"/>
208 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.zip.sha1"/>
209 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.zip.asc"/>
210 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.tar.gz"/>
211 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.tar.gz.md5"/>
212 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.tar.gz.sha1"/>
213 <url url="${svn.staging.path}/knox-${gateway-version}/${knoxshell-artifact}-${gateway-version}.tar.gz.asc"/>
214 <url url="${svn.staging.path}/knox-${gateway-version}/CHANGES"/>
215 </get>
216 </target>
217
218 <target name="verify-stage" depends="_init">
219 <echo>Verify ${gateway-artifact}-${gateway-version}.zip</echo>
220 <exec executable="gpg" dir="${install.dir}" failonerror="true">
221 <arg value="--verify"/>
222 <arg value="${gateway-artifact}-${gateway-version}.zip.asc"/>
223 </exec>
224 <checksum file="${install.dir}/${gateway-artifact}-${gateway-version}.zip" verifyproperty="zip.md5.ok"/>
225 <fail message="MD5 Invalid"><condition><isfalse value="${zip.md5.ok}"/></condition></fail>
226 <checksum file="${install.dir}/${gateway-artifact}-${gateway-version}.zip" algorithm="SHA1" verifyproperty="zip.sha.ok"/>
227 <fail message="SHA Invalid"><condition><isfalse value="${zip.sha.ok}"/></condition></fail>
228
229 <echo>Verify ${gateway-artifact}-${gateway-version}-src.zip</echo>
230 <exec executable="gpg" dir="${install.dir}" failonerror="true">
231 <arg value="--verify"/>
232 <arg value="${gateway-artifact}-${gateway-version}-src.zip.asc"/>
233 </exec>
234 <checksum file="${install.dir}/${gateway-artifact}-${gateway-version}-src.zip" verifyproperty="src.md5.ok"/>
235 <fail message="MD5 Invalid"><condition><isfalse value="${src.md5.ok}"/></condition></fail>
236 <checksum file="${install.dir}/${gateway-artifact}-${gateway-version}-src.zip" algorithm="SHA1" verifyproperty="src.sha.ok"/>
237 <fail message="SHA Invalid"><condition><isfalse value="${src.sha.ok}"/></condition></fail>
238
239 <echo>Verify ${gateway-artifact}-${gateway-version}.tar.gz</echo>
240 <exec executable="gpg" dir="${install.dir}" failonerror="true">
241 <arg value="--verify"/>
242 <arg value="${gateway-artifact}-${gateway-version}.tar.gz.asc"/>
243 </exec>
244 <checksum file="${install.dir}/${gateway-artifact}-${gateway-version}.tar.gz" verifyproperty="tar.md5.ok"/>
245 <fail message="MD5 Invalid"><condition><isfalse value="${tar.md5.ok}"/></condition></fail>
246 <checksum file="${install.dir}/${gateway-artifact}-${gateway-version}.tar.gz" algorithm="SHA1" verifyproperty="tar.sha.ok"/>
247 <fail message="SHA Invalid"><condition><isfalse value="${tar.sha.ok}"/></condition></fail>
248
249 </target>
250
251 <target name="sign-candidate" depends="_init,_passphrase" description="Sign a downloaded created release.">
252 <delete>
253 <fileset dir="${candidate.dir}" includes="*.asc"/>
254 </delete>
255 <exec executable="gpg" dir="${candidate.dir}">
256 <arg value="--armor"/>
257 <arg value="--passphrase"/>
258 <arg value="${passphrase}"/>
259 <arg value="--detach-sig"/>
260 <arg value="${gateway-artifact}-${gateway-version}.zip"/>
261 </exec>
262 <exec executable="gpg" dir="${candidate.dir}">
263 <arg value="--armor"/>
264 <arg value="--passphrase"/>
265 <arg value="${passphrase}"/>
266 <arg value="--detach-sig"/>
267 <arg value="${gateway-artifact}-${gateway-version}-src.zip"/>
268 </exec>
269 <exec executable="gpg" dir="${candidate.dir}">
270 <arg value="--armor"/>
271 <arg value="--passphrase"/>
272 <arg value="${passphrase}"/>
273 <arg value="--detach-sig"/>
274 <arg value="${gateway-artifact}-${gateway-version}.tar.gz"/>
275 </exec>
276 <exec executable="gpg" dir="${candidate.dir}">
277 <arg value="--armor"/>
278 <arg value="--passphrase"/>
279 <arg value="${passphrase}"/>
280 <arg value="--detach-sig"/>
281 <arg value="${knoxshell-artifact}-${gateway-version}.zip"/>
282 </exec>
283 <exec executable="gpg" dir="${candidate.dir}">
284 <arg value="--armor"/>
285 <arg value="--passphrase"/>
286 <arg value="${passphrase}"/>
287 <arg value="--detach-sig"/>
288 <arg value="${knoxshell-artifact}-${gateway-version}.tar.gz"/>
289 </exec>
290 <copy file="src/vote.txt" tofile="target/vote.txt">
291 <filterchain>
292 <expandproperties/>
293 </filterchain>
294 </copy>
295 <loadfile property="stage-message" srcFile="src/stage.txt">
296 <filterchain>
297 <expandproperties/>
298 </filterchain>
299 </loadfile>
300 <echo message="${stage-message}"/>
301 </target>
302
303 <target name="release" depends="_init">
304 <exec executable="${mvn.cmd}">
305 <arg value="-Ppackage,release"/>
306 <arg value="clean"/>
307 <arg value="install"/>
308 </exec>
309 <copy todir="target/${gateway-version}">
310 <fileset file="CHANGES"/>
311 </copy>
312 </target>
313
314 <target name="stage-candidate" depends="_username,_password,unstage-candidate" description="Stage release artifacts.">
315 <exec executable="svn">
316 <arg value="import" />
317 <arg value="${candidate.dir}"/>
318 <arg value="${svn.staging.path}/${gateway-artifact}-${gateway-version}/"/>
319 <arg value="-m"/>
320 <arg value="Staging Apache Knox Gateway version ${gateway-version}."/>
321 <arg value="--username" />
322 <arg value="${username}" />
323 <arg value="--password" />
324 <arg value="${password}" />
325 <arg value="--trust-server-cert" />
326 <arg value="--non-interactive" />
327 </exec>
328 </target>
329
330 <target name="unstage-candidate" depends="_username,_password" description="Delete staged release artifacts.">
331 <exec executable="svn">
332 <arg value="delete" />
333 <arg value="${svn.staging.path}/${gateway-artifact}-${gateway-version}/"/>
334 <arg value="-m"/>
335 <arg value="Removing Apache Knox Gateway version ${gateway-version} from staging."/>
336 <arg value="--username" />
337 <arg value="${username}" />
338 <arg value="--password" />
339 <arg value="${password}" />
340 <arg value="--trust-server-cert" />
341 <arg value="--non-interactive" />
342 </exec>
343 </target>
344
345 <target name="promote-release" depends="_username,_password" description="Promote staged artifacts to release area.">
346 <exec executable="svn">
347 <arg value="move"/>
348 <arg value="${svn.staging.path}/${gateway-artifact}-${gateway-version}"/>
349 <arg value="${svn.release.path}/${gateway-version}"/>
350 <arg value="-m"/>
351 <arg value="Releasing Apache Knox Gateway version ${gateway-version}." />
352 <arg value="--username" />
353 <arg value="${username}" />
354 <arg value="--password" />
355 <arg value="${password}" />
356 <arg value="--trust-server-cert" />
357 <arg value="--non-interactive" />
358 </exec>
359 </target>
360
361 <target name="delete-test-home" depends="_init">
362 <delete dir="${install.dir}" quiet="true"/>
363 </target>
364
365 <target name="_install-test-home-windows" depends="delete-test-home" if="isWindows">
366 <unzip src="target/${gateway-version}/${gateway-artifact}-${gateway-version}.zip" dest="${install.dir}"/>
367 </target>
368
369 <target name="_install-test-home-unix" depends="delete-test-home" if="isUnix">
370 <untar src="target/${gateway-version}/${gateway-artifact}-${gateway-version}.tar.gz" dest="${install.dir}" compression="gzip"/>
371 <chmod file="${install.dir}/${gateway-artifact}-${gateway-version}/bin/gateway.sh" perm="544"/>
372 <chmod file="${install.dir}/${gateway-artifact}-${gateway-version}/bin/ldap.sh" perm="544"/>
373 <chmod file="${install.dir}/${gateway-artifact}-${gateway-version}/bin/knoxcli.sh" perm="544"/>
374 <exec executable="bin/knoxcli.sh" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
375 <arg value="create-master"/>
376 <arg value="--master"/>
377 <arg value="knox"/>
378 </exec>
379 <exec executable="bin/knoxcli.sh" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
380 <arg value="create-cert"/>
381 </exec>
382 </target>
383
384 <target name="install-test-home" depends="_install-test-home-unix,_install-test-home-windows" description="Install binary release into install directory.">
385 <!--
386 <echo file="${install.dir}/${gateway-artifact}-${gateway-version}/data/security/master">#1.0# Mon, Aug 26 2013 14:25:31.483
387 cGkvajhUZHBNSTQ9OjpPMk5PQktYaHRyUmJoTW1zWGo0bytRPT06OkxtVjlvSDdIOWdvSEZqNTRlWVJ2N3c9PQ==</echo>
388 <chmod file="${install.dir}/${gateway-artifact}-${gateway-version}/data/security/master" perm="600"/>
389 -->
390 </target>
391
392 <target name="start-test-ldap" description="Spawn test LDAP server.">
393 <exec executable="bin/ldap.sh" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
394 <arg value="start"/>
395 </exec>
396 </target>
397
398 <target name="start-test-gateway" description="Start test gateway server.">
399 <exec executable="bin/gateway.sh" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
400 <arg value="start"/>
401 </exec>
402 </target>
403
404 <target name="start-debug-gateway" description="Start test gateway server.">
405 <exec executable="java" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
406 <arg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"/>
407 <arg value="-jar"/>
408 <arg value="bin/gateway.jar"/>
409 </exec>
410 </target>
411
412 <target name="stop-test-ldap" description="Spawn test LDAP server.">
413 <exec executable="bin/ldap.sh" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
414 <arg value="stop"/>
415 </exec>
416 </target>
417
418 <target name="stop-test-gateway" description="Start test gateway server.">
419 <exec executable="bin/gateway.sh" dir="${install.dir}/${gateway-artifact}-${gateway-version}">
420 <arg value="stop"/>
421 </exec>
422 </target>
423
424 <target name="start-test-servers" depends="start-test-ldap,start-test-gateway" description="Start test LDAP and test gateway servers."/>
425 <target name="stop-test-servers" depends="stop-test-gateway,stop-test-ldap" description="Stop test LDAP server and gateway servers."/>
426 <target name="restart-test-servers" depends="stop-test-servers,start-test-servers" description="Restart test LDAP and gateway servers."/>
427
428 <target name="build-admin-ui" description="Use the 'ng' command to make a production build of the Admin UI project">
429 <exec executable="ng" dir="gateway-admin-ui">
430 <arg value="build"/>
431 <arg value="--prod"/>
432 </exec>
433 </target>
434
435 <target name="install-test-admin-ui" depends="build-admin-ui" description="Install the Admin UI build into the test gateway home installation">
436 <delete dir="${install.dir}/${gateway-artifact}-${gateway-version}/data/applications/admin-ui/app/" quiet="true"/>
437 <mkdir dir="${install.dir}/${gateway-artifact}-${gateway-version}/data/applications/admin-ui/app/"/>
438 <copy todir="${install.dir}/${gateway-artifact}-${gateway-version}/data/applications/admin-ui/app/">
439 <fileset dir="gateway-admin-ui/dist"/>
440 </copy>
441 <touch file="${install.dir}/${gateway-artifact}-${gateway-version}/conf/topologies/manager.xml"/>
442 </target>
443
444 <target name="promote-admin-ui" depends="build-admin-ui" description="Copy the build artifacts of the admin UI to the applications module for check-in">
445 <delete dir="gateway-applications/src/main/resources/applications/admin-ui/app/" quiet="true"/>
446 <mkdir dir="gateway-applications/src/main/resources/applications/admin-ui/app/"/>
447 <copy todir="gateway-applications/src/main/resources/applications/admin-ui/app/">
448 <fileset dir="gateway-admin-ui/dist"/>
449 </copy>
450 </target>
451 </project>