lucene/build.xml

648 lines
22 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=".">
<import file="common-build.xml"/>
<!-- 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" />
<!-- Javadoc properties -->
<property name="build.docs" value="${dest}/docs"/>
<property name="build.javadoc" value="${build.docs}/api"/>
<property name="build.javadoc.solrj" value="${build.docs}/api-solrj"/>
<!-- JUnit properties -->
<property name="junit.output.dir" location="${dest}/test-results"/>
<property name="junit.reports" location="${dest}/test-results/reports"/>
<property name="clover.db.dir" location="${dest}/tests/clover/db"/>
<property name="clover.report.dir" location="${dest}/tests/clover/reports"/>
<available
property="clover.present"
classname="com.cenqua.clover.tasks.CloverReportTask"
/>
<condition property="clover.enabled">
<and>
<isset property="run.clover"/>
<isset property="clover.present"/>
</and>
</condition>
<!-- Macro for building Jars -->
<macrodef name="solr-jar">
<attribute name="destfile" />
<attribute name="basedir" />
<attribute name="includes" default="org/apache/**" />
<attribute name="manifest" default="${dest}/META-INF/MANIFEST.MF" />
<element name="nested" optional="true" implicit="true" />
<sequential>
<jar destfile="@{destfile}"
basedir="@{basedir}"
includes="@{includes}"
filesetmanifest="skip"
manifest="@{manifest}">
<metainf dir="${basedir}" includes="LICENSE.txt,NOTICE.txt"/>
<nested />
</jar>
</sequential>
</macrodef>
<!-- Default target: usage. Prints out instructions. -->
<target name="usage"
description="Prints out instructions">
<echo message="Welcome to the Solr project!" />
<echo message="Use 'ant example' to create a runnable example configuration." />
<echo message="And for developers:"/>
<echo message="Use 'ant clean' to clean compiled files." />
<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 test' to run unit tests." />
</target>
<!-- Clean: cleans compiled files and other temporary artifacts. -->
<target name="clean" depends="contrib-clean"
description="Cleans compiled files and other temporary artifacts.">
<delete dir="${dest}" />
<delete dir="${dist}" />
</target>
<target name="clean-dest"
description="Cleans out ${dest} but leaves ${dist} alone. This allows us to run nightly and clover together in Hudson">
<delete includeemptydirs="true" >
<fileset dir="${dest}">
<exclude name="docs/"/>
</fileset>
</delete>
</target>
<!-- Prepares an entity file for use in Forrest documentation -->
<target name="init-forrest-entities">
<!-- no description, don't advertise -->
<mkdir dir="${dest}" />
<!-- A folder containing the expanded war file -->
<mkdir dir="${dest}/web" />
<echo file="${dest}/solr-specific-forrest-variables.ent" append="false">
&lt;!ENTITY solr.specversion "${specversion}"&gt;
</echo>
</target>
<!-- ========================================================================= -->
<!-- ===================== COMPILATION-RELATED TASKS ========================= -->
<!-- ========================================================================= -->
<!-- Compile common classes. -->
<target name="compile-common"
description="Compile the source code."
depends="init-forrest-entities">
<solr-javac destdir="${dest}/common"
classpathref="compile.classpath">
<src path="${src}/java" />
<include name="org/apache/solr/common/**" />
</solr-javac>
</target>
<!-- The compilation classpath -->
<path id="compile.classpath">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
<pathelement location="${dest}/common"/>
</path>
<!-- Compile the project. -->
<target name="compile"
description="Compile the source code."
depends="compile-common,init-forrest-entities">
<solr-javac destdir="${dest}/core"
classpathref="compile.classpath.solrj-embedded">
<src path="${src}/java" />
<src path="${src}/webapp/src" />
<src path="client/java/solrj/src" />
<exclude name="org/apache/solr/common/**" />
</solr-javac>
</target>
<target name="core-javadoc" depends="compile"
description="Generates javadoc documentation.">
<mkdir dir="${build.javadoc}"/>
<path id="javadoc.classpath">
<path refid="compile.classpath"/>
</path>
<javadoc
destdir="${build.javadoc}"
author="true"
version="true"
failonerror="true"
use="true"
encoding="utf8"
access="${javadoc.access}"
windowtitle="${Name} ${version} API"
doctitle="${Name} ${version} API (${specversion})"
bottom="Copyright &amp;copy; ${javadoc.years} 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>
<target name="javadoc" depends="core-javadoc, contrib-javadoc">
</target>
<target name="stub-factories" depends="dist-jar"
description="Generates stub factories as needed">
<path id="stub.jars">
<!-- this needs to be a list of all jars that might contain
classes we want to build factories for
-->
<fileset dir="${lib}">
<include name="lucene-*.jar"/>
</fileset>
<fileset dir="${dist}">
<include name="*.jar"/>
<exclude name="*solrj*.jar"/>
</fileset>
</path>
<pathconvert property="jar.list" pathsep=" " refid="stub.jars" />
<property name="stub.list" value="${dest}/need-stub-factories.txt" />
<java fork="false"
classname="org.apache.solr.util.SuggestMissingFactories"
logError="true"
failonerror="true"
classpathref="test.run.classpath"
output="${stub.list}">
<arg line="${jar.list}" />
</java>
<fail unless="stub.src.path">...
This task requires that the property 'stub.src.path' be set.
It must contain a "path" listing directories containing source
files that this task should use when looking for classes that
need factories created, the format is platform specific --
typically it is colon seperated in Unix, semi-colon seperated
on windows, ie:
ant stub-factories -Dstub.src.path="./src:../lucene/contrib:../lucene/src/java"
FYI: The file ${stub.list} contains a list of classes
that seem to need stub factories. (if java files can be found to
use as guides for creating them).
</fail>
<pathconvert pathsep=" " property="stub.src.dirs">
<path>
<pathelement path="${stub.src.path}"/>
</path>
</pathconvert>
<exec executable="${basedir}/src/dev-tools/stub-analysis-factory-maker.pl"
dir="src/java/org/apache/solr/analysis/"
failonerror="true">
<redirector input="${stub.list}">
<!-- place to put special case classes we want to ignore -->
<inputfilterchain>
<linecontainsregexp negate="true">
<!-- only for internal Solr highlighting purposes -->
<regexp pattern="TokenOrderingFilter"/>
</linecontainsregexp>
<linecontainsregexp negate="true">
<!-- no way to leverage this in Solr -->
<regexp pattern="CachingTokenFilter"/>
</linecontainsregexp>
<linecontainsregexp negate="true">
<!-- no way to leverage this in Solr -->
<regexp pattern="HyphenationCompoundWordTokenFilter"/>
</linecontainsregexp>
<linecontainsregexp negate="true">
<!-- no way to leverage these in Solr (yet) -->
<regexp pattern="Sink\|Tee"/>
</linecontainsregexp>
<linecontainsregexp negate="true">
<!-- Solr already has a different impl for this -->
<regexp pattern="SynonymTokenFilter"/>
</linecontainsregexp>
<linecontainsregexp negate="true">
<!-- solr and lucene both have one? ? ? ? -->
<regexp pattern="LengthFilter"/>
</linecontainsregexp>
</inputfilterchain>
</redirector>
<arg line="${stub.src.dirs}"/>
</exec>
</target>
<!-- ========================================================================= -->
<!-- ===================== CLIENT: solrj ============================= -->
<!-- ========================================================================= -->
<property name="solrj-dir" value="client/java/solrj" />
<path id="compile.classpath.solrj">
<fileset dir="${solrj-dir}/lib">
<include name="*.jar" />
</fileset>
<fileset dir="${lib}">
<include name="commons-io-*.jar" />
<include name="stax-*.jar" />
</fileset>
<pathelement location="${dest}/common"/>
</path>
<!-- This depend on all of solr -->
<path id="compile.classpath.solrj-embedded">
<path refid="compile.classpath.solrj" />
<path refid="compile.classpath" />
<pathelement location="${dest}/core"/>
<!-- jetty -->
<fileset dir="example/lib">
<include name="**/*.jar" />
</fileset>
</path>
<target name="compile-solrj-core"
description="Compile the java client."
depends="compile-common">
<solr-javac destdir="${dest}/client/solrj"
classpathref="compile.classpath.solrj">
<src path="${solrj-dir}/src" />
<exclude name="org/apache/solr/client/solrj/embedded/**" />
</solr-javac>
</target>
<!-- solrj includes the embedded app -->
<target name="compile-solrj"
description="Compile the java client."
depends="compile,compile-solrj-core">
<solr-javac destdir="${dest}/client/solrj"
classpathref="compile.classpath.solrj-embedded">
<src path="${solrj-dir}/src/org/apache/solr/client/solrj/embedded" />
</solr-javac>
</target>
<target name="javadoc-solrj" depends="compile"
description="Generates solrj javadoc documentation.">
<mkdir dir="${build.javadoc.solrj}"/>
<path id="javadoc.classpath.solrj">
<path refid="compile.classpath.solrj"/>
</path>
<javadoc
destdir="${build.javadoc.solrj}"
author="true"
version="true"
failonerror="true"
use="true"
encoding="utf8"
access="${javadoc.access}"
windowtitle="${Name}-j ${version} API"
doctitle="${Name}-j ${version} API (${specversion})"
bottom="Copyright &amp;copy; ${javadoc.years} The Apache Software Foundation"
>
<packageset dir="${solrj-dir}/src" />
<link href="${javadoc.link.java}"/>
<link href="${javadoc.link.junit}"/>
<link href="${javadoc.link.lucene}"/>
<classpath refid="compile.classpath.solrj"/>
<classpath refid="compile.classpath.solrj-embedded"/>
</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" />
<path refid="compile.classpath.solrj-embedded" />
<pathelement location="${dest}/common"/>
<pathelement location="${dest}/core"/>
<pathelement location="${dest}/client/solrj"/> <!-- include solrj -->
</path>
<path id="test.run.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${dest}/tests"/>
<!-- include the solrj classpath and jetty files included in example -->
<path refid="compile.classpath.solrj" />
<pathelement path="${java.class.path}"/>
</path>
<!-- Compile unit tests. -->
<target name="compileTests"
description="Compile unit tests."
depends="compile,compile-solrj">
<mkdir dir="${dest}/tests" />
<solr-javac
destdir="${dest}/tests"
classpathref="test.compile.classpath">
<src path="${src}/test" />
<src path="${solrj-dir}/test" />
</solr-javac>
</target>
<!-- Run core unit tests. -->
<target name="core-test"
description="Runs the core unit tests."
depends="init-forrest-entities, compileTests, junit" />
<!-- Run contrib unit tests. -->
<target name="test"
description="Runs the core unit tests."
depends="core-test, contrib-test" />
<target name="junit" depends="compileTests">
<!-- no description so it doesn't show up in -projecthelp -->
<mkdir dir="${junit.output.dir}"/>
<junit printsummary="on"
haltonfailure="no"
errorProperty="tests.failed"
failureProperty="tests.failed"
dir="src/test/test-files/"
>
<formatter type="brief" usefile="false" if="junit.details"/>
<classpath refid="test.run.classpath"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.output.dir}" unless="testcase">
<fileset dir="src/test" includes="${junit.includes}"/>
<!-- this will start jetty and run some tests through HTTP -->
<fileset dir="${solrj-dir}/test/" includes="${junit.includes}" />
</batchtest>
<batchtest fork="yes" todir="${junit.output.dir}" if="testcase">
<fileset dir="src/test" includes="**/${testcase}.java"/>
<fileset dir="${solrj-dir}/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>
<target name="clover" depends="clover.setup, clover.info"
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."/>
<target name="clover.setup" if="clover.enabled">
<taskdef resource="clovertasks"/>
<mkdir dir="${clover.db.dir}"/>
<clover-setup initString="${clover.db.dir}/solr_coverage.db">
<fileset dir="src/java"/>
<fileset dir="src/webapp/src"/>
</clover-setup>
</target>
<target name="clover.info" unless="clover.present">
<echo>
Clover not found. Code coverage reports disabled.
</echo>
</target>
<target name="clover.check">
<fail unless="clover.present">
##################################################################
Clover not found.
Please make sure clover.jar is in ANT_HOME/lib, or made available
to Ant using other mechanisms like -lib or CLASSPATH.
##################################################################
</fail>
</target>
<!--
Run after Junit tests.
-->
<target name="generate-clover-reports" depends="clover.check, clover">
<mkdir dir="${clover.report.dir}"/>
<clover-report>
<current outfile="${clover.report.dir}/clover.xml"
title="${fullnamever}">
<format type="xml"/>
</current>
<current outfile="${clover.report.dir}" title="${fullnamever}">
<format type="html"/>
</current>
</clover-report>
</target>
<!-- ========================================================================= -->
<!-- ===================== DISTRIBUTION-RELATED TASKS ======================== -->
<!-- ========================================================================= -->
<!-- Creates the Solr distribution files. -->
<target name="dist"
description="Creates the Solr distribution files."
depends="init-forrest-entities, dist-solrj, dist-jar, dist-contrib, dist-war" />
<!-- Creates the Solr WAR file. -->
<target name="dist-war"
description="Creates the Solr WAR Distribution file."
depends="compile, make-manifest, dist-jar">
<mkdir dir="${dist}" />
<war destfile="${dist}/${fullnamever}.war"
webxml="${src}/webapp/web/WEB-INF/web.xml"
filesetmanifest="skip"
manifest="${dest}/META-INF/MANIFEST.MF">
<lib dir="${lib}">
<exclude name="servlet-api*.jar" />
<exclude name="easymock.jar" />
</lib>
<lib dir="${dist}">
<include name="${fullnamever}.jar" />
<include name="${fullname}-common-${version}.jar" />
</lib>
<lib dir="client/java/solrj/lib"/>
<fileset dir="${src}/webapp/web" />
<!-- Include anything put in by contrib projects -->
<fileset dir="${dest}/web" />
<metainf dir="${basedir}" includes="LICENSE.txt,NOTICE.txt"/>
</war>
</target>
<!-- Creates the solr jar. -->
<target name="dist-jar"
description="Creates the Solr JAR Distribution file."
depends="compile, make-manifest">
<mkdir dir="${dist}" />
<solr-jar
destfile="${dist}/${fullnamever}.jar"
basedir="${dest}/core" />
<!-- package the common classes together -->
<solr-jar
destfile="${dist}/${fullname}-common-${version}.jar"
basedir="${dest}/common" />
</target>
<!-- Creates the solr jar. -->
<target name="dist-solrj"
description="Creates the Solr JAR Distribution file."
depends="compile-solrj, dist-jar">
<mkdir dir="${dist}" />
<solr-jar
destfile="${dist}/${fullname}-solrj-${version}.jar"
basedir="${dest}/client/solrj" />
<mkdir dir="${dist}/solrj-lib" />
<copy todir="${dist}/solrj-lib">
<fileset dir="${lib}">
<include name="commons-codec-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="stax-*.jar"/>
</fileset>
<fileset dir="${solrj-dir}/lib">
<include name="*.jar" />
</fileset>
</copy>
</target>
<target name="example"
description="Creates a runnable example configuration."
depends="init-forrest-entities,dist-war">
<copy file="${dist}/${fullnamever}.war"
tofile="${example}/webapps/${ant.project.name}.war"/>
<jar destfile="${example}/exampledocs/post.jar"
basedir="${dest}/core"
filesetmanifest="skip"
includes="org/apache/solr/util/SimplePostTool*.class">
<manifest>
<attribute name="Main-Class"
value="org.apache.solr.util.SimplePostTool"/>
</manifest>
</jar>
<copy todir="${example}/solr/bin">
<fileset dir="${src}/scripts">
<exclude name="scripts.conf"/>
</fileset>
</copy>
<chmod dir="${example}/solr/bin" perm="755" includes="**"/>
<echo>See ${example}/README.txt for how to run the Solr example configuration.</echo>
</target>
<!-- make a distribution -->
<target name="package"
description="Packages the Solr Distribution files and Documentation."
depends="dist, example, javadoc-solrj, javadoc">
<copy todir="${build.docs}">
<fileset dir="site" />
</copy>
<tar destfile="${dist}/${fullnamever}.tgz" compression="gzip">
<tarfileset dir="."
prefix="${fullnamever}"
includes="LICENSE.txt NOTICE.txt *.txt *.xml lib/** src/** example/** client/**"
excludes="**/data/ **/logs/* **/classes/ **/*.sh **/bin/ src/scripts/ src/site/build/" />
<tarfileset dir="."
mode="755"
prefix="${fullnamever}"
includes="**/*.sh **/bin/ src/scripts/" />
<tarfileset dir="."
prefix="${fullnamever}"
includes="dist/**"
excludes="*.tgz *.zip *.md5" />
<tarfileset dir="${build.docs}"
prefix="${fullnamever}/docs/" />
</tar>
<solr-checksum file="${dist}/${fullnamever}.tgz"/>
<gunzip src="${dist}/${fullnamever}.tgz" dest="${dest}/${fullnamever}.tar"/>
<untar src="${dest}/${fullnamever}.tar" dest="${dest}"/>
<fixcrlf srcdir="${dest}/${fullnamever}"
eol="crlf"
includes="**/*.txt **/*.xml **/*.java **/*.html **/*.csv **/*.css **/*.properties **/*.jsp **/*.xsl **/*.py **/*.rb **/*.js **/*.json **/*.pl"
/>
<zip destfile="${dist}/${fullnamever}.zip">
<zipfileset dir="${dest}/${fullnamever}"
prefix="${fullnamever}"
excludes="**/*.sh **/bin/ src/scripts/" />
<zipfileset dir="${dest}/${fullnamever}"
prefix="${fullnamever}"
includes="**/*.sh **/bin/ src/scripts/"
filemode="755" />
</zip>
<solr-checksum file="${dist}/${fullnamever}.zip"/>
</target>
<target name="nightly"
depends="test, package">
<!-- no description, don't advertise -->
</target>
</project>