lucene/build.xml

280 lines
8.9 KiB
XML
Raw Normal View History

<!-- Solr build file -->
<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="build.docs" value="${dest}/docs"/>
<property name="javadoc.link.java"
value="http://java.sun.com/j2se/1.5.0/docs/api/"/>
<property name="javadoc.packages" value="org.apache.solr.*"/>
<property name="build.javadoc" value="${build.docs}/api"/>
<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 distribution files." />
<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"
classpathref="compile.classpath">
<src path="${src}/java" />
<src path="${src}/webapp/src" />
</javac>
</target>
<target name="javadoc" depends="compile">
<mkdir dir="${build.javadoc}"/>
<javadoc
destdir="${build.javadoc}"
author="true"
version="true"
use="true"
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}"/>
<classpath refid="compile.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"
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"/>
<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="on"
haltonfailure="no"
errorProperty="tests.failed"
failureProperty="tests.failed"
dir="src/apps/SolrTest"
>
<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">
<!-- no description so it doesn't show up in -projecthelp ... yet -->
<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}/${ant.project.name}-${version}.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 distribution. -->
<target name="dist-src"
description="Creates the source distribution." >
<mkdir dir="${dist}" />
<zip destfile="${dist}/${ant.project.name}-${version}-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}/${ant.project.name}-${version}.jar"
basedir="${dest}"
includes="org/apache/**" />
</target>
<target name="example"
depends="dist-war">
<copy file="${dist}/${ant.project.name}-${version}.war" tofile="${example}/webapps/${ant.project.name}.war"/>
</target>
<target name="dist-example"
depends="example">
<zip destfile="${dist}/${ant.project.name}-${version}-example.zip">
<zipfileset dir="${example}"
prefix="${ant.project.name}-${example}"
excludes="data/ logs/*"
/>
</zip>
</target>
<!-- make a distribution -->
<target name="package"
depends="dist, example, javadoc">
<zip destfile="${dist}/${ant.project.name}-${version}.zip">
<zipfileset dir="."
prefix="${ant.project.name}-${version}"
includes="*.txt *.xml lib/** src/** example/**"
excludes="**/data/ **/logs/ **/classes/" />
<zipfileset dir="."
prefix="${ant.project.name}-${version}"
includes="dist/*.jar dist/*.war" />
<zipfileset dir="${dest}/docs/api/"
prefix="${ant.project.name}-${version}/docs/api/" />
</zip>
</target>
<target name="nightly"
depends="test, package">
</target>
</project>