forked from tjake/Solandra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
311 lines (261 loc) · 10.6 KB
/
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
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
<!--
~ Copyright 2009 T Jake Luciani
~
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project name="solandra" default="dist" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<description>Solandra</description>
<property name="src" location="src" />
<property name="test" location="test" />
<property name="config" location="config" />
<property name="build" location="build" />
<property name="build.classes" location="${build}/classes" />
<property name="build.test.classes" location="${build}/test-classes" />
<property name="lib" location="lib" />
<property name="cassandra.base" location="${basedir}" />
<property name="app" location="solandra-app" />
<property name="resources" location="resources" />
<property name="autogen.thrift.dir" location="${basedir}/thrift" />
<!-- ivy properties -->
<property name="ivy.version" value="2.2.0" />
<property name="ivy.dir" location="${build}/ivy" />
<property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar" />
<property name="ivy.lib.dir" location="${lib}" />
<property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
<property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
<target name="init">
<tstamp />
<mkdir dir="${build}" />
<mkdir dir="${build}/output" />
<mkdir dir="${build.classes}" />
<mkdir dir="${build.test.classes}" />
<mkdir dir="${ivy.dir}" />
<mkdir dir="${ivy.lib.dir}" />
<mkdir dir="${app}" />
<!--
Allow Ivy to be disabled with "-Dnoivy=".
It is kind of a hack to pretend that we already found it,
but Ant doesn't provide an easy way of blocking dependencies
from executing or checking multiple conditions.
-->
<condition property="ivy.found">
<isset property="noivy" />
</condition>
<condition property="offline">
<isset property="noivy" />
</condition>
<condition property="cassandra.found">
<isset property="cassandra" />
</condition>
</target>
<target name="ivy-download" description="To download ivy" unless="offline">
<get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true" />
</target>
<target name="ivy-probe-antlib">
<condition property="ivy.found">
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache" />
</condition>
</target>
<target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
<typedef uri="antlib:org.apache.ivy.ant" onerror="fail" loaderRef="ivyLoader">
<classpath>
<pathelement location="${ivy.jar}" />
</classpath>
</typedef>
<fail>
<condition>
<not>
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache" />
</not>
</condition>
You need Apache Ivy 2.0 or later from http://ant.apache.org/
It could not be loaded from ${ivy_repo_url}
</fail>
</target>
<target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
<ivy:retrieve />
</target>
<path id="autoivy.classpath">
<fileset dir="${ivy.lib.dir}">
<include name="**/*.jar" />
<exclude name="**/*cassandra*.jar" if="cassandra.found" />
</fileset>
</path>
<!-- =========================== -->
<path id="solandra.classpath">
<pathelement location="${build.classes}" />
<pathelement location="${build.test.classes}" />
<pathelement location="${resources}" />
<pathelement location="${resources}/solr" />
<pathelement location="${resources}/cassandra" />
<fileset dir="${lib}">
<include name="**/*.jar" />
<exclude name="**/*cassandra*.jar" if="cassandra.found" />
</fileset>
<fileset dir="${cassandra}" erroronmissingdir="false">
<include name="lib/*.jar" />
<include name="build/*.jar" />
</fileset>
<path refid="autoivy.classpath" />
<pathelement location="${cassandra}/build/classes" />
</path>
<target name="compile" depends="init,resolve">
<javac debug="true" destdir="${build.classes}">
<src path="${src}" />
<src path="${autogen.thrift.dir}/gen-java" />
<classpath refid="solandra.classpath" />
</javac>
</target>
<target name="compile.tests" depends="compile">
<javac debug="true" destdir="${build.test.classes}">
<src path="${test}" />
<classpath refid="solandra.classpath" />
</javac>
</target>
<target name="test" depends="compile.tests">
<echo message="running tests" />
<mkdir dir="${build}/output" />
<junit fork="on" failureproperty="testfailed">
<classpath>
<path refid="solandra.classpath" />
<pathelement location="${basedir}/solandra-app/" />
</classpath>
<formatter type="xml" usefile="true" />
<formatter type="brief" usefile="false" />
<batchtest todir="${build}/output">
<fileset dir="${build.test.classes}" includes="**/SolandraTests.class" />
</batchtest>
<jvmarg value="-Xmx1G" />
<jvmarg value="-Dlog4j.configuration=file:///${basedir}/resources/cassandra/log4j-tools.properties" />
<jvmarg value="-Dlog4j.defaultInitOverride=true" />
</junit>
<fail if="testfailed" message="Some test(s) failed." />
</target>
<target name="test-long" depends="compile.tests">
<echo message="running tests" />
<mkdir dir="${build}/output" />
<junit fork="on" failureproperty="testfailed">
<classpath>
<path refid="solandra.classpath" />
<pathelement location="${basedir}/solandra-app/" />
</classpath>
<formatter type="xml" usefile="true" />
<formatter type="brief" usefile="false" />
<batchtest todir="${build}/output">
<fileset dir="${build.test.classes}" includes="**/IndexManagerTests.class" />
</batchtest>
<jvmarg value="-Xmx1G" />
<jvmarg value="-Dlog4j.configuration=file:///${basedir}/resources/log4j.properties" />
<jvmarg value="-Dlog4j.defaultInitOverride=true" />
</junit>
<fail if="testfailed" message="Some test(s) failed." />
</target>
<target name="solandra.jar" depends="compile,compile.tests">
<jar jarfile="solandra.jar" basedir="${build.classes}" />
<jar jarfile="solandra-tests.jar" basedir="${build.test.classes}" />
</target>
<target name="clean">
<delete dir="${build}" />
<delete dir="${lib}" />
<delete dir="${app}" />
<delete dir="${autogen}" />
<delete file="solandra.jar" />
<delete file="solandra-tests.jar" />
<delete file="solandra.war" />
</target>
<!-- ============================= -->
<target name="war" depends="solandra.jar">
<war destfile="solandra.war" webxml="${resources}/solr/web.xml">
<lib dir="${lib}">
<exclude name="jetty*.jar" />
<exclude name="servlet-api*.jar" />
<exclude name="easymock.jar" />
</lib>
<lib dir="${cassandra.base}/lib">
<include name="**/*.jar" />
</lib>
<lib dir="${cassandra.base}/build">
<include name="**/*.jar" />
</lib>
<classes dir="${resources}">
<include name="*.properties" />
</classes>
<lib file="solandra.jar" />
</war>
</target>
<target name="dist" depends="solandra.jar">
<delete dir="${app}" />
<mkdir dir="${app}" />
<mkdir dir="${app}/conf" />
<mkdir dir="${app}/lib" />
<mkdir dir="${app}/bin" />
<copy todir="${app}/lib">
<fileset dir="${lib}" includes="*.jar" />
<fileset dir="${basedir}" includes="solandra.jar" />
</copy>
<copy todir="${app}/conf" overwrite="false">
<fileset dir="${resources}/solr" includes="solrconfig.xml,schema.xml,*.txt,jetty.xml,jetty-logging.xml" />
<fileset dir="${resources}" includes="solandra.properties" />
<fileset dir="${resources}/cassandra" includes="solandra-env.sh,solandra.properties,cassandra.yaml,log4j-tools.properties,log4j-server.properties" />
</copy>
<copy todir="${app}/bin" overwrite="false">
<fileset dir="${resources}/cassandra" includes="solandra,cassandra-cli,nodetool,solandra.in.sh,solandra.bat" />
</copy>
<chmod dir="${app}/bin" perm="755" includes="solandra,cassandra-cli,nodetool" />
<echo>Solandra successfully built</echo>
<echo>You can excute the following command to start the server.</echo>
<echo>cd ${app}; bin/solandra</echo>
</target>
<target name="set.cassandra">
<fail unless="cassandra.found">path to cassandra not found use -Dcassandra=...</fail>
</target>
<!-- Construct the path to the cassandra distribution. Taken from the command
line if set like this
ant cassandra-dist -Dcassandra=apache-cassandra-0.7.1
-->
<!-- Copy our required runtime file the cassandra extracted directory -->
<target name="cassandra-dist" depends="init,set.cassandra,solandra.jar">
<!-- copy over all the new jar files -->
<copy todir="${cassandra}/lib">
<fileset dir="${lib}" includes="jetty*.jar,servlet*.jar,jsp*.jar, solr*.jar, lucene*.jar, commons*.jar, velocity*.jar, snappy*.jar" />
<fileset dir="${basedir}" includes="solandra.jar" />
</copy>
<!-- copy the solr data -->
<copy todir="${cassandra}/conf" overwrite="false">
<fileset dir="${resources}/solr" includes="solrconfig.xml,schema.xml,*.txt" />
<fileset dir="${resources}" includes="solandra.properties" />
</copy>
<copy overwrite="true" file="${cassandra}/bin/cassandra" tofile="${cassandra}/bin/solandra" />
<replace file="${cassandra}/bin/solandra" failOnNoReplacements="true">
<replacetoken>classname="org.apache.cassandra.thrift.CassandraDaemon"</replacetoken>
<replacevalue>classname="solandra.SolandraServer"</replacevalue>
</replace>
<chmod dir="${cassandra}/bin" perm="755" includes="solandra" />
<echo>Libraries successfully copied into cassandra distribution</echo>
<echo>Start the cassandra server with ${cassandra}/bin/solandra command</echo>
</target>
<!-- Generate thrift code.-->
<target name="gen-thrift-java" description="Generate Thrift Java artifacts">
<echo>Generating Thrift Java code from ${basedir}/thrift/lucandra.thrift ....</echo>
<exec executable="thrift" dir="${basedir}/thrift" failonerror="true">
<arg line="--gen java:hashcode" />
<arg line="-o ${autogen.thrift.dir}" />
<arg line="lucandra.thrift" />
</exec>
</target>
</project>