forked from WebDataConsulting/billing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc-build.xml
executable file
·148 lines (117 loc) · 5.66 KB
/
cc-build.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
<!--
Delegating build script, used by Cruise Control to build the source tree and run all
tests with a common test output directory.
You must define a 'cc-build.properties' file to set the grails server port and
database connection details for the running instance of jBilling. This is to ensure
that multiple instances of jBilling can be run under the same Cruise Control build loop.
Add to your ant script if you run into memory issues:
ANT_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m"
@author: Brian Cowdery
@since: Dec-13-2011
-->
<project name="CruiseControl Build" default="test.quick" basedir=".">
<property name="root.dir" value="."/>
<property file="cc-build.properties" />
<property file="application.properties" />
<condition property="cc-grails.home"
value="${grails.base.path}${app.grails.version}">
<and>
<isset property="grails.base.path"/>
<isset property="app.grails.version"/>
</and>
</condition>
<property environment="env"/>
<condition property="cc-grails.home" value="${env.GRAILS_HOME}">
<not>
<isset property="cc-grails.home"/>
</not>
</condition>
<!-- We define this variable for when build.xml is called
so that it works using the same Grails version -->
<property name="grails.home" value="${cc-grails.home}"/>
<condition property="cc-grails" value="${cc-grails.home}\bin\grails.bat">
<os family="windows"/>
</condition>
<property name="cc-grails" value="${cc-grails.home}/bin/grails"/>
<!--
Targets
-->
<target name="test.all" depends="init" description="Run entire test suite">
<antcall target="start"/>
<ant antfile="build.xml" target="test" inheritall="true" inheritrefs="true"/>
<antcall target="stop"/>
</target>
<target name="test.quick" depends="init" description="Run quick check-in tests">
<antcall target="start"/>
<ant antfile="build.xml" target="test-checkin" inheritall="true" inheritrefs="true"/>
<antcall target="stop"/>
</target>
<target name="init" depends="clean" description="Update the data source and remote bean definitions for the test run.">
<!-- update DataSource.groovy connection details -->
<replace file="${root.dir}/grails-app/conf/DataSource.groovy">
<replacefilter token='username = "jbilling"'
value='username = "${test_db_user}"'/>
</replace>
<replace file="${root.dir}/grails-app/conf/DataSource.groovy">
<replacefilter token="jdbc:postgresql://localhost:5432/jbilling_test"
value="jdbc:postgresql://localhost:5432/${test_db}"/>
</replace>
</target>
<target name="clean" description="Complete clean and recompile of all source-code, resources, and testing databases.">
<!-- make sure jbilling was shutdown after the previous run -->
<exec executable="./shutdown.sh"/>
<!-- delete some leftover junk from previous runs -->
<delete file="nohup.out"/>
<delete file="velocity.log*"/>
<delete file="TESTS-TestSuites.xml"/>
<!-- delete the ActiveMQ Data folder
This stores the JMS message queues for payments, and causes
tests to fail if the queue gains a considerable size -->
<delete dir="${root.dir}/activemq-data"/>
<!-- delete previous test-results -->
<delete dir="${root.dir}/target/test-results"/>
<property name="test-results.cleaned" value="true"/> <!-- mark test results as clean so the build doesn't do it again -->
<!-- clean and re-compile -->
<echo message="Building with grails ${cc-grails}"/>
<exec dir="${root.dir}" executable="${cc-grails}" failonerror="true">
<env key="GRAILS_HOME" value="${cc-grails.home}"/>
<arg value="clean"/>
</exec>
<exec dir="${root.dir}" executable="${cc-grails}" failonerror="true"> <!-- should compile on the 1st try -->
<env key="GRAILS_HOME" value="${cc-grails.home}"/>
<arg value="compile"/>
<arg value="--non-interactive"/>
</exec>
<!-- compile resources and load testing database -->
<exec dir="${root.dir}" executable="${cc-grails}" failonerror="true">
<env key="GRAILS_HOME" value="${cc-grails.home}"/>
<arg value="prepare-test"/>
<arg value="-hard"/>
<arg value="-user=${test_db_user}"/>
<arg value="-db=${test_db}"/>
<arg value="--non-interactive"/>
<arg value="--stacktrace"/>
</exec>
</target>
<!--
jBilling Start / Stop
-->
<target name="start" description="Start jBilling and wait for the application to become available.">
<exec executable="./startup.sh" spawn="true">
<env key="GRAILS_HOME" value="${cc-grails.home}"/>
<env key="GRAILS_STARTUP_OPT" value="-Djava.awt.headless=true -noreloading"/>
</exec>
<echo message="Waiting for application to start on port ${server_port} ..."/>
<waitfor maxwait="12" maxwaitunit="minute" checkevery="500" timeoutproperty="startup.timeout">
<http url="http://localhost:${server_port}/jbilling"/>
</waitfor>
<antcall target="stop.if.failed"/>
</target>
<target name="stop" description="Shutdown jBilling.">
<exec executable="./shutdown.sh"/>
</target>
<target name="stop.if.failed" if="startup.timeout">
<exec executable="./shutdown.sh"/>
<fail message="jBilling failed start in the expected time."/>
</target>
</project>