--- /dev/null
+<?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"/>
+ <property name="dev-tools.dir" value="${common.dir}/../dev-tools"/>
+ <property name="prettify.dir" value="${common.dir}/src/tools/prettify"/>
+ <property name="maven.build.dir" value="${build.dir}/maven"/>
+
+ <!-- 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"/>
+ <!-- datetime format that is safe to treat as part of a dotted version -->
+ <format property="dateversion" pattern="yyyy.MM.dd.HH.mm.ss" />
+ </tstamp>
+
+ <property name="name" value="${ant.project.name}"/>
+ <property name="Name" value="Lucene"/>
+ <property name="dev.version" value="3.5-SNAPSHOT"/>
+ <property name="tests.luceneMatchVersion" value="3.5"/>
+ <property name="version" value="${dev.version}"/>
+ <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>
+
+ <path id="ant-path">
+ <fileset dir="${common.dir}/lib" includes="ant-*.jar"/>
+ </path>
+
+ <path id="tools.runtime.classpath">
+ <pathelement location="${common.dir}/build/classes/tools"/>
+ </path>
+
+ <path id="maven-ant-tasks.classpath">
+ <fileset dir="${common.dir}/lib">
+ <include name="maven-ant-tasks-*.jar"/>
+ </fileset>
+ </path>
+
+ <!-- default arguments to pass to JVM executing tests -->
+ <property name="testmethod" value=""/>
+ <property name="args" value=""/>
+ <property name="tests.threadspercpu" value="1" />
+ <condition property="tests.sequential">
+ <or>
+ <isset property="testcase"/>
+ <equals arg1="${tests.threadspercpu}" arg2="0"/>
+ </or>
+ </condition>
+ <property name="tests.multiplier" value="1" />
+ <property name="tests.locale" value="random" />
+ <property name="tests.timezone" value="random" />
+ <property name="tests.directory" value="random" />
+ <property name="tests.linedocsfile" value="europarl.lines.txt.gz" />
+ <property name="tests.iter" value="1" />
+ <property name="tests.iter.min" value="${tests.iter}" />
+ <property name="tests.seed" value="random" />
+ <property name="tests.loggingfile" value="/dev/null"/>
+ <property name="tests.nightly" value="false" />
+ <property name="tests.cleanthreads.sysprop" value="perMethod"/>
+ <property name="tests.asserts.gracious" value="false"/>
+
+ <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"/>
+ <!-- clover wants to run with -lib, otherwise we prefer a repeatable
+ classpath -->
+ <property name="javac.includeAntRuntime" value="${run.clover}"/>
+
+ <property name="javadoc.link" value="http://download.oracle.com/javase/1.5.0/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=".">
+ <exclude name="build/**/*.jar"/>
+ <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="tests.src.dir" location="src/test"/>
+ <property name="tests-framework.src.dir" location="${common.dir}/src/test-framework/java"/>
+ <property name="build.dir" location="build"/>
+ <!-- Needed in case a contrib needs the original build, also for compile-tools to be called from contrib -->
+ <property name="common.build.dir" location="${common.dir}/build"/>
+ <property name="tests.lockdir" location="${common.build.dir}"/>
+ <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}"/>
+
+ <path id="jflex.classpath">
+ <fileset dir="${jflex.home}/">
+ <!-- for a JFlex trunk checkout: -->
+ <include name="jflex/target/*.jar"/>
+ <!-- for a JFlex distribution (not yet available): -->
+ <include name="lib/*.jar"/>
+ </fileset>
+ </path>
+
+ <path id="javacc.classpath">
+ <fileset dir="${javacc.home}/">
+ <include name="bin/lib/*.jar"/>
+ </fileset>
+ </path>
+
+ <property name="backwards.dir" location="backwards"/>
+ <property name="build.dir.backwards" location="${build.dir}/backwards"/>
+
+ <property name="junit.output.dir" location="${build.dir}/test"/>
+ <property name="junit.output.dir.backwards" location="${build.dir.backwards}/test"/>
+ <property name="junit.reports" location="${build.dir}/test/reports"/>
+ <property name="junit.reports.backwards" location="${build.dir.backwards}/test/reports"/>
+ <property name="junit.excludes" value=""/>
+ <condition property="junit.details.formatter"
+ value="org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"
+ else="org.apache.lucene.util.LuceneJUnitResultFormatter">
+ <isset property="tests.sequential"/>
+ </condition>
+ <property name="junit.parallel.selector" value="org.apache.lucene.util.LuceneJUnitDividingSelector"/>
+
+ <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" />
+
+ <property name="gpg.exe" value="gpg" />
+ <property name="gpg.key" value="CODE SIGNING KEY" />
+
+ <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>
+
+ <propertyset id="uptodate.and.compiled.properties" dynamic="true">
+ <propertyref regex=".*\.uptodate$$"/>
+ <propertyref regex=".*\.compiled$$"/>
+ </propertyset>
+
+ <patternset id="lucene.local.src.package.patterns"
+ includes="src/,index.html,*build*.xml,docs/,*.txt,contrib/,lib/,backwards/"
+ excludes="**/pom.xml,**/*.iml,src/site/build/"
+ />
+
+ <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.dir}" includes="**/*.jj" />
+ <mapper type="glob" from="*.jj" to="*.java"/>
+ </uptodate>
+ </target>
+
+ <target name="javacc-notice" depends="javacc-uptodate-check" 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">
+ <!-- currently empty -->
+ </target>
+
+ <target name="jflex-uptodate-check">
+ <uptodate property="jflex.files.uptodate">
+ <srcfiles dir="${src.dir}" includes="**/*.jflex" />
+ <mapper type="glob" from="*.jflex" to="*.java"/>
+ </uptodate>
+ </target>
+
+ <target name="jflex-notice" depends="jflex-uptodate-check" 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">
+ <available property="javacc.present" classname="org.javacc.parser.Main">
+ <classpath refid="javacc.classpath"/>
+ </available>
+ <fail unless="javacc.present">
+ ##################################################################
+ JavaCC not found.
+ JavaCC Home: ${javacc.home}
+
+ Please download and install JavaCC 4.1 from:
+
+ <http://javacc.dev.java.net>
+
+ 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">
+ <available property="jflex.present" classname="jflex.anttask.JFlexTask">
+ <classpath refid="jflex.classpath"/>
+ </available>
+ <fail unless="jflex.present">
+ ##################################################################
+ JFlex not found.
+ JFlex Home: ${jflex.home}
+
+ Please install the jFlex 1.5 version (currently not released)
+ from its SVN repository:
+
+ svn co http://jflex.svn.sourceforge.net/svnroot/jflex/trunk jflex
+ cd jflex
+ mvn install
+
+ 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 the JFlex trunk checkout is located
+ (in the above example its the directory called "jflex").
+
+ ##################################################################
+ </fail>
+ </target>
+
+ <target name="compile-core" depends="init, clover"
+ description="Compiles core classes">
+ <compile
+ srcdir="${src.dir}"
+ destdir="${build.dir}/classes/java">
+ <classpath refid="classpath"/>
+ </compile>
+
+ <!-- Copy the resources folder (if existent) -->
+ <copy todir="${build.dir}/classes/java">
+ <fileset dir="${src.dir}/../resources" erroronmissingdir="no"/>
+ </copy>
+ </target>
+
+ <target name="compile" depends="compile-core, validate-lucene">
+ <!-- convenience target to compile core -->
+ </target>
+
+ <target name="jar-core" depends="compile-core"
+ description="Packages the JAR file">
+ <jarify/>
+ </target>
+
+ <macrodef name="m2-deploy" description="Builds a Maven artifact">
+ <element name="artifact-attachments" optional="yes"/>
+ <attribute name="pom.xml" default="pom.xml"/>
+ <attribute name="jar.file" default="${build.dir}/${final.name}.jar"/>
+ <sequential>
+ <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
+ <artifact:pom id="maven.project" file="@{pom.xml}"/>
+ <artifact:deploy file="@{jar.file}">
+ <artifact-attachments/>
+ <remoteRepository url="${m2.repository.url}">
+ <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}" password="${m2.repository.password}"/>
+ </remoteRepository>
+ <pom refid="maven.project"/>
+ </artifact:deploy>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="m2-deploy-with-pom-template" description="Builds a Maven artifact given a POM template">
+ <attribute name="pom.xml"/>
+ <attribute name="jar.file"/>
+ <sequential>
+ <copy file="@{pom.xml}" tofile="${maven.build.dir}/pom.xml" overwrite="true">
+ <filterset begintoken="@" endtoken="@">
+ <filter token="version" value="${version}"/>
+ </filterset>
+ <filterset begintoken="$${" endtoken="}">
+ <filter token="project.version" value="${version}"/>
+ </filterset>
+ </copy>
+ <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
+ <artifact:pom id="maven.project" file="${maven.build.dir}/pom.xml" />
+ <artifact:deploy file="@{jar.file}">
+ <remoteRepository url="${m2.repository.url}">
+ <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}" password="${m2.repository.password}"/>
+ </remoteRepository>
+ <pom refid="maven.project"/>
+ </artifact:deploy>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="build-manifest" description="Builds a manifest file">
+ <attribute name="title"/>
+ <attribute name="implementation.title"/>
+ <attribute name="spec.version"/>
+ <sequential>
+ <manifest file="${manifest.file}">
+ <!--
+ http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR%20Manifest
+ http://java.sun.com/j2se/1.5.0/docs/guide/versioning/spec/versioning2.html
+ http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Package.html
+ http://java.sun.com/j2se/1.5.0/docs/api/java/util/jar/package-summary.html
+ http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
+ -->
+ <!-- Don't set 'Manifest-Version' it identifies the version of the
+ manifest file format, and should always be 1.0 (the default)
+
+ Don't set 'Created-by' attribute, its purpose is
+ to identify the version of java used to build the jar,
+ which ant will do by default.
+
+ Ant will happily override these with bogus strings if you
+ tell it to, so don't.
+
+ NOTE: we don't use section info because all of our manifest data
+ applies to the entire jar/war ... no package specific info.
+ -->
+ <attribute name="Extension-Name" value="@{implementation.title}"/>
+ <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="@{implementation.title}"/>
+ <!-- impl version can be any string -->
+ <attribute name="Implementation-Version"
+ value="${version} ${svnversion} - ${user.name} - ${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"/>
+ <attribute name="title" default="Lucene Search Engine: ${ant.project.name}"/>
+ <attribute name="excludes" default="**/pom.xml,**/*.iml"/>
+ <attribute name="metainf.source.dir" default="${common.dir}"/>
+ <attribute name="implementation.title" default="org.apache.lucene"/>
+ <attribute name="spec.version" default="${spec.version}"/>
+ <element name="nested" optional="true" implicit="true"/>
+ <sequential>
+ <!-- If possible, include the svnversion -->
+ <exec dir="." executable="${svnversion.exe}"
+ outputproperty="svnversion" failifexecutionfails="false">
+ <arg line="."/>
+ </exec>
+
+ <build-manifest title="@{title}"
+ implementation.title="@{implementation.title}"
+ spec.version="@{spec.version}"/>
+
+ <jar destfile="@{destfile}"
+ basedir="@{basedir}"
+ manifest="${manifest.file}"
+ excludes="@{excludes}">
+ <metainf dir="@{metainf.source.dir}" includes="LICENSE.txt,NOTICE.txt"/>
+ <nested />
+ </jar>
+ </sequential>
+ </macrodef>
+
+ <property name="lucene-core.jar" value="${common.dir}/build/lucene-core-${version}.jar"/>
+ <target name="check-lucene-core-uptodate" unless="lucene-core.uptodate">
+ <uptodate property="lucene-core.uptodate" targetfile="${lucene-core.jar}">
+ <srcfiles dir="${common.dir}/src/java" includes="**/*.java"/>
+ </uptodate>
+ </target>
+ <target name="jar-lucene-core" unless="lucene-core.uptodate" depends="check-lucene-core-uptodate">
+ <ant dir="${common.dir}" target="jar-core" inheritAll="false">
+ <propertyset refid="uptodate.and.compiled.properties"/>
+ </ant>
+ <property name="lucene-core.uptodate" value="true"/>
+ </target>
+ <target name="compile-lucene-core" unless="core.compiled">
+ <ant dir="${common.dir}" target="compile-core" inheritAll="false">
+ <propertyset refid="uptodate.and.compiled.properties"/>
+ </ant>
+ <property name="core.compiled" value="true"/>
+ </target>
+
+ <path id="test-framework.classpath">
+ <path refid="ant-path"/>
+ <path refid="test.classpath"/>
+ </path>
+
+ <target name="compile-test-framework" depends="compile-core">
+ <compile-test-macro srcdir="${tests-framework.src.dir}" destdir="${common.dir}/build/classes/test-framework"
+ test.classpath="test-framework.classpath"/>
+ <!-- Copy the resources folder (if existent) -->
+ <copy todir="${common.dir}/build/classes/test-framework">
+ <fileset dir="${tests-framework.src.dir}/../resources" erroronmissingdir="no"/>
+ </copy>
+ </target>
+
+ <target name="compile-tools">
+ <compile
+ srcdir="${common.dir}/src/tools/java"
+ destdir="${common.build.dir}/classes/tools">
+ <classpath refid="classpath"/>
+ </compile>
+ </target>
+
+ <target name="compile-test" depends="compile-test-framework">
+ <compile-test-macro srcdir="${tests.src.dir}" 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" default="${tests.src.dir}"/>
+ <attribute name="tempDir" default="${build.dir}/test"/>
+ <attribute name="threadNum" default="1"/>
+ <attribute name="threadTotal" default="1"/>
+ <attribute name="tests.nightly" default="${tests.nightly}"/>
+ <attribute name="tests.multiplier" default="${tests.multiplier}"/>
+
+ <sequential>
+ <condition property="runall">
+ <not><or>
+ <isset property="testcase" />
+ <isset property="testpackage" />
+ <isset property="testpackageroot" />
+ </or></not>
+ </condition>
+ <!-- <mkdir dir="@{tempDir}/@{pattern}"/>
+ This is very loud and obnoxious. abuse touch instead for a "quiet" mkdir
+ -->
+ <touch file="@{tempDir}/@{threadNum}/quiet.ant" verbose="false" mkdirs="true"/>
+ <junit printsummary="off" haltonfailure="no" maxmemory="512M" tempdir="@{tempDir}/@{threadNum}"
+ errorProperty="tests.failed" failureProperty="tests.failed" forkmode="perBatch" dir="@{tempDir}/@{threadNum}">
+ <classpath refid="@{junit.classpath}"/>
+ <assertions>
+ <enable package="org.apache.lucene"/>
+ <enable package="org.apache.solr"/>
+ </assertions>
+
+ <jvmarg line="${args}"/>
+
+ <!-- allow tests to control debug prints -->
+ <sysproperty key="tests.verbose" value="${tests.verbose}"/>
+ <!-- directory for formatter lock -->
+ <sysproperty key="tests.lockdir" value="${tests.lockdir}"/>
+ <!-- set the locale tests should run with -->
+ <sysproperty key="tests.locale" value="${tests.locale}"/>
+ <!-- set the timezone tests should run with -->
+ <sysproperty key="tests.timezone" value="${tests.timezone}"/>
+ <!-- set the directory tests should run with -->
+ <sysproperty key="tests.directory" value="${tests.directory}"/>
+ <!-- set the line file source for oal.util.LineFileDocs -->
+ <sysproperty key="tests.linedocsfile" value="${tests.linedocsfile}"/>
+ <!-- set the number of times tests should run -->
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
+ <!-- set the minimum number of times tests should run unless failure -->
+ <sysproperty key="tests.iter.min" value="${tests.iter.min}"/>
+ <!-- set the test seed -->
+ <sysproperty key="tests.seed" value="${tests.seed}"/>
+ <!-- set the Version that tests should run against -->
+ <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
+ <!-- for lucene we can be strict, and we don't want false fails even across methods -->
+ <sysproperty key="tests.cleanthreads" value="${tests.cleanthreads.sysprop}"/>
+ <!-- logging config file -->
+ <sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
+ <!-- set whether or not nightly tests should run -->
+ <sysproperty key="tests.nightly" value="@{tests.nightly}"/>
+
+ <!-- set whether tests framework should not require java assertions enabled -->
+ <sysproperty key="tests.asserts.gracious" value="${tests.asserts.gracious}"/>
+
+ <!-- TODO: create propertyset for test properties, so each project can have its own set -->
+ <sysproperty key="tests.multiplier" value="@{tests.multiplier}"/>
+ <sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
+
+ <sysproperty key="lucene.version" value="${dev.version}"/>
+
+ <sysproperty key="testmethod" value="${testmethod}"/>
+ <sysproperty key="jetty.testMode" value="1"/>
+ <sysproperty key="jetty.insecurerandom" value="1"/>
+ <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
+
+ <formatter type="xml"/>
+ <formatter classname="${junit.details.formatter}" usefile="false"/>
+ <batchtest fork="yes" todir="@{junit.output.dir}" if="runall">
+ <fileset dir="@{dataDir}" includes="**/Test*.java,**/*Test.java" excludes="${junit.excludes}">
+ <custom classname="${junit.parallel.selector}" classpathref="@{junit.classpath}">
+ <param name="divisor" value="@{threadTotal}" />
+ <param name="part" value="@{threadNum}" />
+ </custom>
+ </fileset>
+ </batchtest>
+ <batchtest fork="yes" todir="@{junit.output.dir}" if="testpackage">
+ <fileset dir="@{dataDir}" includes="**/${testpackage}/**/Test*.java,**/${testpackage}/**/*Test.java" excludes="${junit.excludes}">
+ <custom classname="${junit.parallel.selector}" classpathref="@{junit.classpath}">
+ <param name="divisor" value="@{threadTotal}" />
+ <param name="part" value="@{threadNum}" />
+ </custom>
+ </fileset>
+ </batchtest>
+ <batchtest fork="yes" todir="@{junit.output.dir}" if="testpackageroot">
+ <fileset dir="@{dataDir}" includes="**/${testpackageroot}/Test*.java,**/${testpackageroot}/*Test.java" excludes="${junit.excludes}">
+ <custom classname="${junit.parallel.selector}" classpathref="@{junit.classpath}">
+ <param name="divisor" value="@{threadTotal}" />
+ <param name="part" value="@{threadNum}" />
+ </custom>
+ </fileset>
+ </batchtest>
+ <batchtest fork="yes" todir="@{junit.output.dir}" if="testcase">
+ <fileset dir="@{dataDir}" includes="**/${testcase}.java"/>
+ </batchtest>
+ </junit>
+ <fail if="tests.failed">Tests failed!</fail>
+ </sequential>
+ </macrodef>
+
+ <target name="test" depends="compile-test,junit-mkdir,junit-sequential,junit-parallel" description="Runs unit tests"/>
+
+ <target name="junit-mkdir">
+ <mkdir dir="${junit.output.dir}"/>
+ </target>
+
+ <target name="junit-sequential" if="tests.sequential">
+ <test-macro/>
+ </target>
+
+ <target name="junit-parallel" unless="tests.sequential">
+ <parallel threadsPerProcessor="${tests.threadspercpu}">
+ <test-macro threadNum="1" threadTotal="8"/>
+ <test-macro threadNum="2" threadTotal="8"/>
+ <test-macro threadNum="3" threadTotal="8"/>
+ <test-macro threadNum="4" threadTotal="8"/>
+ <test-macro threadNum="5" threadTotal="8"/>
+ <test-macro threadNum="6" threadTotal="8"/>
+ <test-macro threadNum="7" threadTotal="8"/>
+ <test-macro threadNum="8" threadTotal="8"/>
+ </parallel>
+ </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.dir}">
+ <include name="org/apache/**/*.java" />
+ </fileset>
+ <testsources dir="${tests-framework.src.dir}">
+ <include name="org/apache/**/*.java" />
+ </testsources>
+ <testsources dir="${tests.src.dir}">
+ <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="${tests-framework.src.dir}" id="clover.test-framework.src.files">
+ <include name="**/*.java" />
+ </fileset>
+ <fileset dir="${tests.src.dir}" 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 -->
+ <exclude name="backwards/**"/>
+ </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.test-framework.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.test-framework.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.backwards}">
+ <include name="**/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">
+ <fileset dir="${src.dir}/../resources" erroronmissingdir="no"/>
+ </jarify>
+ </target>
+
+ <target name="default" depends="jar-core"/>
+
+ <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 source and test files">
+ <rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
+ <fileset dir="${src.dir}"/>
+ <fileset dir="${tests-framework.src.dir}"/>
+ <fileset dir="${tests.src.dir}"/>
+ </rat:report>
+ </target>
+
+ <!--+
+ | 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
+ includeAntRuntime="${javac.includeAntRuntime}"
+ 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 -Xlint:-deprecation -Xlint:-serial"/>
+ </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" encoding="UTF-8">
+ <containsregexp expression="Generated.*By.*JavaCC"/>
+ </fixcrlf>
+ </sequential>
+ </macrodef>
+
+ <property name="failonjavadocwarning" value="true"/>
+ <macrodef name="invoke-javadoc">
+ <element name="sources" optional="yes"/>
+ <attribute name="destdir"/>
+ <attribute name="title" default="${Name} ${version} API"/>
+ <attribute name="overview" default="${src.dir}/overview.html"/>
+ <sequential>
+ <copy todir="@{destdir}" file="${prettify.dir}/prettify.js" overwrite="false" />
+ <copy todir="@{destdir}" file="${prettify.dir}/prettify.css" overwrite="false" />
+ <record name="@{destdir}/log_javadoc.txt" action="start" append="no"/>
+ <javadoc
+ overview="@{overview}"
+ packagenames="org.apache.lucene.*,org.apache.solr.*"
+ destdir="@{destdir}"
+ access="${javadoc.access}"
+ encoding="${build.encoding}"
+ charset="${javadoc.charset}"
+ docencoding="${javadoc.charset}"
+ author="true"
+ version="true"
+ use="true"
+ failonerror="true"
+ source="${ant.java.version}"
+ link="${javadoc.link}"
+ windowtitle="${Name} ${version} API"
+ doctitle="@{title}"
+ stylesheetfile="${prettify.dir}/stylesheet+prettify.css"
+ maxmemory="${javadoc.maxmemory}"
+ bottom="Copyright &copy; ${year} Apache Software Foundation. All Rights Reserved.">
+ <tag name="lucene.experimental"
+ description="WARNING: This API is experimental and might change in incompatible ways in the next release."/>
+ <tag name="lucene.internal"
+ description="NOTE: This API is for internal purposes only and might change in incompatible ways in the next release."/>
+ <link offline="true" packagelistLoc="${javadoc.dir}"/>
+ <header><![CDATA[
+ <script src="{@docRoot}/prettify.js" type="text/javascript"></script>
+ <script language="JavaScript">window.onload=function(){windowTitle();prettyPrint();}</script>
+ ]]></header>
+
+ <sources />
+
+ <classpath refid="javadoc.classpath"/>
+ </javadoc>
+ <record name="@{destdir}/log_javadoc.txt" action="stop"/>
+
+ <delete>
+ <fileset file="@{destdir}/log_javadoc.txt">
+ <or>
+ <not>
+ <containsregexp expression="\[javadoc\]\s*[1-9][0-9]*\s*warning"/>
+ </not>
+ <and>
+ <!-- allow 1 warning, if there is also a bootstrap warning generated by Java7 -->
+ <containsregexp expression="\[javadoc\]\s*warning.*bootstrap"/>
+ <containsregexp expression="\[javadoc\]\s*1\s*warning"/>
+ </and>
+ </or>
+ </fileset>
+ </delete>
+
+ <fail message="Javadocs warnings were found!">
+ <condition>
+ <and>
+ <available file="@{destdir}/log_javadoc.txt"/>
+ <istrue value="${failonjavadocwarning}"/>
+ </and>
+ </condition>
+ </fail>
+
+
+ </sequential>
+ </macrodef>
+
+ <macrodef name="contrib-crawl">
+ <attribute name="target" default=""/>
+ <attribute name="failonerror" default="true"/>
+ <sequential>
+ <subant target="@{target}" failonerror="@{failonerror}" inheritall="false">
+ <propertyset refid="uptodate.and.compiled.properties"/>
+ <fileset dir="." includes="contrib/*/build.xml"/>
+ </subant>
+ </sequential>
+ </macrodef>
+
+ <!-- VALIDATION work -->
+ <!--
+ >find . -name lib
+./lucene/backwards/lib
+./lucene/contrib/ant/lib
+./lucene/contrib/benchmark/lib
+./lucene/contrib/db/bdb/lib
+./lucene/contrib/db/bdb-je/lib
+./lucene/contrib/icu/lib
+./lucene/contrib/lucli/lib
+./lucene/contrib/queries/lib
+./lucene/lib
+
+
+ -->
+ <target name="check-legal-lucene" depends="compile-tools">
+ <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">
+ <classpath>
+ <path refid="tools.runtime.classpath" />
+ </classpath>
+ <!-- TODO: it might be better to just automatically find all directories that contain jar files, but that could take a
+ long time. This should be faster, but we could miss a directory
+ TODO: convert this to just check whichever library is currently being built
+ -->
+ <!-- Lucene -->
+ <arg value="-c" />
+ <arg value="${common.dir}/lib" />
+ <arg value="-c" />
+ <arg value="${common.dir}/contrib/benchmark/lib" />
+ <arg value="-c" />
+ <arg value="${common.dir}/contrib/icu/lib" />
+
+ <arg value="-c" />
+ <arg value="${common.dir}/contrib/lucli/lib" />
+ <arg value="-c" />
+ <arg value="${common.dir}/contrib/queries/lib" />
+ </java>
+ </target>
+
+ <target name="check-legal" depends="check-legal-lucene"/>
+
+ <target name="validate-lucene" depends="check-legal-lucene" unless="validated-lucene"/>
+
+ <!-- Generic placeholder target for if we add other validation tasks -->
+ <target name="validate" depends="validate-lucene"/>
+
+ <property name="svn.export.dir" location="${build.dir}/svn-export"/>
+ <macrodef name="svn-export-source"
+ description="Runs 'svn export' with the same URL and revision as the current working copy.">
+ <attribute name="source.dir"/>
+ <sequential>
+ <delete dir="${svn.export.dir}" includeemptydirs="true" failonerror="false"/>
+ <get-svn-info directory="@{source.dir}"/>
+ <exec dir="@{source.dir}" executable="${svn.exe}" failonerror="true">
+ <arg value="export"/>
+ <arg value="--native-eol"/>
+ <arg value="LF"/>
+ <arg value="-r"/>
+ <arg value="${svn.Revision}"/>
+ <arg value="${svn.URL}"/>
+ <arg value="${svn.export.dir}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="get-svn-info"
+ description="Populates properties svn.URL and svn.Revision using 'svn info'.">
+ <attribute name="directory"/>
+ <sequential>
+ <exec dir="." executable="${svnversion.exe}" outputproperty="svn.ver"/>
+ <fail message="A subversion checkout is required for this target">
+ <condition>
+ <equals arg1="${svn.ver}" arg2="exported"/>
+ </condition>
+ </fail>
+ <exec dir="@{directory}" executable="${svn.exe}" outputproperty="svn.info" failonerror="true">
+ <arg value="info"/>
+ </exec>
+ <loadproperties>
+ <propertyresource name="svn.info"/>
+ <filterchain>
+ <linecontainsregexp>
+ <regexp pattern="(URL|Revision):"/>
+ </linecontainsregexp>
+ <replacestring from=": " to="="/>
+ <prefixlines prefix="svn."/>
+ </filterchain>
+ </loadproperties>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="make-checksums" description="Macro for building checksum files">
+ <attribute name="file"/>
+ <sequential>
+ <echo>Building checksums for '@{file}'</echo>
+ <checksum file="@{file}" algorithm="md5" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
+ <checksum file="@{file}" algorithm="sha1" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="sign-artifacts-macro">
+ <attribute name="artifacts.dir"/>
+ <sequential>
+ <delete failonerror="false">
+ <fileset dir="@{artifacts.dir}">
+ <include name="**/*.asc"/>
+ </fileset>
+ </delete>
+
+ <available property="gpg.input.handler" classname="org.apache.tools.ant.input.SecureInputHandler"
+ value="org.apache.tools.ant.input.SecureInputHandler"/>
+ <!--else:--><property name="gpg.input.handler" value="org.apache.tools.ant.input.DefaultInputHandler"/>
+ <input message="Enter GPG keystore password: >" addproperty="gpg.passphrase">
+ <handler classname="${gpg.input.handler}" />
+ </input>
+
+ <apply executable="${gpg.exe}" inputstring="${gpg.passphrase}"
+ dest="@{artifacts.dir}" type="file" maxparallel="1" verbose="yes">
+ <arg value="--passphrase-fd"/>
+ <arg value="0"/>
+ <arg value="--batch"/>
+ <arg value="--armor"/>
+ <arg value="--default-key"/>
+ <arg value="${gpg.key}"/>
+ <arg value="--output"/>
+ <targetfile/>
+ <arg value="--detach-sig"/>
+ <srcfile/>
+
+ <fileset dir="@{artifacts.dir}">
+ <include name="**/*.jar"/>
+ <include name="**/*.zip"/>
+ <include name="**/*.tgz"/>
+ <include name="**/*.pom"/>
+ </fileset>
+ <globmapper from="*" to="*.asc"/>
+ </apply>
+ </sequential>
+ </macrodef>
+
+ <property name="rc" value="rc0"/>
+ <property name="remote.staging.dir" value="public_html/staging_area/${rc}/${version}"/>
+ <property name="keyfile" value="${user.home}/.ssh/id_rsa"/>
+ <property name="scp.user" value="${user.name}"/>
+ <!--keys.dir is the location of the https://svn.apache.org/repos/asf/lucene/java/dist/ directory-->
+ <property name="keys.dir" value="${common.dir}/../../dist"/>
+ <macrodef name="copy-to-stage-macro">
+ <attribute name="artifacts.dir"/>
+ <sequential>
+ <sshexec host="people.apache.org"
+ username="${scp.user}"
+ keyfile="${keyfile}"
+ command="mkdir -p ${remote.staging.dir}"/>
+ <echo>Uploading artifacts to ${scp.user}@people.apache.org:${remote.staging.dir}</echo>
+ <scp todir="${scp.user}@people.apache.org:${remote.staging.dir}"
+ username="${scp.user}"
+ keyfile="${keyfile}"
+ verbose="true">
+ <fileset dir="${artifacts.dir}"/>
+ <fileset dir="${keys.dir}">
+ <include name="KEYS"/>
+ </fileset>
+ </scp>
+ </sequential>
+ </macrodef>
+
+</project>