-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildfile
217 lines (205 loc) · 11.4 KB
/
buildfile
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
VERSION_NUMBER = "1.0.0"
GROUP = "project"
COPYRIGHT = "LTD"
ACTIVATION = 'javax.activation:activation:jar:1.1'
AMAZON = 'com.amazonaws:aws-java-sdk:jar:1.2.7'
ANTLR = 'antlr:antlr:jar:2.7.6'
AOPALLIANCE = 'aopalliance:aopalliance:jar:1.0'
ASM = 'asm:asm:jar:3.1'
AXIS = 'org.apache.axis:axis:jar:1.4'
AXIS_SAAJ = 'org.apache.axis:axis-saaj:jar:1.4'
ASPECTJ = 'org.aspectj:aspectjweaver:jar:1.6.8'
BEANUTILS = 'commons-beanutils:commons-beanutils:jar:1.8.3'
BRAINTREE = 'com.braintreegateway:braintree-java:jar:2.15.0'
C3P0 = 'c3p0:c3p0:jar:0.9.1.2'
CGLIB = 'cglib:cglib:jar:2.2.2'
CGLIB_NODEP = 'cglib:cglib-nodep:jar:2.2.2'
COMMONS_CODEC = 'commons-codec:commons-codec:jar:1.6'
COMMONS_HIBRENATE = 'org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final'
COLLECTIONS = 'commons-collections:commons-collections:jar:3.2.1'
HTML_CLEANER = 'net.sourceforge.htmlcleaner:htmlcleaner:jar:2.2'
DISCOVERY = 'commons-discovery:commons-discovery:jar:0.5'
HTTPCLIENT = 'commons-httpclient:commons-httpclient:jar:3.1'
COMMONS_IO = 'commons-io:commons-io:jar:2.1'
LANG = 'org.apache.commons:commons-lang3:jar:3.1'
LOGGING = 'commons-logging:commons-logging:jar:1.1.1'
VALIDATOR = 'commons-validator:commons-validator:jar:1.4.0'
DAO = 'com.googlecode.genericdao:dao:jar:1.0.0'
DAOHIBERNATE = 'com.googlecode.genericdao:dao-hibernate:jar:1.0.0'
DOM4J = 'dom4j:dom4j:jar:1.6.1'
EHCAHCE = 'net.sf.ehcache:ehcache-core:jar:1.6.2'
GEARMAN = 'gearman-java:gearman:jar:0.04'
GUAVA = 'com.google.guava:guava:jar:12.0.1'
HIBERNATE_JPA = 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final'
HIBERNATE = 'org.hibernate:hibernate-core:jar:3.6.10.Final'
JACKSON_MAPPER = 'org.codehaus.jackson:jackson-mapper-asl:jar:1.9.8'
JACKSON_CORE = 'org.codehaus.jackson:jackson-core-asl:jar:1.9.8'
JACKSON_CORE_LGPL = 'org.codehaus.jackson:jackson-core-lgpl:jar:1.9.8'
JACKSON_MAPPER_LGPL = 'org.codehaus.jackson:jackson-mapper-lgpl:jar:1.9.8'
JACKSON_JAXRS = 'org.codehaus.jackson:jackson-jaxrs:jar:1.9.8'
JACKSON_XC = 'org.codehaus.jackson:jackson-xc:jar:1.9.8'
JACKSON_MRBEAN = 'org.codehaus.jackson:jackson-mrbean:jar:1.9.8'
JACKSON_SMILE = 'org.codehaus.jackson:jackson-smile:jar:1.9.8'
JAVASSIST = 'javassist:javassist:jar:3.3'
JAXB_API = 'javax.xml.bind:jaxb-api:jar:2.2.6'
JAXB_IMPL = 'com.sun.xml.bind:jaxb-impl:jar:2.2.4'
JAXRPC_API = 'javax.xml:jaxrpc-api:jar:1.1'
JAX_RPC = 'org.apache.axis:axis-jaxrpc:jar:1.4'
JDOM = 'org.jdom:jdom:jar:2.0.2'
JERSEY_CLIENT = 'com.sun.jersey:jersey-client:jar:1.13'
JERSEY_CORE = 'com.sun.jersey:jersey-core:jar:1.13'
JERSEY_JSON = 'com.sun.jersey:jersey-json:jar:1.13'
JERSEY_SERVER = 'com.sun.jersey:jersey-server:jar:1.13'
JERSEY_SERVLET = 'com.sun.jersey:jersey-servlet:jar:1.13'
JERSEY_SPRING = 'com.sun.jersey.contribs:jersey-spring:jar:1.13'
JETTISON = 'org.codehaus.jettison:jettison:jar:1.2'
JSOUP = 'org.jsoup:jsoup:jar:1.6.3'
JODA_TIME = 'joda-time:joda-time:jar:2.1'
JTA = 'javax.transaction:jta:jar:1.1'
LIB_PHONE_NUMBER = 'com.googlecode.libphonenumber:libphonenumber:jar:5.0'
LOGBACK_ACCESS = 'ch.qos.logback:logback-access:jar:1.0.6'
LOGBACK_CLASSIC = 'ch.qos.logback:logback-classic:jar:1.0.6'
LOGBACK_CORE = 'ch.qos.logback:logback-core:jar:1.0.6'
MAIL = 'javax.mail:mail:jar:1.4.5'
MYSQL = 'mysql:mysql-connector-java:jar:5.1.21'
OFF_GEOCODER = 'com.googlecode.libphonenumber:geocoder:jar:2.1'
OPEN_CSV = 'net.sf.opencsv:opencsv:jar:2.3'
RESTFB = 'com.restfb:restfb:jar:1.6.9'
SPRING_AOP = 'org.springframework:spring-aop:jar:3.0.5.RELEASE'
SPRING_ASM = 'org.springframework:spring-asm:jar:3.0.5.RELEASE'
SPRING_BEANS = 'org.springframework:spring-beans:jar:3.0.5.RELEASE'
SPRING_CONTEXT = 'org.springframework:spring-context:jar:3.0.5.RELEASE'
SPRING_EXPRESSION = 'org.springframework:spring-expression:jar:3.0.5.RELEASE'
SPRING_JDBC = 'org.springframework:spring-jdbc:jar:3.0.5.RELEASE'
SPRING_ORM = 'org.springframework:spring-orm:jar:3.0.5.RELEASE'
SPRING_TEST = 'org.springframework:spring-test:jar:3.0.5.RELEASE'
SPRING_TRANSACTION = 'org.springframework:spring-tx:jar:3.0.5.RELEASE'
SPRING_WEB = 'org.springframework:spring-web:jar:3.0.5.RELEASE'
SPRING_CORE = 'org.springframework:spring-core:jar:3.0.5.RELEASE'
SEARCH = 'com.googlecode.genericdao:search:jar:1.0.0'
SEARCH_HIBERNATE = 'com.googlecode.genericdao:search-hibernate:jar:1.0.0'
SLF4J = 'org.slf4j:slf4j-api:jar:1.6.6'
STAX_API = 'stax:stax-api:jar:1.0.1'
TOMCAT_SERVLET = 'org.apache.tomcat:tomcat-servlet-api:jar:7.0.29'
TOMCAT_COYOTE = 'org.apache.tomcat:tomcat-coyote:jar:7.0.29'
TWITTER4J_CORE = 'org.twitter4j:twitter4j-core:jar:2.2.6'
WSDL4J = 'wsdl4j:wsdl4j:jar:1.6.2'
download artifact(GEARMAN) => 'https://launchpad.net/gearman-java/trunk/0.04/+download/gearman-java-0.04.jar'
repositories.remote << "http://repo1.maven.org/maven2"
repositories.remote << "http://braintree.github.com/braintree_java/releases"
desc "Compiling backend of Alicanto team"
tomcat1_home = ENV['TOMCAT_DEV_1']
tomcat2_home = ENV['TOMCAT_DEV_2']
test_home = ENV['TOMCAT_TEST']
warname = '/webapps/ROOT.war'
script = '/bin/rm-grroo.sh'
test_war = test_home + warname
tomcat1_war = tomcat1_home + warname
tomcat2_war = tomcat2_home + warname
#script to remove the folder of Grroo + the war.
rm_script_test = "sudo " + test_home + script + "; sleep 3; "
rm_script_tomcat1 = "sudo " + tomcat1_home + script + "; sleep 3; "
rm_script_tomcat2 = "sudo " + tomcat2_home + script + "; sleep 3; "
#shutdown and startup scripts
script_shutdown = "/bin/shutdown.sh"
test_shutdown = "sudo " + test_home + script_shutdown + "; sleep 5; "
tomcat1_shutdown = "sudo " + tomcat1_home + script_shutdown + "; sleep 5; "
tomcat2_shutdown = "sudo " + tomcat2_home + script_shutdown + "; sleep 5; "
script_startup = "/bin/startup.sh"
test_startup = "sudo " + test_home + script_startup
tomcat1_startup = "sudo " + tomcat1_home + script_startup
tomcat2_startup = "sudo " + tomcat2_home + script_startup
war = nil
engine = nil
engineartifacts = nil
engineroot = ENV['ENGINE_HOME']
engine_full_jar = engineroot + "/engine_dev.jar"
engine_lib = "engine_dev_lib/";
engine_lib_folder = engineroot + "/" + engine_lib
define "Project" do
test.using :integration
project.version = VERSION_NUMBER
project.group = GROUP
manifest['Copyright'] = COPYRIGHT
# in setup of integration - stop tomcat, remove the old war and the folder, move the new buildwar, start tomcat
integration.setup {
puts "starting integration tests" if verbose
sh test_shutdown
sh rm_script_test
sh "ln -f " + war.to_s + " " + test_war
sh "sleep 2"
sh test_startup
# wait until the server it up again
sh "while ! wget -q -O /dev/null http://10.0.0.210:5181/ ; do echo waiting ; sleep 3 ; done"
}
desc 'Building common project for engine and API'
define 'Common' do
compile.with SPRING_CORE,COMMONS_CODEC, COMMONS_IO, LANG,DAOHIBERNATE,GUAVA,HIBERNATE_JPA,HIBERNATE,HTML_CLEANER,JERSEY_CLIENT,JDOM,JERSEY_CORE,JERSEY_JSON,JERSEY_SERVER,JERSEY_SERVLET,JERSEY_SPRING,JETTISON,JODA_TIME,LIB_PHONE_NUMBER,LOGBACK_ACCESS,LOGBACK_CLASSIC,LOGBACK_CORE,OFF_GEOCODER,SPRING_AOP,SPRING_ASM,SPRING_BEANS,SPRING_CONTEXT,SPRING_EXPRESSION,SPRING_JDBC,SPRING_ORM,SPRING_TEST,SPRING_TRANSACTION,SPRING_WEB,SEARCH,SEARCH_HIBERNATE,SLF4J
package(:jar, :id=>"Common")
end
desc 'Building API project'
define 'Grroo' do
# specify the artifact for plimus, twilio and floristone since I created it locally
plimus = artifact('plimus.com:plimus:jar:1.0').from('/var/lib/selfdep/wsintegration.jar')
floristone = artifact('floristone.com:floristone:jar:1.0').from('/var/lib/selfdep/floristone.jar')
twilio = artifact('twilio.com:twilio:jar:1.0').from('/var/lib/selfdep/twilio.jar')
im4java = artifact('im4java.com:im4java:jar:1.3.2').from('/var/lib/selfdep/im4java.jar')
# install the artifact locally
install plimus
install floristone
install twilio
install im4java
libs = projects('Common'),im4java,plimus, twilio, floristone,AMAZON,ACTIVATION,ANTLR,AOPALLIANCE,ASM,ASPECTJ,AXIS,BRAINTREE,C3P0,BEANUTILS,COMMONS_HIBRENATE,COLLECTIONS,COMMONS_CODEC,DISCOVERY,HTTPCLIENT,COMMONS_IO,LANG,LOGGING,VALIDATOR,DAO,DAOHIBERNATE,DOM4J,EHCAHCE,GUAVA,GEARMAN,HIBERNATE_JPA,HIBERNATE,HTML_CLEANER,JACKSON_MAPPER,JACKSON_CORE,JACKSON_CORE_LGPL,JACKSON_MAPPER_LGPL,JACKSON_JAXRS,JACKSON_XC,JACKSON_MRBEAN,JACKSON_SMILE,JAVASSIST,JAXB_API,JAXB_IMPL,JAX_RPC,JDOM,JERSEY_CLIENT,JDOM,JERSEY_CORE,JERSEY_JSON,JERSEY_SERVER,JERSEY_SERVLET,JERSEY_SPRING,JETTISON,JODA_TIME,JSOUP,JTA,LIB_PHONE_NUMBER,LOGBACK_ACCESS,LOGBACK_CLASSIC,LOGBACK_CORE,MAIL,MYSQL,OFF_GEOCODER,OPEN_CSV,SPRING_AOP,SPRING_ASM,SPRING_BEANS,SPRING_CONTEXT,SPRING_CORE, SPRING_EXPRESSION,SPRING_JDBC,SPRING_ORM,SPRING_TEST,SPRING_TRANSACTION,SPRING_WEB,RESTFB,AXIS_SAAJ,RESTFB,SEARCH,SEARCH_HIBERNATE,SLF4J,STAX_API,TWITTER4J_CORE,WSDL4J
compile.with libs,TOMCAT_COYOTE, TOMCAT_SERVLET
war = package(:war, :id=>"Grroo")
war.with :libs => libs
test.using :integration
test.exclude('*')
end
desc 'Building the engine project based on common'
define 'Engine' do
enginelibs = projects('Common'),LIB_PHONE_NUMBER, CGLIB, SPRING_CORE, CGLIB_NODEP, ACTIVATION,ANTLR,AOPALLIANCE,ASM,ASPECTJ,C3P0,BEANUTILS,COLLECTIONS,DISCOVERY,HTTPCLIENT,COMMONS_IO,LANG,LOGGING,VALIDATOR,DAO,DAOHIBERNATE,DOM4J,EHCAHCE,GUAVA,HIBERNATE_JPA,HIBERNATE,COMMONS_HIBRENATE,JAVASSIST,JAXB_API,JAXB_IMPL,JAXRPC_API,JDOM,JERSEY_CLIENT,JERSEY_CORE,JERSEY_JSON,JODA_TIME,JTA,LOGBACK_ACCESS,LOGBACK_CLASSIC,LOGBACK_CORE,MAIL,MYSQL,SPRING_AOP,SPRING_ASM,SPRING_BEANS,SPRING_CONTEXT,SPRING_EXPRESSION,SPRING_JDBC,SPRING_ORM,SPRING_TEST,SPRING_TRANSACTION,SPRING_WEB,SEARCH,SEARCH_HIBERNATE,SLF4J,JACKSON_MAPPER,JACKSON_CORE,JACKSON_CORE_LGPL,JACKSON_MAPPER_LGPL,JACKSON_JAXRS,JACKSON_XC,JACKSON_MRBEAN,JACKSON_SMILE
compile.with enginelibs
test.using :integration
test.with HTML_CLEANER,COMMONS_CODEC
puts "package engine jar" if verbose
# package the engine jar
engine = package(:jar, :id=>"Engine")
engineartifacts = Buildr.artifacts(enginelibs)
manifest_cp = engineartifacts.map{ |d| "#{File.basename(d.to_s)}"}.join(" " + engine_lib)
engine.with :manifest=>{ 'Main-Class'=>'com.grroo.engine.main.EngineMain','Class-Path'=>" " + engine_lib + manifest_cp }
#extending the test task if everything worked fine:
end
task :copy_files => [task(:integration)] do
info "after integration success" if verbose
# stop tomcat on port dev1 to copy the new version and tomcat on tests
sh tomcat1_shutdown
sh rm_script_tomcat1
sh "ln -f " + war.to_s + " " + tomcat1_war
sh "sleep 2"
# start tomcat
sh tomcat1_startup
# wait for the application to go up
sh "while ! wget -q -O /dev/null http://api1.dev.alicanto.com/ ; do echo waiting ; sleep 3 ; done"
sh tomcat2_shutdown
sh rm_script_tomcat2
sh "ln -f " + war.to_s + " " + tomcat2_war
sh "sleep 2"
# start tomcat
sh tomcat2_startup
sh "while ! wget -q -O /dev/null http://api2.dev.alicanto.com/ ; do echo waiting ; sleep 3 ; done"
#stop the old engine and copy the new version
sh "d='jps -l | grep " + engine_full_jar + "| cut -d \' \' -f 1\'; if [ -z \"$d\" ]; then :; else kill \"$d\"; fi;"
rm_rf engine_lib_folder
sh "sleep 3"
mkdir_p engine_lib_folder
engineartifacts.map(&:to_s).each do |artifact|
cp artifact, engine_lib_folder
end
sh "sleep 3"
cp engine.to_s, engine_full_jar
sh "sleep 3"
puts "starting engine" if verbose
sh "nohup java -jar " + engine_full_jar + " \&> /var/log/engine/dev/startengine.log \&"
end
end