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
10
http://www.apache.org/licenses/LICENSE-2.0
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.
18
<project name="solr" default="usage">
19
<description>Solr</description>
21
<target name="usage" description="Prints out instructions">
22
<echo message="Welcome to the Solr project!" />
23
<echo message="Use 'ant example' to create a runnable example configuration." />
24
<echo message="Use 'ant run-example' to create and run the example." />
25
<echo message="And for developers:"/>
26
<echo message="Use 'ant clean' to clean compiled files." />
27
<echo message="Use 'ant compile' to compile the source code." />
28
<echo message="Use 'ant dist' to build the project WAR and JAR files." />
29
<echo message="Use 'ant javadocs' to build javadocs under build/docs/api" />
30
<echo message="Use 'ant generate-maven-artifacts' to generate maven artifacts." />
31
<echo message="Use 'ant package' to generate zip, tgz for distribution." />
32
<echo message="Use 'ant luke' to start luke. see: http://luke.googlecode.com" />
33
<echo message="Use 'ant test' to run unit tests." />
36
<import file="common-build.xml"/>
38
<!-- ========================================================================= -->
39
<!-- ============================== USER TASKS =============================== -->
40
<!-- ========================================================================= -->
42
<target name="example" description="Creates a runnable example configuration."
44
<copy file="${dist}/${fullnamever}.war"
45
tofile="${example}/webapps/${ant.project.name}.war"/>
46
<delete includeemptydirs="true">
47
<fileset dir="${example}/work" includes="**/*"/>
49
<echo>See ${example}/README.txt for how to run the Solr example configuration.</echo>
52
<target name="run-example" depends="example"
53
description="Run Solr interactively, via Jetty. -Dexample.debug=true to enable JVM debugger">
54
<property name="example.solr.home" location="example/solr"/>
55
<property name="example.data.dir" location="example/solr/data"/>
56
<property name="example.debug.suspend" value="n"/>
57
<property name="example.jetty.port" value="8983"/>
58
<condition property="example.jvm.line" value="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=${example.debug.suspend},address=5005">
59
<isset property="example.debug"/>
61
<property name="example.jvm.line" value=""/>
62
<property name="example.heap.size" value="512M"/>
63
<java jar="${example}/start.jar" fork="true" dir="${example}" maxmemory="${example.heap.size}">
64
<jvmarg line="${example.jvm.line}"/>
65
<sysproperty key="solr.solr.home" file="${example.solr.home}"/>
66
<sysproperty key="solr.data.dir" file="${example.data.dir}"/>
67
<sysproperty key="jetty.port" value="${example.jetty.port}"/>
71
<!-- setup proxy for download tasks -->
72
<condition property="proxy.specified">
74
<isset property="proxy.host"/>
75
<isset property="proxy.port"/>
76
<isset property="proxy.user"/>
80
<target name="proxy.setup" if="proxy.specified">
81
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.user}" proxypassword="${proxy.password}"/>
84
<target name="compile-xml-query-parser">
85
<ant dir="${common.dir}/contrib/xml-query-parser" target="compile-core" inheritAll="false">
86
<propertyset refid="uptodate.and.compiled.properties"/>
90
<property name="luke.version" value="1.0.1"/>
91
<available file="luke/luke-${luke.version}.jar" property="luke.jar.exists" />
92
<target name="luke-download" unless="luke.jar.exists" depends="proxy.setup,compile-xml-query-parser">
94
<get src="http://luke.googlecode.com/files/luke-${luke.version}.jar"
95
dest="luke/luke-${luke.version}.jar"/>
97
<path id="luke.classpath">
98
<pathelement location="${common.dir}/build/classes/java" />
99
<pathelement location="${common.dir}/build/contrib/xml-query-parser/classes/java" />
101
<target name="luke" depends="luke-download">
103
classname="org.getopt.luke.Luke"
108
<include name="luke-${luke.version}.jar"/>
110
<path refid="classpath"/>
111
<path refid="luke.classpath"/>
112
<path refid="test.classpath"/>
117
<!-- ========================================================================= -->
118
<!-- ========================== BUILD/TEST TASKS ============================= -->
119
<!-- ========================================================================= -->
121
<target name="compile" description="Compile the source code."
122
depends="compile-core, compile-contrib"/>
123
<target name="test" description="Validate, then run core and solrj unit tests."
124
depends="validate-solr, test-core"/>
125
<target name="test-core" description="Runs the core and solrj unit tests."
126
depends="test-solr-core, test-solrj"/>
127
<target name="compile-test" description="Compile unit tests."
128
depends="compile-solr-test-framework, compile-test-solr-core, compile-test-solrj, test-jsp"/>
129
<target name="javadocs" description="Calls javadocs-all, javadocs-solrj, and javadocs-test-framework"
130
depends="javadocs-all,javadocs-solrj,javadocs-test-framework"/>
131
<target name="compile-core" depends="compile-solr-core" unless="solr.core.compiled"/>
133
<!-- Solr core targets -->
134
<target name="test-solr-core" description="Test solr core">
135
<ant dir="core" target="test" inheritAll="false">
136
<propertyset refid="uptodate.and.compiled.properties"/>
140
<!-- Solrj targets -->
141
<target name="test-solrj" description="Test java client">
142
<ant dir="solrj" target="test" inheritAll="false">
143
<propertyset refid="uptodate.and.compiled.properties"/>
146
<target name="javadocs-solrj">
147
<ant dir="solrj" target="javadocs" inheritAll="false">
148
<propertyset refid="uptodate.and.compiled.properties"/>
152
<!-- test-framework targets -->
153
<target name="javadocs-test-framework">
154
<ant dir="test-framework" target="javadocs" inheritAll="false">
155
<propertyset refid="uptodate.and.compiled.properties"/>
159
<!-- Webapp targets -->
160
<target name="test-jsp">
161
<ant dir="webapp" target="test" inheritall="false">
162
<propertyset refid="uptodate.and.compiled.properties"/>
166
<!-- Clean targets -->
167
<target name="clean" description="Cleans compiled files and other temporary artifacts.">
168
<delete dir="build" />
169
<delete dir="dist" />
170
<delete dir="package" />
171
<delete dir="example/solr/lib" />
174
<target name="clean-dest"
175
description="Cleans out build/ but leaves build/docs/, dist/ and package/ alone. This allows us to run nightly and clover together in Hudson">
176
<delete includeemptydirs="true" >
177
<fileset dir="build">
178
<exclude name="docs/"/>
183
<!-- Clover targets -->
184
<target name="clover" depends="clover.setup, clover.info"
185
description="Instrument the Unit tests using Clover. Requires a Clover license and clover.jar in the ANT classpath. To use, specify -Drun.clover=true on the command line."/>
187
<target name="clover.setup" if="clover.enabled">
188
<taskdef resource="cloverlib.xml"/>
189
<mkdir dir="${clover.db.dir}"/>
190
<clover-setup initString="${clover.db.dir}/lucene_coverage.db">
191
<fileset dir="core/src/java"/>
192
<fileset dir="solrj/src/java"/>
193
<testsources dir="test-framework/src/java"/>
194
<testsources dir="core/src/test"/>
195
<testsources dir="solrj/src/test"/>
199
<target name="clover.info" unless="clover.present">
201
Clover not found. Code coverage reports disabled.
205
<target name="clover.check">
206
<fail unless="clover.present">
207
##################################################################
209
Please make sure clover.jar is in ANT_HOME/lib, or made available
210
to Ant using other mechanisms like -lib or CLASSPATH.
211
##################################################################
215
<!-- Run after Junit tests. -->
216
<target name="generate-clover-reports" depends="clover.check, clover">
217
<mkdir dir="${clover.report.dir}"/>
219
<current outfile="${clover.report.dir}/clover.xml"
220
title="${fullnamever}">
223
<current outfile="${clover.report.dir}" title="${fullnamever}">
224
<format type="html"/>
229
<!-- ========================================================================= -->
230
<!-- ===================== DISTRIBUTION-RELATED TASKS ======================== -->
231
<!-- ========================================================================= -->
233
<target name="copy-to-stage">
234
<copy-to-stage-macro artifacts.dir="${package.dir}"/>
238
description="Creates the Solr distribution files."
239
depends="dist-solrj, dist-core, dist-test-framework, dist-war" />
241
<target name="dist-test-framework" depends="init-dist"
242
description="Creates the Solr test-framework JAR.">
243
<ant dir="test-framework" target="dist" inheritall="false">
244
<propertyset refid="uptodate.and.compiled.properties"/>
248
<target name="dist-war"
249
description="Creates the Solr WAR Distribution file.">
250
<ant dir="webapp" target="dist" inheritall="false">
251
<propertyset refid="uptodate.and.compiled.properties"/>
255
<target name="prepare-release"
256
depends="clean, package, generate-maven-artifacts, sign-artifacts"/>
258
<!-- make a distribution -->
259
<target name="package" depends="package-src-tgz,create-package"/>
261
<!-- Makes a tarball from running "svn export" at the root level. -->
262
<!-- Copies NOTICE.txt and LICENSE.txt from solr/ to the root level. -->
263
<target name="package-src-tgz" depends="init-dist"
264
description="Packages the Solr Source Distribution">
265
<property name="source.package.file"
266
value="${package.dir}/${fullnamever}-src.tgz"/>
267
<delete file="${source.package.file}" failonerror="false" />
268
<svn-export-source source.dir=".."/>
269
<tar destfile="${source.package.file}" compression="gzip" longfile="gnu">
270
<tarfileset dir="${svn.export.dir}"
271
prefix="${fullnamever}"
272
excludes="example/**/*.sh example/**/bin/"/>
273
<tarfileset dir="${svn.export.dir}"
274
prefix="${fullnamever}"
276
includes="example/**/*.sh example/**/bin/"/>
277
<tarfileset dir="${svn.export.dir}/solr" prefix="${fullnamever}"
278
includes="NOTICE.txt,LICENSE.txt"/>
280
<make-checksums file="${source.package.file}"/>
283
<target name="package-local-src-tgz"
284
description="Packages the Solr and Lucene sources from the local working copy">
285
<mkdir dir="${common-solr.dir}/build"/>
286
<property name="source.package.file"
287
value="${common-solr.dir}/build/${fullnamever}-src.tgz"/>
288
<delete file="${source.package.file}" failonerror="false" />
290
<tar destfile="${source.package.file}" compression="gzip" longfile="gnu">
291
<tarfileset dir=".." prefix="${fullnamever}" includes="*.txt *.xml" />
292
<tarfileset dir="." prefix="${fullnamever}" includes="LICENSE.txt NOTICE.txt"/>
293
<tarfileset dir="." prefix="${fullnamever}/solr"
294
excludes="build ${package.dir}/** ${dist}/**
295
example/webapps/*.war
296
lib/README.committers.txt **/data/ **/logs/*
297
**/*.sh **/bin/ scripts/
298
.idea/ **/*.iml **/pom.xml" />
299
<tarfileset dir="." prefix="${fullnamever}/solr"
300
includes="core/src/test-files/solr/lib/classes/empty-file-main-lib.txt" />
301
<tarfileset dir="." filemode="755" prefix="${fullnamever}/solr"
302
includes="**/*.sh **/bin/ scripts/"
303
excludes="build/**"/>
304
<tarfileset dir="../lucene" prefix="${fullnamever}/lucene">
305
<patternset refid="lucene.local.src.package.patterns"/>
310
<target name="create-package"
311
description="Packages the Solr Binary Distribution"
312
depends="init-dist, dist, example, javadocs">
313
<mkdir dir="${dest}/${fullnamever}"/>
314
<delete includeemptydirs="true">
315
<fileset dir="${example}/work" includes="**/*"/>
316
<fileset dir="${dest}/${fullnamever}" includes="**/*"/>
319
<delete file="${package.dir}/${fullnamever}.tgz" failonerror="false" />
320
<delete file="${package.dir}/${fullnamever}.zip" failonerror="false" />
322
<mkdir dir="${dest}/contrib-lucene-libs-to-package"/>
323
<delete dir="${dest}/contrib-lucene-libs-to-package" includes="**/*"/>
324
<contrib-crawl target="add-lucene-libs-to-package"/>
326
<tar destfile="${package.dir}/${fullnamever}.tgz" compression="gzip" longfile="gnu">
328
prefix="${fullnamever}"
329
includes="LICENSE.txt NOTICE.txt CHANGES.txt README.txt example/**"
330
excludes="lib/README.committers.txt **/data/ **/logs/* **/classes/ **/*.sh
331
**/bin/ **/*.iml **/*.ipr **/*.iws **/pom.xml **/*pom.xml.template" />
332
<tarfileset dir="${dest}/contrib-lucene-libs-to-package"
333
prefix="${fullnamever}"
337
prefix="${fullnamever}"
338
includes="example/**/*.sh example/**/bin/" />
340
prefix="${fullnamever}"
341
includes="dist/*.jar dist/*.war dist/solrj-lib/*"
342
excludes="**/*.tgz **/*.zip **/*.md5 **/*src*.jar **/*docs*.jar" />
343
<tarfileset dir="${dest}/docs"
344
prefix="${fullnamever}/docs" />
346
<make-checksums file="${package.dir}/${fullnamever}.tgz"/>
348
<untar compression="gzip" src="${package.dir}/${fullnamever}.tgz" dest="${dest}"/>
351
This is a list of text file patterns to convert to CRLF line-ending style.
352
Shell scripts and files included in shell scripts should not be converted.
353
NB: The line-ending conversion process will mangle non-UTF8-encoded files.
355
<fixcrlf srcdir="${dest}/${fullnamever}"
358
includes="**/*.alg **/*.cfg **/*.cgi **/*.cpp **/*.css **/*.csv **/*.dtd
359
**/*.erb **/*.fcgi **/.htaccess **/*.htm **/*.html **/*.incl
360
**/*.java **/*.javacc **/*.jflex **/*.jflex-macro **/*.jj
361
**/*.js **/*.json **/*.jsp **/*LICENSE **/package-list **/*.pl
362
**/*.pom **/*pom.xml.template **/*.properties **/*.py
363
**/*.rake **/Rakefile **/*.rb **/*.rbbi **/README* **/*.rhtml
364
**/*.rslp **/*.rxml **/*.script **/*.svg **/*.tsv **/*.txt
365
**/UPGRADING **/USAGE **/*.uxf **/*.vm **/*.xcat **/*.xml
366
**/*.xsl **/*.xslt **/*.yml"
367
excludes="**/stopwordsWrongEncoding.txt **/gb18030-example.xml"
370
<zip destfile="${package.dir}/${fullnamever}.zip">
371
<zipfileset dir="${dest}/${fullnamever}"
372
prefix="${fullnamever}"
373
excludes="**/*.sh **/bin/ src/scripts/" />
374
<zipfileset dir="${dest}/${fullnamever}"
375
prefix="${fullnamever}"
376
includes="**/*.sh **/bin/ src/scripts/"
379
<make-checksums file="${package.dir}/${fullnamever}.zip"/>
382
<target name="sign-artifacts">
383
<sign-artifacts-macro artifacts.dir="${package.dir}"/>
386
<target name="javadocs-dep">
387
<copy failonerror="false" todir="${dest}/docs">
388
<fileset dir="${common-solr.dir}/site" />
392
<target name="javadocs-all" depends="prep-lucene-jars,javadocs-dep"
393
description="Generate javadoc for core and java client">
395
<mkdir dir="${dest}/docs/api"/>
397
<path id="javadoc.classpath">
398
<path refid="classpath"/>
399
<pathelement location="${dest}/solr-solrj/classes/java"/>
402
<invoke-javadoc destdir="${dest}/docs/api"
403
overview="core/src/java/overview.html">
405
<packageset dir="core/src/java" />
406
<packageset dir="solrj/src/java" />
407
<group title="Core" packages="org.apache.*" />
408
<group title="SolrJ" packages="org.apache.solr.common.*,org.apache.solr.client.solrj*" />
414
<target name="generate-maven-artifacts">
415
<taskdef uri="antlib:org.apache.maven.artifact.ant"
416
resource="org/apache/maven/artifact/ant/antlib.xml"
417
classpathref="maven-ant-tasks.classpath" />
419
<ant target="get-maven-poms" dir=".." inheritall="false"/>
420
<m2-deploy pom.xml="pom.xml"/> <!-- Solr parent POM -->
421
<subant target="dist-maven" inheritall="false" >
422
<fileset dir="core" includes="build.xml"/>
423
<fileset dir="solrj" includes="build.xml"/>
424
<fileset dir="test-framework" includes="build.xml"/>
425
<fileset dir="webapp" includes="build.xml"/>
427
<contrib-crawl target="dist-maven"/>