lucene ant build script : Big Project Ant Script « Ant « Java






lucene ant build script


<?xml version="1.0"?>

<!--
    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="core" default="default" basedir=".">

  <property name="junit.includes" value="**/Test*.java"/>

  <import file="common-build.xml"/>

  <property name="build.demo.template" value="src/demo/demo-build.template"/> 

  <property name="demo.name" value="lucene-demos-${version}"/>
  <property name="demo.war.name" value="luceneweb"/>

  <!-- Build classpath -->
  <path id="classpath">
    <pathelement location="${build.dir}/classes/java"/>
  </path>

  <path id="backwards.classpath">
    <pathelement location="${build.dir}/${backwards.branch}/classes/java"/>
  </path>

  <path id="demo.classpath">
    <path refid="classpath"/>
    <pathelement location="${build.dir}/classes/demo"/>
  </path>
  
  <path id="test.classpath">
    <path refid="classpath"/>
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/classes/test"/>
  </path>


  <path id="junit.classpath">
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/classes/test"/>
    <pathelement location="${build.dir}/classes/java"/>
    <pathelement path="${java.class.path}"/>
  </path>

  <patternset id="src.dist.patterns"
              includes="src/,build.xml,*build*.xml,docs/,*.txt,contrib/,*pom.xml*,lib/"
              excludes="contrib/db/*/lib/,contrib/*/ext-libs/,src/site/build/,contrib/benchmark/temp/**,contrib/benchmark/work/**"
  />
  <patternset id="binary.build.dist.patterns"
              includes="${final.name}.jar,${demo.war.name}.war,${demo.name}.jar,docs/,contrib/*/*.jar,contrib/*/*.war, contrib/*/*/*.jar"
  />
  <patternset id="binary.root.dist.patterns"
              includes="src/demo/,src/jsp/,docs/,*.txt,contrib/*/README*,**/CHANGES.txt,lib/servlet-api-*.jar"
              excludes="${build.demo.template}"
  />


  <!-- ----------------------------------------------------------------== -->
  <!-- Prepares the build directory                                       -->
  <!-- ----------------------------------------------------------------== -->

  <target name="test-core" depends="common.test"
          description="Runs unit tests for the core Lucene code"
  />
  <target name="test" depends="test-core, test-contrib, test-backwards"
          description="Runs all unit tests (core, contrib and back-compat)"
  />
  
  <path id="backwards.test.classpath">
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/${backwards.branch}/${backwards.branch}.jar"/>
  </path>
  
  <path id="backwards.junit.classpath">
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/${backwards.branch}/classes/test"/>
    <pathelement location="${build.dir}/${final.name}.jar"/>
    <pathelement path="${java.class.path}"/>
  </path>

  <available property="backwards.available" file="${backwards.dir}/${backwards.branch}/src"/>
  
  <target name="init-backwards-checkout" unless="backwards.available" description="Creates the sparse svn checkout for backwards branch.">
    <sequential>
      <echo>Initial SVN checkout for '${backwards.branch}'...</echo>
      <mkdir dir="${backwards.dir}"/>
      <exec dir="${backwards.dir}" executable="${svn.exe}" failifexecutionfails="false" failonerror="true">
        <arg line="checkout --trust-server-cert --non-interactive -r ${backwards.rev} --depth empty https://svn.apache.org/repos/asf/lucene/java/branches/${backwards.branch} ${backwards.branch}"/>
      </exec>
      <exec dir="${backwards.dir}" executable="${svn.exe}" failifexecutionfails="false" failonerror="true">
        <arg line="update --trust-server-cert --non-interactive -r ${backwards.rev} --set-depth infinity ${backwards.branch}/src"/>
      </exec>
    </sequential>
  </target>

  <target name="download-backwards" depends="init-backwards-checkout" description="Downloads a previous Lucene version.">
    <sequential>
      <echo>Update backwards branch '${backwards.branch}' to revision ${backwards.rev}...</echo>
      <exec dir="${backwards.dir}" executable="${svn.exe}" failifexecutionfails="false" failonerror="true">
        <arg line="update --trust-server-cert --non-interactive -r ${backwards.rev} ${backwards.branch}"/>
      </exec>
    </sequential>
  </target>
  
  <!-- remove this -->
  <target name="test-tag" depends="test-backwards" description="deprecated"/>

  <target name="test-backwards" depends="download-backwards, compile-core, jar-core"
    description="Runs tests of a previous Lucene version.">
  <sequential>
    <available property="backwards.tests.available" file="${backwards.dir}/${backwards.branch}/src/test" />

    <fail unless="backwards.tests.available">
      Backwards branch '${backwards.branch}' could not be found in directory '${backwards.dir}'.
    </fail>
    <mkdir dir="${build.dir}/${backwards.branch}"/>    

    <!-- first compile branch classes -->
    <compile
      srcdir="${backwards.dir}/${backwards.branch}/src/java"
      destdir="${build.dir}/${backwards.branch}/classes/java"
      javac.source="${javac.source.backwards}" javac.target="${javac.target.backwards}">
    <classpath refid="backwards.classpath"/>
    </compile>

    <!-- compile jar for branch -->
      <jarify basedir="${build.dir}/${backwards.branch}/classes/java"
        destfile="${build.dir}/${backwards.branch}/${backwards.branch}.jar" />
        
    <!-- compile branch tests against branch jar -->  
    <compile-test-macro srcdir="${backwards.dir}/${backwards.branch}/src/test" destdir="${build.dir}/${backwards.branch}/classes/test"
                test.classpath="backwards.test.classpath" javac.source="${javac.source.backwards}" javac.target="${javac.target.backwards}"/>
    
    <!-- run branch tests against trunk jar -->
      <test-macro dataDir="${backwards.dir}/${backwards.branch}/src/test" 
              tempDir="${build.dir}/${backwards.branch}"
              junit.classpath="backwards.junit.classpath"
              junit.output.dir="${junit.output.dir.backwards}" />
    </sequential>
  </target>  

  
  <!-- remove this soon -->
  <target name="clean-tags"
    description="deprecated: removes the old 'tag' subdir">
    <delete dir="${common.dir}/tags"/>
  </target>

  <target name="clean-backwards"
    description="Removes contents of the '${backwards.dir}' directory">
    <delete dir="${backwards.dir}"/>
  </target>
  
  <!-- ----------------------------------------------------------------== -->
  <!-- J A R                                                              -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->

  <target name="jar-demo" depends="compile-demo">
    <sequential>
      <build-manifest title="Lucene Search Engine: demos"/>
      <jar
        destfile="${build.dir}/${demo.name}.jar"
        basedir="${build.dir}/classes/demo"
        excludes="**/*.java"
        manifest="${manifest.file}">
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
      </jar>
    </sequential>
  </target>

  <target name="jar-demo-src" depends="compile-demo">
    <sequential>
      <build-manifest title="Lucene Search Engine: demos"/>
      <jar
        destfile="${build.dir}/${demo.name}-src.jar"
        basedir="src/demo"
        manifest="${manifest.file}">
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
      </jar>
    </sequential>
  </target>

  <target name="war-demo" depends="jar-core,jar-demo">
    <sequential>
      <build-manifest title="Lucene Search Engine: demos"/>
      <war destfile="${build.dir}/${demo.war.name}.war"
           webxml="src/jsp/WEB-INF/web.xml"
           manifest="${manifest.file}">
        <fileset dir="src/jsp" excludes="WEB-INF/web.xml"/>
        <lib dir="${build.dir}" includes="${demo.name}.jar"/>
        <lib dir="${build.dir}" includes="${final.name}.jar"/>
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
      </war>
    </sequential>
  </target>


  <!-- ----------------------------------------------------------------== -->
  <!-- B U I L D  D E M O                                                 -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="compile-demo" depends="compile-core">
    <mkdir dir="${build.dir}/classes/demo"/>

    <compile
      srcdir="src/demo"
      destdir="${build.dir}/classes/demo">
      <classpath refid="demo.classpath"/>
    </compile>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- D O C U M E N T A T I O N                                          -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="docs" description="Build the website">
      <echo>DEPRECATED - Doing Nothing.  See http://wiki.apache.org/lucene-java/HowToUpdateTheWebsite</echo>
  </target>

  <target name="javadocs" description="Generate javadoc" 
          depends="javadocs-all, javadocs-core, javadocs-demo, javadocs-contrib">
    <echo file="${javadoc.dir}/index.html" append="false">
