lucene/build.xml

355 lines
12 KiB
XML

<!-- Solr build file -->
<!--
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="solr" default="usage" basedir=".">
<!-- Initialize property values: allow easy customization via build.properties -->
<property file="build.properties" />
<property name="Name" value="Solr" />
<!-- Solr version -->
<property name="version" value="1.0" />
<!-- 3rd party libraries for compilation -->
<property name="lib" value="lib" />
<!-- solr source files -->
<property name="src" value="src" />
<!-- Destination for compiled classes and binaries -->
<property name="dest" value="build" />
<!-- Destination for distribution files (demo WAR, src distro, etc.) -->
<property name="dist" value="dist" />
<!-- Example directory -->
<property name="example" value="example" />
<property name="fullname" value="apache-${ant.project.name}"/>
<property name="fullnamever" value="apache-${ant.project.name}-${version}"/>
<!-- Javadoc properties -->
<property name="year" value="2006" />
<property name="build.docs" value="${dest}/docs"/>
<property name="build.javadoc" value="${build.docs}/api"/>
<property name="javadoc.access" value="protected"/>
<property name="javadoc.link.java"
value="http://java.sun.com/j2se/1.5.0/docs/api/"/>
<property name="javadoc.link.junit"
value="http://junit.sourceforge.net/javadoc/"/>
<property name="javadoc.link.lucene"
value="http://lucene.apache.org/java/docs/api/"/>
<property name="javadoc.packages" value="org.apache.solr.*"/>
<!-- JUnit properties -->
<property name="junit.output.dir" location="${dest}/test-results"/>
<property name="junit.reports" location="${dest}/test-results/reports"/>
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
<!-- Default target: usage. Prints out instructions. -->
<target name="usage"
description="Prints out instructions">
<echo message="Welcome to the Solr project!" />
<echo message="Use 'ant compile' to compile the source code." />
<echo message="Use 'ant dist' to build the project WAR and JAR files." />
<echo message="Use 'ant package' to build a .zip and .tgz for distribution." />
<echo message="Use 'ant example' to install solr.war in ./example" />
<echo message="Use 'ant clean' to clean compiled files." />
<echo message="Use 'ant test' to run unit tests." />
</target>
<!-- Clean: cleans compiled files and other temporary artifacts. -->
<target name="clean"
description="Cleans compiled files and other temporary artifacts.">
<delete dir="${dest}" />
<delete dir="${dist}" />
</target>
<!-- ========================================================================= -->
<!-- ===================== COMPILATION-RELATED TASKS ========================= -->
<!-- ========================================================================= -->
<!-- The compilation classpath -->
<path id="compile.classpath">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
</path>
<!-- Compile the project. -->
<target name="compile"
description="Compile the source code.">
<mkdir dir="${dest}" />
<javac destdir="${dest}"
target="1.5"
source="1.5"
debug="on"
encoding="utf8"
classpathref="compile.classpath">
<src path="${src}/java" />
<src path="${src}/webapp/src" />
</javac>
</target>
<target name="javadoc" depends="compile"
description="Generates javadoc documentation.">
<mkdir dir="${build.javadoc}"/>
<!-- we do this to make sure whatever classes where in ant's
classpath at runtime are in the classpath used by javadoc
(ie: junit.jar)
-->
<path id="javadoc.classpath">
<path refid="compile.classpath"/>
<!-- aparently ant.library.dir isn't allways set right? -->
<fileset dir="${ant.home}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${ant.library.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<javadoc
destdir="${build.javadoc}"
author="true"
version="true"
use="true"
encoding="utf8"
access="${javadoc.access}"
windowtitle="${Name} ${version} API"
doctitle="${Name} ${version} API"
bottom="Copyright &amp;copy; ${year} The Apache Software Foundation"
>
<packageset dir="${src}/java"/>
<packageset dir="${src}/webapp/src"/>
<link href="${javadoc.link.java}"/>
<link href="${javadoc.link.junit}"/>
<link href="${javadoc.link.lucene}"/>
<classpath refid="javadoc.classpath"/>
</javadoc>
</target>
<!-- ========================================================================= -->
<!-- ===================== TESTING-RELATED TASKS ============================= -->
<!-- ========================================================================= -->
<!-- Classpath for unit test compilation. -->
<!-- For now, it's the same as main classpath. Later it will have JUnit, Clover, etc. -->
<path id="test.compile.classpath">
<path refid="compile.classpath" />
<pathelement location="${dest}"/>
</path>
<path id="test.run.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${dest}/tests"/>
</path>
<!-- Compile unit tests. -->
<target name="compileTests"
description="Compile unit tests."
depends="compile">
<mkdir dir="${dest}/tests" />
<javac
destdir="${dest}/tests"
target="1.5"
source="1.5"
debug="on"
encoding="utf8"
classpathref="test.compile.classpath">
<src path="${src}/test" />
<src path="${src}/apps/SolrTest/src" />
</javac>
</target>
<!-- Run unit tests. -->
<target name="test"
description="Runs the unit tests."
depends="compileTests, junit" />
<target name="legacyTest"
depends="compileTests" >
<!-- DEPRECATED: no description so it doesn't show up in project help -->
<java classname="SolrTest" fork="true" dir="src/apps/SolrTest" failonerror="true">
<arg line="-test newtest.txt -qargs qt=test"/>
<classpath>
<path refid="test.run.classpath" />
</classpath>
</java>
</target>
<target name="junit" depends="compileTests">
<!-- no description so it doesn't show up in -projecthelp -->
<mkdir dir="${junit.output.dir}"/>
<!-- :TODO: either SolrCore needs a way to specify the
solrconfig.xml, or all test are going to need to use the same
conf file, either way we need a specific run directory for
the tests.
-->
<junit printsummary="withOutAndErr"
haltonfailure="no"
errorProperty="tests.failed"
failureProperty="tests.failed"
dir="src/test/test-files/"
>
<syspropertyset>
<propertyref prefix="solr" />
</syspropertyset>
<classpath refid="test.run.classpath"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.output.dir}" unless="testcase">
<fileset dir="src/test" includes="${junit.includes}"/>
</batchtest>
<batchtest fork="yes" todir="${junit.output.dir}" if="testcase">
<fileset dir="src/test" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<target name="test-reports"
description="Generates HTML test reports.">
<mkdir dir="${junit.reports}"/>
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.reports}"/>
</junitreport>
</target>
<!-- ========================================================================= -->
<!-- ===================== DISTRIBUTION-RELATED TASKS ======================== -->
<!-- ========================================================================= -->
<!-- Creates the Solr distribution files. -->
<target name="dist"
description="Creates the Solr distribution files."
depends="dist-src, dist-war, dist-jar" />
<!-- Creates the Solr WAR file. -->
<target name="dist-war"
description="Creates the demo WAR file."
depends="compile">
<mkdir dir="${dist}" />
<war destfile="${dist}/${fullnamever}.war"
webxml="${src}/webapp/WEB-INF/web.xml">
<classes dir="${dest}" includes="org/apache/**" />
<lib dir="${lib}">
<exclude name="servlet-api*.jar" />
</lib>
<fileset dir="${src}/webapp/resources" />
</war>
</target>
<!-- Creates the source jar. -->
<target name="dist-src"
description="Creates the source distribution." >
<mkdir dir="${dist}" />
<zip destfile="${dist}/${fullnamever}-src.zip"
basedir="${src}" />
</target>
<!-- Creates the solr jar. -->
<target name="dist-jar"
description="Creates the binary distribution."
depends="compile">
<mkdir dir="${dist}" />
<jar destfile="${dist}/${fullnamever}.jar"
basedir="${dest}"
includes="org/apache/**" />
</target>
<target name="example"
depends="dist-war">
<copy file="${dist}/${fullnamever}.war"
tofile="${example}/webapps/${ant.project.name}.war"/>
<copy todir="${example}/solr/bin">
<fileset dir="${src}/scripts">
<exclude name="scripts.conf"/>
</fileset>
</copy>
<chmod dir="${example}/solr/bin" perm="755" includes="**"/>
</target>
<target name="dist-example"
depends="example">
<zip destfile="${dist}/${fullnamever}-example.zip">
<zipfileset dir="${example}"
prefix="${fullnamever}-${example}"
excludes="data/ logs/*"
/>
</zip>
</target>
<!-- make a distribution -->
<target name="package"
depends="dist, example, javadoc">
<zip destfile="${dist}/${fullnamever}.zip">
<zipfileset dir="."
prefix="${fullnamever}"
includes="*.txt *.xml lib/** src/** example/**"
excludes="**/data/ **/logs/ **/classes/" />
<zipfileset dir="."
prefix="${fullnamever}"
includes="dist/*.jar dist/*.war" />
<zipfileset dir="${dest}/docs/api/"
prefix="${fullnamever}/docs/api/" />
</zip>
<tar destfile="${dist}/${fullnamever}.tgz" compression="gzip">
<tarfileset dir="."
prefix="${fullnamever}"
includes="*.txt *.xml lib/** src/** example/**"
excludes="**/data/ **/logs/ **/classes/" />
<tarfileset dir="."
prefix="${fullnamever}"
includes="dist/*.jar dist/*.war" />
<tarfileset dir="${dest}/docs/api/"
prefix="${fullnamever}/docs/api/" />
</tar>
</target>
<target name="nightly"
depends="test, package">
</target>
</project>