<html><head><title>${Name} ${version} Javadoc Index</title></head>
<body>
<h1>${Name} ${version} Javadoc Index</h1>
<ul>
  <li><a href="all/index.html">All</a></li>
  <li><a href="core/index.html">Core</a></li>
  <li>Contrib packages:</li>
  <ul>
</echo>
    <contrib-crawl target="javadocs-index.html" failonerror="false"/>
    <echo file="${javadoc.dir}/index.html" append="true">
  </ul>
  <li><a href="demo/index.html">Demo</a></li>
</ul></body>

</echo>
  </target>
  
  <target name="javadocs-core" description="Generate javadoc for core classes">
    <sequential>
      <mkdir dir="${javadoc.dir}/core"/>
      <invoke-javadoc
        destdir="${javadoc.dir}/core"
        title="${Name} ${version} core API">
        <sources>
          <packageset dir="src/java"/>
          <link href=""/>
        </sources>
      </invoke-javadoc>
     <jarify basedir="${javadoc.dir}/core" destfile="${build.dir}/${final.name}-javadoc.jar"/>
    </sequential>
  </target>

  <target name="javadocs-demo" description="Generate javadoc for demo classes">
    <sequential>
      <mkdir dir="${javadoc.dir}/demo"/>
      <invoke-javadoc
        destdir="${javadoc.dir}/demo"
        title="${Name} ${version} demo API">
        <sources>
          <packageset dir="src/demo"/>
          <link href=""/>
        </sources>
      </invoke-javadoc>
      <jarify basedir="${javadoc.dir}/demo" destfile="${build.dir}/${demo.name}-javadoc.jar"/>
    </sequential>
  </target>
  
  <target name="javadocs-contrib" description="Generate javadoc for contrib classes">
    <contrib-crawl target="javadocs"
                   failonerror="false"/>
  </target>
    
  <target name="javadocs-all" description="Generate javadoc for core, demo and contrib classes" depends="build-contrib">
    <sequential>
      <mkdir dir="${javadoc.dir}/all"/>
      <invoke-javadoc
        destdir="${javadoc.dir}/all">
        <sources>
          <!-- TODO: find a dynamic way to do include multiple source roots -->
          <packageset dir="src/java"/>

          <packageset dir="src/demo"/>

          <!-- please keep this list up to date, and in alpha order...   -->
        
          <!-- ie: `find contrib/* -path \*src/java | sort` -->

          <!-- if you make changes to the list of package sets, also -->
          <!-- make sure the group list below is updated.            -->
          <!-- Also remember to keep site.xml in sync.            -->      

          <packageset dir="contrib/analyzers/common/src/java"/>
          <packageset dir="contrib/analyzers/smartcn/src/java"/>
          <packageset dir="contrib/ant/src/java"/>
          <packageset dir="contrib/benchmark/src/java"/>
          <packageset dir="contrib/icu/src/java"/>
          <packageset dir="contrib/db/bdb-je/src/java"/>
          <packageset dir="contrib/db/bdb/src/java"/>
          <packageset dir="contrib/fast-vector-highlighter/src/java"/>
          <packageset dir="contrib/highlighter/src/java"/>
          <packageset dir="contrib/instantiated/src/java"/>
          <packageset dir="contrib/lucli/src/java"/>
          <packageset dir="contrib/memory/src/java"/>
          <packageset dir="contrib/misc/src/java"/>
          <packageset dir="contrib/queries/src/java"/>
          <packageset dir="contrib/regex/src/java"/>
          <packageset dir="contrib/remote/src/java"/>
          <packageset dir="contrib/spatial/src/java"/>
          <packageset dir="contrib/spellchecker/src/java"/>
          <packageset dir="contrib/surround/src/java"/>
          <packageset dir="contrib/swing/src/java"/>
          <packageset dir="contrib/wikipedia/src/java"/>
          <packageset dir="contrib/wordnet/src/java"/>
          <packageset dir="contrib/xml-query-parser/src/java"/>
          <packageset dir="contrib/queryparser/src/java"/>
          <!-- end alpha sort -->

          <!-- If the main javadoc Group listing includes an "Other   -->
          <!-- Packages" group after the ones listed here, then those -->
          <!-- packages are not being matched by any of these rules   -->
  
          <group title="Core" packages="org.apache.*:org.apache.lucene.analysis:org.apache.lucene.analysis.standard*:org.apache.lucene.analysis.tokenattributes*"/>
  
          <group title="Demo" packages="org.apache.lucene.demo*"/>
  
          <group title="contrib: Analysis" packages="org.apache.lucene.analysis.*:org.tartarus.snowball*"/>
          <group title="contrib: Ant" packages="org.apache.lucene.ant*"/>
          <group title="contrib: Benchmark" packages="org.apache.lucene.benchmark*"/>
          <group title="contrib: ICU" packages="org.apache.lucene.collation*"/>
          <group title="contrib: DB" packages="org.apache.lucene.store.db*:org.apache.lucene.store.je*:com.sleepycat*"/>
          <group title="contrib: Fast Vector Highlighter" packages="org.apache.lucene.search.vectorhighlight*"/>
          <group title="contrib: Highlighter" packages="org.apache.lucene.search.highlight*"/>
          <group title="contrib: Instantiated" packages="org.apache.lucene.store.instantiated*"/>
          <group title="contrib: Lucli" packages="lucli*"/>
          <group title="contrib: Memory" packages="org.apache.lucene.index.memory*"/>
          <group title="contrib: Misc " packages="org.apache.lucene.misc*:org.apache.lucene.queryParser.analyzing*:org.apache.lucene.queryParser.precedence*"/>
          <group title="contrib: Queries" packages="org.apache.lucene.search.similar*"/>
          <group title="contrib: Query Parser" packages="org.apache.lucene.queryParser.*"/>
          <group title="contrib: RegEx" packages="org.apache.lucene.search.regex*:org.apache.regexp*"/>
          <group title="contrib: Spatial" packages="org.apache.lucene.spatial*"/>
          <group title="contrib: SpellChecker" packages="org.apache.lucene.search.spell*"/>
          <group title="contrib: Surround Parser" packages="org.apache.lucene.queryParser.surround*"/>
          <group title="contrib: Swing" packages="org.apache.lucene.swing*"/>
          <group title="contrib: Wikipedia" packages="org.apache.lucene.wikipedia*"/>
          <group title="contrib: WordNet" packages="org.apache.lucene.wordnet*"/>
          <group title="contrib: XML Query Parser" packages="org.apache.lucene.xmlparser*"/>
          
        </sources>
      </invoke-javadoc>
    </sequential>
  </target>


  <!-- ----------------------------------------------------------------== -->
  <!-- D I S T R I B U T I O N                                            -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package" depends="jar-core, javadocs, war-demo, build-contrib, init-dist, changes-to-html">
     <copy file="${build.demo.template}" tofile="${build.dir}/build-demo.xml">
        <filterset begintoken="@PLACEHOLDER_" endtoken="@"> 
    <filter token="version" value="${version}"/>
    <filter token="javac.source" value="${javac.source}"/>
    <filter token="javac.target" value="${javac.target}"/>
        </filterset>
     </copy>
  </target>

  <target name="nightly" depends="test, package-tgz">
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Packages the distribution with zip                                 -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package-zip" depends="package"
    description="--> Generates the Lucene distribution as .zip">

    <delete file="${dist.dir}/lucene-${version}.zip"/>
    <zip destfile="${dist.dir}/lucene-${version}.zip">
      <zipfileset prefix="lucene-${version}" dir=".">
        <patternset refid="binary.root.dist.patterns"/>
      </zipfileset>
      <zipfileset dir="${build.dir}" includes="build-demo.xml" fullpath="lucene-${version}/build.xml"/>
      <zipfileset prefix="lucene-${version}" dir="${build.dir}">
        <patternset refid="binary.build.dist.patterns"/>
      </zipfileset>
    </zip>
  <lucene-checksum file="${dist.dir}/lucene-${version}.zip"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- packages the distribution with tar-gzip                            -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package-tgz" depends="package"
    description="--> Generates the lucene distribution as .tar.gz">

    <delete file="${build.dir}/lucene-${version}.tar"/>
    <delete file="${dist.dir}/lucene-${version}.tar.gz"/>
    <tar tarfile="${build.dir}/lucene-${version}.tar" longfile="gnu">
      <tarfileset prefix="lucene-${version}" dir=".">
        <patternset refid="binary.root.dist.patterns"/>
      </tarfileset>
      <tarfileset dir="${build.dir}" includes="build-demo.xml" fullpath="lucene-${version}/build.xml"/>
      <tarfileset prefix="lucene-${version}" dir="${build.dir}">
        <patternset refid="binary.build.dist.patterns"/>
      </tarfileset>
    </tar>

    <gzip zipfile="${dist.dir}/lucene-${version}.tar.gz"
      src="${build.dir}/lucene-${version}.tar"
      />
  <lucene-checksum file="${dist.dir}/lucene-${version}.tar.gz"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- packages the distribution with zip and tar-gzip                    -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package-all-binary" depends="package-zip, package-tgz"
    description="--> Generates the .tar.gz and .zip distributions"/>

  <!-- ----------------------------------------------------------------== -->
  <!-- same as package-all. it is just here for compatibility.            -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="dist" depends="package-all-binary"/>

  <!-- ----------------------------------------------------------------== -->
  <!-- S O U R C E  D I S T R I B U T I O N                               -->
  <!-- ----------------------------------------------------------------== -->
    <target name="init-dist" >

        <!-- Package is not called first if packaging src standalone, so the dist.dir may not exist -->
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${maven.dist.dir}"/>
    </target>
  <!-- ----------------------------------------------------------------== -->
  <!-- Packages the sources with zip                                      -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package-zip-src" depends="init, init-dist"
    description="--> Generates the Lucene sources as .zip">
    <zip destfile="${dist.dir}/lucene-${version}-src.zip">
      <zipfileset prefix="lucene-${version}" dir=".">
        <patternset refid="src.dist.patterns"/>
      </zipfileset>
    </zip>
  <lucene-checksum file="${dist.dir}/lucene-${version}-src.zip"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Packages the sources with tar-gzip                                 -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package-tgz-src" depends="init, init-dist"
    description="--> Generates the Lucene distribution as .tar.gz">

    <delete file="${build.dir}/lucene-${version}-src.tar"/>
    <delete file="${dist.dir}/lucene-${version}-src.tar.gz"/>
    <tar tarfile="${build.dir}/lucene-${version}-src.tar" longfile="gnu">
      <tarfileset prefix="lucene-${version}" dir=".">
        <patternset refid="src.dist.patterns"/>
      </tarfileset>
    </tar>

    <gzip zipfile="${dist.dir}/lucene-${version}-src.tar.gz"
          src="${build.dir}/lucene-${version}-src.tar"
    />
  <lucene-checksum file="${dist.dir}/lucene-${version}-src.tar.gz"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Packages the sources with zip and tar-gzip                         -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="package-all-src" depends="package-zip-src, package-tgz-src"
    description="--> Generates the .tar.gz and .zip source distributions"/>

  <!-- ----------------------------------------------------------------== -->
  <!-- same as package-all-src. it is just here for compatibility.        -->
  <!-- ----------------------------------------------------------------== -->
  <!--                                                                    -->
  <!-- ----------------------------------------------------------------== -->
  <target name="dist-src" depends="package-all-src"/>

  <target name="dist-all" depends="dist, dist-src"/>

  <target name="generate-maven-artifacts" depends="maven.ant.tasks-check, package, jar-src, jar-demo-src, javadocs">
    <sequential>
      <m2-deploy pom.xml="lucene-parent-pom.xml.template"/>
      <m2-deploy pom.xml="lucene-core-pom.xml.template">
        <artifact-attachments>
          <attach file="${build.dir}/${final.name}-src.jar"
                  classifier="sources"/>
          <attach file="${build.dir}/${final.name}-javadoc.jar"
                  classifier="javadoc"/>
        </artifact-attachments>
      </m2-deploy>
      
      <m2-deploy pom.xml="lucene-demos-pom.xml.template">
        <artifact-attachments>
          <attach file="${build.dir}/${demo.name}-src.jar"
                  classifier="sources"/>
          <attach file="${build.dir}/${demo.name}-javadoc.jar"
                  classifier="javadoc"/>
        </artifact-attachments>
      </m2-deploy>
      
      <m2-deploy pom.xml="lucene-contrib-pom.xml.template"/>
      <contrib-crawl target="dist-maven"/>
    </sequential>
  </target>
  
  <!-- ----------------------------------------------------------------== -->
  <!-- Build the JavaCC files into the source tree                        -->
  <!-- ----------------------------------------------------------------== -->
  <target name="jjdoc">
    <mkdir dir="${build.dir}/docs/grammars"/>
    <jjdoc target="src/java/org/apache/lucene/queryParser/QueryParser.jj"
           outputfile="${build.dir}/docs/grammars/QueryParser.html"
           javacchome="${javacc.home}"
    />
    <jjdoc target="src/demo/org/apache/lucene/demo/html/HTMLParser.jj"
           outputfile="${build.dir}/docs/grammars/HTMLParser.html"
           javacchome="${javacc.home}"
    />
    <jjdoc target="contrib/surround/src/java/org/apache/lucene/queryParser/surround/parser/QueryParser.jj"
           outputfile="${build.dir}/docs/grammars/Surround_QueryParser.html"
           javacchome="${javacc.home}"
    />
    <jjdoc target="contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/parser/StandardSyntaxParser.jj"
           outputfile="${build.dir}/docs/grammars/StandardSyntaxParser.html"
           javacchome="${javacc.home}"
    />
  </target>

  <target name="clean-javacc">
    <delete>
      <fileset dir="src/java/org/apache/lucene/analysis/standard" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
        <exclude name="ParseException.java"/>
      </fileset>
      <fileset dir="src/java/org/apache/lucene/queryParser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
      <fileset dir="contrib/surround/src/java/org/apache/lucene/queryParser/surround/parser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
      <fileset dir="contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/parser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
      <fileset dir="src/demo/org/apache/lucene/demo/html" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
    </delete>
  </target>

  <target name="javacc" depends="clean-javacc,javacc-QueryParser,javacc-HTMLParser,javacc-contrib-queryparser, javacc-contrib-surround, javacc-contrib-precedence"/>

  <target name="javacc-QueryParser" depends="init,javacc-check" if="javacc.present">
    <sequential>
      <invoke-javacc target="src/java/org/apache/lucene/queryParser/QueryParser.jj"
                     outputDir="src/java/org/apache/lucene/queryParser"/>

      <!-- Change the inccorrect public ctors for QueryParser to be protected instead -->
      <replaceregexp file="src/java/org/apache/lucene/queryParser/QueryParser.java"
         byline="true"
         match="public QueryParser\(CharStream "
         replace="protected QueryParser(CharStream "/>
      <replaceregexp file="src/java/org/apache/lucene/queryParser/QueryParser.java"
         byline="true"
         match="public QueryParser\(QueryParserTokenManager "
         replace="protected QueryParser(QueryParserTokenManager "/>

    </sequential>
  </target>  
  
  <target name="javacc-HTMLParser" depends="init,javacc-check" if="javacc.present">
    <invoke-javacc target="src/demo/org/apache/lucene/demo/html/HTMLParser.jj"
                   outputDir="src/demo/org/apache/lucene/demo/html"
    />
  </target>
  
  <target name="javacc-contrib-queryparser" depends="init,javacc-check" if="javacc.present">
    <ant target="javacc"
      dir="contrib/queryparser"
      antfile="build.xml" 
    />
  </target>
  
  <target name="javacc-contrib-surround" depends="init,javacc-check" if="javacc.present">
    <ant target="javacc"
      dir="contrib/surround"
      antfile="build.xml" 
    />
  </target>
  
  <target name="javacc-contrib-precedence" depends="init,javacc-check" if="javacc.present">
    <ant target="javacc"
      dir="contrib/misc"
      antfile="build.xml" 
    />
  </target>
  
  <!-- ----------------------------------------------------------------== -->
  <!-- Build the JFlex files into the source tree                         -->
  <!-- ----------------------------------------------------------------== -->

  <target name="jflex" depends="clean-jflex,jflex-StandardAnalyzer" />

  <target name="jflex-StandardAnalyzer" depends="init,jflex-check" if="jflex.present">
    <taskdef classname="JFlex.anttask.JFlexTask" name="jflex">
      <classpath location="${jflex.home}/lib/JFlex.jar" />
    </taskdef>

    <jflex file="src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex"
           outdir="src/java/org/apache/lucene/analysis/standard"
           nobak="on" />
  </target>

  <target name="clean-jflex">
    <delete>
      <fileset dir="src/java/org/apache/lucene/analysis/standard" includes="*.java">
        <containsregexp expression="generated.*by.*JFlex"/>
      </fileset>
    </delete>
  </target>

  <macrodef name="contrib-crawl">
    <attribute name="target" default=""/>
    <attribute name="failonerror" default="true"/>
    <sequential>
      <subant target="@{target}" failonerror="@{failonerror}">
        <fileset dir="."
                 includes="contrib/*/build.xml"
        />
      </subant>
    </sequential>
  </macrodef>

  <target name="build-contrib"
          description="Builds all contrib modules and their tests">
    <contrib-crawl target="build-artifacts-and-tests"/>
  </target>

  <target name="test-contrib" depends="build-contrib">
    <!-- Don't fail on error, instead check for flag file so we run
         all the tests possible and can "ant generate-test-reports"
         for all of them.

         Because of this, we depend on "build-contrib" even though the
         Individual contrib "test" targets probably have the
         neccessary dependencies.  If they fail to compile, we won't
         know about it.
     -->
    <contrib-crawl target="test" failonerror="false"/>
    <available property="contribs.failed" file="junitfailed.flag">
      <filepath>
        <dirset dir="${build.dir}/contrib/">
          <include name="**/test/" />
        </dirset>
      </filepath>
    </available>
    <fail if="contribs.failed">Contrib tests failed!</fail>
  </target>

  <!-- Macro for building checksum files -->
  <macrodef name="lucene-checksum">
    <attribute name="file"/>
    <sequential>
      <checksum file="@{file}" algorithm="md5" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
      <checksum file="@{file}" algorithm="sha1" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
    </sequential>
  </macrodef>

  <!--
   compile changes.txt into an html file
   -->

  <target name="changes-to-html">
    <mkdir dir="${changes.target.dir}"/>
    <exec executable="perl" input="CHANGES.txt" output="${changes.target.dir}/Changes.html" failonerror="true">
      <arg value="${changes.src.dir}/changes2html.pl"/>
    </exec>
    <exec executable="perl" input="contrib/CHANGES.txt" output="${changes.target.dir}/Contrib-Changes.html" failonerror="true">
      <arg value="${changes.src.dir}/changes2html.pl"/>
    </exec>
    <copy todir="${changes.target.dir}">
      <fileset dir="${changes.src.dir}" includes="*.css"/>
    </copy>
  </target>

  <!--
   Committer helpers
   -->

  <property name="patch.file" value="${basedir}/../patches/${patch.name}"/>
  <!-- Apply a patch.  Assumes  patch can be applied in the basedir.
  -Dpatch.name assumes the patch is located in ${basedir}/../patches/${patch.name}
  -Dpatch.file means the patch can be located anywhere on the file system
  -->
  <target name="apply-patch" depends="clean" description="Apply a patch file.  Set -Dpatch.file, or -Dpatch.name when the patch is in the directory ../patches/">
    <patch patchfile="${patch.file}" strip="0"/>
  </target>

  <target name="rat-sources-typedef">
    <typedef resource="org/apache/rat/anttasks/antlib.xml" uri="antlib:rat.anttasks">
      <classpath>
        <fileset dir="." includes="rat*.jar"/>
      </classpath>
    </typedef>
  </target>

  <target name="rat-sources" depends="rat-sources-typedef"
    description="runs the tasks over src/java">
    <rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
      <fileset dir="src/java">
      </fileset>
    </rat:report>
  </target>

</project>


File: common-build.xml

<?xml version="1.0"?>

<!--
    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="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
  <description>
    This file is designed for importing into a main build file, and not intended
    for standalone use.
  </description>

  <dirname file="${ant.file.common}" property="common.dir"/>

  <!-- Give user a chance to override without editing this file
      (and without typing -D each time it compiles it -->
  <property file="${user.home}/lucene.build.properties"/>
  <property file="${user.home}/build.properties"/>
  <property file="${basedir}/build.properties"/>
  <property file="${common.dir}/build.properties"/>

  <tstamp>
    <format property="current.year" pattern="yyyy"/>
    <format property="DSTAMP" pattern="yyyy-MM-dd"/>
    <format property="TSTAMP" pattern="HH:mm:ss"/>
  </tstamp>

  <property name="name" value="${ant.project.name}"/>
  <property name="Name" value="Lucene"/>
  <property name="dev.version" value="3.1-dev"/>
  <property name="version" value="${dev.version}"/>
  <property name="backwards.branch" value="lucene_3_0_back_compat_tests"/>
  <property name="backwards.rev" value="901812"/>
  <property name="spec.version" value="${version}"/>  
  <property name="year" value="2000-${current.year}"/>
  <property name="final.name" value="lucene-${name}-${version}"/>

  <property name="junit.jar" value="junit-4.7.jar"/>
  <property name="junit-location.jar" value="${common.dir}/lib/${junit.jar}"/>
  <path id="junit-path">
    <pathelement location="${junit-location.jar}"/>
  </path>

  <!-- default arguments to pass to JVM executing tests -->
  <property name="args" value=""/>

  <property name="javac.deprecation" value="off"/>
  <property name="javac.debug" value="on"/>
  <property name="javac.source" value="1.5"/>
  <property name="javac.target" value="1.5"/>
  <property name="javac.source.backwards" value="1.5"/>
  <property name="javac.target.backwards" value="1.5"/>

  <property name="javadoc.link" value="http://java.sun.com/j2se/1.5/docs/api/"/>
  <property name="javadoc.access" value="protected"/>
  <property name="javadoc.charset" value="utf-8"/>
  <property name="javadoc.dir" value="${common.dir}/build/docs/api"/>
  <property name="javadoc.maxmemory" value="512m" />
  <!-- Javadoc classpath -->
  <path id="javadoc.classpath">
    <path refid="classpath"/>
    <pathelement location="${ant.home}/lib/ant.jar"/>
    <fileset dir=".">
      <include name="**/lib/*.jar"/>
    </fileset>
  </path>
  
  <property name="changes.src.dir" value="${common.dir}/src/site/changes"/>
  <property name="changes.target.dir" value="${common.dir}/build/docs/changes"/>

  <property name="project.name" value="site"/> <!-- todo: is this used by anakia or something else? -->
  <property name="build.encoding" value="utf-8"/>

  <property name="src.dir" location="src/java"/>
  <property name="build.dir" location="build"/>
  <property name="backwards.dir" location="backwards"/>
  <property name="dist.dir" location="dist"/>
  <property name="maven.dist.dir" location="dist/maven"/>
  <property name="m2.repository.url" value="file://${maven.dist.dir}"/>
  <property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>

  <property name="javacc.home" location="${common.dir}"/>
  <property name="jflex.home" location="${common.dir}"/>

  <property name="junit.output.dir" location="${build.dir}/test"/>
  <property name="junit.output.dir.backwards" location="${build.dir}/bw-test"/>
  <property name="junit.reports" location="${build.dir}/test/reports"/>
  <property name="junit.reports.backwards" location="${build.dir}/bw-test/reports"/>
  <property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
  <property name="junit.excludes" value=""/>

  <property name="manifest.file" location="${common.dir}/build/MANIFEST.MF"/>

  <!-- 
    we attempt to exec svnversion to get details build information
    for jar manifests.  this property can be set at runtime to an
    explicit path as needed, or ant will just try to find it in the
    default PATH. (this is useful for Hudson)
  -->
  <property name="svnversion.exe" value="svnversion" />
  <property name="svn.exe" value="svn" />
  
  <condition property="build-1-5-contrib">
     <equals arg1="1.5" arg2="${ant.java.version}" />
  </condition>
  
  <property name="clover.db.dir" location="${common.dir}/build/test/clover/db"/>
  <property name="clover.report.dir" location="${common.dir}/build/test/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>

  <available
    property="javacc.present"
    classname="org.javacc.parser.Main"
    classpath="${javacc.home}/bin/lib/javacc.jar"
    />

   <available
    property="jflex.present"
    classname="JFlex.anttask.JFlexTask"
    classpath="${jflex.home}/lib/JFlex.jar"
    />

  <available
    property="maven.ant.tasks.present"
    classname="org.apache.maven.artifact.ant.Pom"
  />
  
  <target name="clean"
    description="Removes contents of build and dist directories">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.dir}"/>
    <delete file="velocity.log"/>
  </target>

  <!-- TODO: maybe make JavaCC checking specific to only the projects
             that use it (Lucene core and contrib/misc
  -->
  <target name="javacc-uptodate-check">
    <uptodate property="javacc.files.uptodate">
      <srcfiles dir="src" includes="**/*.jj" />
      <mapper type="glob" from="*.jj" to="*.java"/>
    </uptodate>
  </target>

  <target name="javacc-notice" unless="javacc.files.uptodate">
    <echo>
      One or more of the JavaCC .jj files is newer than its corresponding
      .java file.  Run the "javacc" target to regenerate the artifacts.
    </echo>
  </target>

  <target name="init" depends="javacc-uptodate-check, javacc-notice, jflex-uptodate-check, jflex-notice">
  </target>

  <target name="jflex-uptodate-check">
    <uptodate property="jflex.files.uptodate">
      <srcfiles dir="src" includes="**/*.jflex" />
      <mapper type="glob" from="*.jflex" to="*.java"/>
    </uptodate>
  </target>
 
  <target name="jflex-notice" unless="jflex.files.uptodate">
    <echo>
      One or more of the JFlex .jflex files is newer than its corresponding
      .java file.  Run the "jflex" target to regenerate the artifacts.
    </echo>
  </target>

  <target name="javacc-check">
    <fail unless="javacc.present">
      ##################################################################
      JavaCC not found.
      JavaCC Home: ${javacc.home}
      JavaCC JAR: ${javacc.jar}

      Please download and install JavaCC from:

      &lt;http://javacc.dev.java.net&gt;

      Then, create a build.properties file either in your home
      directory, or within the Lucene directory and set the javacc.home
      property to the path where JavaCC is installed. For example,
      if you installed JavaCC in /usr/local/java/javacc-4.1, then set the
      javacc.home property to:

      javacc.home=/usr/local/java/javacc-4.1

      If you get an error like the one below, then you have not installed
      things correctly. Please check all your paths and try again.

      java.lang.NoClassDefFoundError: org.javacc.parser.Main
      ##################################################################
    </fail>

  </target>
  
  <target name="jflex-check">
    <fail unless="jflex.present">
      ##################################################################
      JFlex not found.
      JFlex Home: ${jflex.home}

      Please download and install JFlex from:

      &lt;http://jflex.de/download.html&gt;

      Then, create a build.properties file either in your home
      directory, or within the Lucene directory and set the jflex.home
      property to the path where JFlex is installed. For example,
      if you installed JFlex in /usr/local/java/jflex-1.4.1, then set the
      jflex.home property to:

      jflex.home=/usr/local/java/jflex-1.4.1

      ##################################################################
    </fail>
  </target>

  <target name="compile-core" depends="init, clover"
          description="Compiles core classes">
    <compile
      srcdir="src/java"
      destdir="${build.dir}/classes/java">
      <classpath refid="classpath"/>
    </compile>

    <!-- Copy the resources folder (if existent) -->
    <copy todir="${build.dir}/classes/java" includeEmptyDirs="false">
      <globmapper from="resources/*" to="*" handledirsep="yes"/>
      <fileset dir="src" includes="resources/**"/>
    </copy>
  </target>

  <target name="compile" depends="compile-core">
    <!-- convenience target to compile core -->
  </target>

  <target name="jar-core" depends="compile-core"
    description="Packages the JAR file">
    <jarify/>
  </target>

  <target name="maven.ant.tasks-check">
  <fail unless="maven.ant.tasks.present">
    ##################################################################
      Maven ant tasks not found.
      Please make sure the maven-ant-tasks jar is in ANT_HOME/lib, or made 
      available to Ant using other mechanisms like -lib or CLASSPATH.
      ##################################################################
    </fail>
  </target>

  <property name="pom.xml" value="pom.xml.template"/>

  <macrodef name="m2-deploy" description="Builds a Maven artifact">
    <element name="artifact-attachments" optional="yes"/>
    <attribute name="pom.xml" default="${pom.xml}"/>
    <sequential>
      <copy file="@{pom.xml}" tofile="${build.dir}/@{pom.xml}">
        <filterset begintoken="@" endtoken="@"> 
          <filter token="version" value="${version}"/>
        </filterset>
      </copy>
    <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-2"/>
      
      <artifact:pom id="maven.project" file="${build.dir}/@{pom.xml}" />
      <artifact:deploy file="${build.dir}/${maven.project.build.finalName}.jar">
        <artifact-attachments/>
        <remoteRepository url="${m2.repository.url}">
          <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}"/>
    </remoteRepository>
        <pom refid="maven.project"/>
      </artifact:deploy>
    </sequential>
  </macrodef>    
  
  
  
  <macrodef name="build-manifest" description="Builds a manifest file">
    <attribute name="title" default="Lucene Search Engine: ${ant.project.name}" />
    <sequential>
      <manifest file="${manifest.file}">
        <attribute name="Specification-Title" value="@{title}"/>
    <!-- spec version must match "digit+{.digit+}*" -->
    <attribute name="Specification-Version" value="${spec.version}"/>
    <attribute name="Specification-Vendor"
               value="The Apache Software Foundation"/>
    <attribute name="Implementation-Title" value="org.apache.lucene"/>
    <!-- impl version can be any string -->
    <attribute name="Implementation-Version"
               value="${version} ${svnversion} - ${DSTAMP} ${TSTAMP}"/>
    <attribute name="Implementation-Vendor"
               value="The Apache Software Foundation"/>
    <attribute name="X-Compile-Source-JDK" 
               value="${javac.source}"/>
    <attribute name="X-Compile-Target-JDK" 
               value="${javac.target}"/>
    </manifest>
    </sequential>
  </macrodef>
  
  <macrodef name="jarify" description="Builds a JAR file">
    <attribute name="basedir" default="${build.dir}/classes/java"/>
    <attribute name="destfile" default="${build.dir}/${final.name}.jar"/>
    <element name="manifest-attributes" optional="yes"/>
    <element name="metainf-includes" optional="yes"/>
    <sequential>
      <!-- If possible, include the svnversion -->
      <exec dir="." executable="${svnversion.exe}"
            outputproperty="svnversion" failifexecutionfails="false">
        <arg line="."/>
      </exec>
      
      <build-manifest/>
      
      <jar
        destfile="@{destfile}"
        basedir="@{basedir}"
        manifest="${manifest.file}">
        <manifest>
          <manifest-attributes/>
        </manifest>
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
        <metainf-includes/>
      </jar>
    </sequential>
  </macrodef>

  <target name="compile-test" depends="compile-core">
    <compile-test-macro srcdir="src/test" destdir="${build.dir}/classes/test"
              test.classpath="test.classpath"/>
  </target>

  <property name="tests.verbose" value="false"/>
  
  <macrodef name="compile-test-macro" description="Compiles junit tests.">
    <attribute name="srcdir"/>
    <attribute name="destdir"/>
    <attribute name="test.classpath"/>
    <attribute name="javac.source" default="${javac.source}"/>
    <attribute name="javac.target" default="${javac.target}"/>
     <sequential>
      <compile
        srcdir="@{srcdir}" 
        destdir="@{destdir}"
        javac.source="@{javac.source}"
        javac.target="@{javac.source}">
        <classpath refid="@{test.classpath}"/>
      </compile>

      <!-- Copy any data files present to the classpath -->
      <copy todir="@{destdir}">
        <fileset dir="@{srcdir}" excludes="**/*.java"/>
      </copy>
    </sequential>
  </macrodef>
  
  <macrodef name="test-macro" description="Executes junit tests.">
    <attribute name="junit.output.dir" default="${junit.output.dir}"/>
    <attribute name="junit.classpath" default="junit.classpath"/>
    <attribute name="dataDir"/>
    <attribute name="tempDir"/>
    <element name="contrib-settings" optional="yes"/>

    <sequential>
      <condition property="runall">
        <not><or>
          <isset property="testcase" />
          <isset property="testpackage" />
          <isset property="testpackageroot" />
        </or></not>
      </condition>
      <mkdir dir="@{junit.output.dir}"/>
      <junit printsummary="off" haltonfailure="no" maxmemory="512M"
        errorProperty="tests.failed" failureProperty="tests.failed">
        <classpath refid="@{junit.classpath}"/>
        <assertions>
          <enable package="org.apache.lucene"/>
        </assertions>
        
        <jvmarg line="${args}"/>
  
        <!-- allow tests to control debug prints -->
        <sysproperty key="tests.verbose" value="${tests.verbose}"/>
  
        <!-- TODO: create propertyset for test properties, so each project can have its own set -->
        <sysproperty key="dataDir" file="@{dataDir}"/>
        <sysproperty key="tempDir" file="@{tempDir}"/>
        <sysproperty key="java.io.tmpdir" file="@{tempDir}"/>
        <sysproperty key="lucene.version" value="${dev.version}"/>
  
      <contrib-settings />
        
        <formatter type="xml"/>
        <formatter type="brief" usefile="false"/>
        <batchtest fork="yes" todir="@{junit.output.dir}" if="runall">
          <fileset dir="@{dataDir}" includes="${junit.includes}" excludes="${junit.excludes}"/>
        </batchtest>
        <batchtest fork="yes" todir="@{junit.output.dir}" if="testpackage">
          <fileset dir="@{dataDir}" includes="**/${testpackage}/**/Test*.java,**/${testpackage}/**/*Test.java" excludes="${junit.excludes}"/>
        </batchtest>
        <batchtest fork="yes" todir="@{junit.output.dir}" if="testpackageroot">
          <fileset dir="@{dataDir}" includes="**/${testpackageroot}/Test*.java,**/${testpackageroot}/*Test.java" excludes="${junit.excludes}"/>
        </batchtest>
        <batchtest fork="yes" todir="@{junit.output.dir}" if="testcase">
          <fileset dir="@{dataDir}" includes="**/${testcase}.java"/>
        </batchtest>
      </junit>
      <!-- create this file, then if we don't fail, delete it -->
      <!-- this meme makes it easy to tell if contribs have failed later -->
      <echo file="@{junit.output.dir}/junitfailed.flag">MAYBE</echo>
      <fail if="tests.failed">Tests failed!</fail>
      <!-- life would be easier if echo had an 'if' attribute like fail -->
      <delete file="@{junit.output.dir}/junitfailed.flag" />
    </sequential>
  </macrodef>
  
  <target name="test" depends="compile-test" description="Runs unit tests">
    <test-macro dataDir="src/test" tempDir="${build.dir}/test">
      <contrib-settings>
        <!-- set as a system property so contrib tests can have a fixed root
             to reference file paths from, and "ant test" can work from
             anywhere.
         -->
        <sysproperty key="lucene.common.dir" file="${common.dir}" />
        
        <!-- contrib/ant IndexTaskTest needs these two system properties -->
        <sysproperty key="docs.dir" file="src/test"/>
        <sysproperty key="index.dir" file="${build.dir}/test/index"/>
  
        <!-- contrib/benchmark uses this system property to locate docs data and defined tasks -->
        <sysproperty key="tasks.dir" file="${build.dir}/classes/java/org/apache/lucene/benchmark/byTask/tasks"/>
        <sysproperty key="benchmark.work.dir" file="${common.dir}/contrib/benchmark/work"/>
    </contrib-settings>
    </test-macro>
  </target>

    <!--
     If you want clover test code coverage, run this before the tests.  You need clover.jar and the license in your ANT classspath and you need to specify -Drun.clover=true on the command line.

     See http://issues.apache.org/jira/browse/LUCENE-721
     -->
  <target name="clover" depends="clover.setup, clover.info" description="Instrument the Unit tests using Clover.  Requires a Clover 2.x 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="cloverlib.xml"/>
    <mkdir dir="${clover.db.dir}"/>
    <clover-setup initString="${clover.db.dir}/lucene_coverage.db" encoding="${build.encoding}">
      <fileset dir="src/java">
        <include name="org/apache/**/*.java" />
      </fileset>
      <testsources dir="src/test">
        <include name="org/apache/**/*.java" />
      </testsources>
    </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}"/>
    <!-- This extra path is needed, because from a top-level ant run, the contrib tests would be not visible (report generation is only done on top-level not via subants) -->
    <fileset dir="contrib" id="clover.contrib.test.src.files">
      <include name="**/test/**/*.java"/>
    </fileset>
    <fileset dir="src/test" id="clover.test.src.files">
      <include name="**/*.java" />
    </fileset>
    <fileset dir="${build.dir}" id="clover.test.result.files">
      <include name="**/test/TEST-*.xml" />
      <!-- do not include BW tests -->
    </fileset>
    <clover-report>
       <current outfile="${clover.report.dir}" title="${final.name}" numThreads="0">
          <format type="html" filter="assert"/>
          <testsources refid="clover.test.src.files"/>
          <testsources refid="clover.contrib.test.src.files"/>
          <testresults refid="clover.test.result.files"/>
       </current>
       <current outfile="${clover.report.dir}/clover.xml" title="${final.name}">
          <format type="xml" filter="assert"/>
          <testsources refid="clover.test.src.files"/>
          <testsources refid="clover.contrib.test.src.files"/>
          <testresults refid="clover.test.result.files"/>
       </current>
    </clover-report>
  </target>

  <target name="generate-test-reports" description="Generates test reports">
    <mkdir dir="${junit.reports}"/>
    <junitreport todir="${junit.output.dir}">
      <!-- this fileset let's the task work for individual contribs,
           as well as the project as a whole
       -->
      <fileset dir="${build.dir}">
        <include name="**/test/TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${junit.reports}"/>
    </junitreport>
    
    <mkdir dir="${junit.reports.backwards}"/>
    <junitreport todir="${junit.output.dir.backwards}">
      <!-- this fileset let's the task work for individual contribs,
           as well as the project as a whole
       -->
      <fileset dir="${build.dir}">
        <include name="**/bw-test/TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${junit.reports.backwards}"/>
    </junitreport>
  </target>

  <target name="jar" depends="jar-core">
    <!-- convenience target to package core JAR -->
  </target>

  <target name="jar-src" depends="init">
    <jarify basedir="${src.dir}" destfile="${build.dir}/${final.name}-src.jar"/>
  </target>

  <target name="default" depends="jar-core"/>

  <!--+
      | M A C R O S
      +-->
  <macrodef name="compile">
    <attribute name="srcdir"/>
    <attribute name="destdir"/>
    <attribute name="javac.source" default="${javac.source}"/>
    <attribute name="javac.target" default="${javac.target}"/>
    <element name="nested" implicit="yes" optional="yes"/>

    <sequential>
      <mkdir dir="@{destdir}"/>
      <javac
        encoding="${build.encoding}"
        srcdir="@{srcdir}"
        destdir="@{destdir}"
        deprecation="${javac.deprecation}"
        debug="${javac.debug}"
        source="@{javac.source}"
        target="@{javac.target}">
        <nested/>
        <compilerarg line="-Xmaxwarns 10000000"/>
        <compilerarg line="-Xmaxerrs 10000000"/>
        <!-- for generics in Java 1.5: -->
        <!--<compilerarg line="-Xlint:unchecked"/>-->
      </javac>
    </sequential>
  </macrodef>

  <macrodef name="invoke-javacc">
    <attribute name="target"/>
    <attribute name="outputDir"/>
    <sequential>
      <mkdir dir="@{outputDir}"/>
      <javacc
          target="@{target}"
          outputDirectory="@{outputDir}"
          debugTokenManager="${javacc.debug.tokenmgr}"
          debugParser="${javacc.debug.parser}"
          debuglookahead="${javacc.debug.lookahead}"
          javacchome="${javacc.home}"
          jdkversion="${javac.source}"
      />
      <fixcrlf srcdir="@{outputDir}" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fixcrlf>
    </sequential>
  </macrodef>
  
  <macrodef name="invoke-javadoc">
    <element name="sources" optional="yes"/>
    <attribute name="destdir"/>
    <attribute name="title" default="${Name} ${version} API"/>
    <sequential>
      <javadoc
          overview="src/java/overview.html"
          packagenames="org.apache.lucene.*"
          destdir="@{destdir}"
          access="${javadoc.access}"
          encoding="${build.encoding}"
          charset="${javadoc.charset}"
          docencoding="${javadoc.charset}"
          author="true"
          version="true"
          use="true"
          source="${ant.java.version}"
          link="${javadoc.link}"
          windowtitle="${Name} ${version} API"
          doctitle="@{title}"
          maxmemory="${javadoc.maxmemory}"
          bottom="Copyright &amp;copy; ${year} Apache Software Foundation.  All Rights Reserved.">
        <tag name="todo" description="To Do:"/>
        <tag name="uml.property" description="UML Property:"/>
        <link offline="true" packagelistLoc="${javadoc.dir}"/>
        
        <sources />
                
        <classpath refid="javadoc.classpath"/>
      </javadoc>
   </sequential>
  </macrodef>


</project>

 








Related examples in the same category

1.Ant script for xmlgraphics-commons
2.nutch ant script
3.rhino ant build script
4.apache solr ant script
5.Tomcat ant build script
6.OFBiz ant build script
7.Apache Lenya Build System
8.Apache pivot ant build script
9.XmlSchema ant script
10.xml security
11.velocity tools ant script
12.weka build script
13.xml bean ant script
14.xml graphics common ant script
15.uPortal ant script
16.SmartGWT ant script
17.Build file to fetch maven2 tasks; extracted from (Ant's) fetch.xml
18.Build file to fetch optional libraries for Apache Ant
19.Ant build script
20.Build script for apache-cassandra-0.5.1-src
21.apache-log4j-site\build.xml
22.apache-roller-src-4.0.1
23.Build script from apache dbutils
24.Fop build script
25.Google guice ant script
26.GWT ant script
27.hadoop ant build script
28.jakarta jmeter ant script
29.jakarta oro ant script
30.jakarta regexp ant script
31.jedit build script
32.jibx ant build script