Skip to content

Apache Lucene open-source search software

LUCENE-2333: Fix failures during contrib builds, when classes in core were changed without ant clean. This fix also optimizes the dependency management between contribs by a new ANT macro

Uwe Schindler3343dcddce81
diff --git a/lucene/build.xml b/lucene/build.xml
index 268f4a45820..ea143ffbab7 100644
--- a/lucene/build.xml
+++ b/lucene/build.xml
@@ -670,6 +670,7 @@ The source distribution does not contain sources of the previous Lucene Java ver
<attribute name="failonerror" default="true"/>
<sequential>
<subant target="@{target}" failonerror="@{failonerror}">
+ <property name="core.compiled" value="true"/>
<fileset dir="."
includes="contrib/*/build.xml"
/>
@@ -677,7 +678,7 @@ The source distribution does not contain sources of the previous Lucene Java ver
</sequential>
</macrodef>
- <target name="build-contrib"
+ <target name="build-contrib" depends="compile-test"
description="Builds all contrib modules and their tests">
<contrib-crawl target="build-artifacts-and-tests"/>
</target>
diff --git a/lucene/contrib/CHANGES.txt b/lucene/contrib/CHANGES.txt
index 391ab36c881..0f372ae9572 100644
--- a/lucene/contrib/CHANGES.txt
+++ b/lucene/contrib/CHANGES.txt
@@ -117,6 +117,11 @@ Build
queryparsers under contrib/misc into contrib/queryparser. Moved
contrib/fast-vector-highlighter into contrib/highlighter. (Robert Muir)
+ * LUCENE-2333: Fix failures during contrib builds, when classes in
+ core were changed without ant clean. This fix also optimizes the
+ dependency management between contribs by a new ANT macro.
+ (Uwe Schindler, Shai Erera)
+
Optimizations
* LUCENE-2157: DelimitedPayloadTokenFilter no longer copies the buffer
diff --git a/lucene/contrib/ant/build.xml b/lucene/contrib/ant/build.xml
index 121ebd161bb..cda5e5698b8 100644
--- a/lucene/contrib/ant/build.xml
+++ b/lucene/contrib/ant/build.xml
@@ -33,11 +33,5 @@
refid="additional.dependencies"
/>
- <target name="compile-core" depends="common.compile-core">
- <copy todir="${build.dir}/classes/java">
- <fileset dir="src/java" includes="**/*.xml"/>
- </copy>
- </target>
-
<import file="../contrib-build.xml"/>
</project>
diff --git a/lucene/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml b/lucene/contrib/ant/src/resources/org/apache/lucene/ant/antlib.xml
similarity index 100%
rename from lucene/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml
rename to lucene/contrib/ant/src/resources/org/apache/lucene/ant/antlib.xml
diff --git a/lucene/contrib/benchmark/build.xml b/lucene/contrib/benchmark/build.xml
index 60a92864952..14c624cc59b 100644
--- a/lucene/contrib/benchmark/build.xml
+++ b/lucene/contrib/benchmark/build.xml
@@ -8,6 +8,12 @@
<import file="../contrib-build.xml"/>
<property name="working.dir" location="work"/>
+ <contrib-uptodate name="highlighter" property="highlighter.uptodate" classpath.property="highlighter.jar"/>
+ <contrib-uptodate name="icu" property="icu.uptodate" classpath.property="icu.jar"/>
+ <!-- analyzers common needs a hack for the jar file: -->
+ <contrib-uptodate name="analyzers/common" jarfile="${common.dir}/build/contrib/analyzers/common/lucene-analyzers-${version}.jar"
+ property="analyzers-common.uptodate" classpath.property="analyzers-common.jar"/>
+ <contrib-uptodate name="memory" property="memory.uptodate" classpath.property="memory.jar"/>
<target name="check-files">
<available file="temp/news20.tar.gz" property="news20.exists"/>
@@ -126,11 +132,11 @@
</target>
<path id="classpath">
- <pathelement path="${common.dir}/build/classes/java"/>
- <pathelement path="${common.dir}/build/classes/demo"/>
- <pathelement path="${common.dir}/build/contrib/highlighter/classes/java"/>
- <pathelement path="${common.dir}/build/contrib/memory/classes/java"/>
- <pathelement path="${common.dir}/build/contrib/analyzers/common/classes/java"/>
+ <pathelement path="${memory.jar}"/>
+ <pathelement path="${highlighter.jar}"/>
+ <pathelement path="${analyzers-common.jar}"/>
+ <path refid="base.classpath"/>
+ <pathelement path="${common.dir}/build/classes/demo"/>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
@@ -172,8 +178,8 @@
<path id="collation.runtime.classpath">
<path refid="run.classpath"/>
- <pathelement path="${common.dir}/build/contrib/icu/classes/java"/>
- <fileset dir="${common.dir}/contrib/icu/lib" includes="icu4j*.jar"/>
+ <pathelement path="${icu.jar}"/>
+ <fileset dir="${common.dir}/contrib/icu/lib" includes="icu4j*.jar"/>
</path>
<target name="collation" depends="compile,compile-icu,top-100k-wiki-word-files">
@@ -202,7 +208,7 @@
<path refid="run.classpath"/>
</path>
- <target name="shingle" depends="compile,compile-analyzers-common,get-files">
+ <target name="shingle" depends="compile,get-files">
<echo>Running contrib/benchmark with alg file: ${shingle.alg.file}</echo>
<java fork="true" classname="org.apache.lucene.benchmark.byTask.Benchmark"
maxmemory="${task.mem}" output="${shingle.output.file}">
@@ -223,27 +229,27 @@
<fileset dir="${common.dir}" includes="build.xml"/>
</subant>
</target>
- <target name="compile-highlighter">
- <subant target="compile">
+ <target name="compile-highlighter" unless="highlighter.uptodate">
+ <subant target="default">
<fileset dir="${common.dir}/contrib/highlighter" includes="build.xml"/>
</subant>
</target>
- <target name="compile-icu">
- <subant target="compile">
+ <target name="compile-icu" unless="icu.uptodate">
+ <subant target="default">
<fileset dir="${common.dir}/contrib/icu" includes="build.xml"/>
</subant>
</target>
- <target name="compile-analyzers-common">
- <subant target="compile">
+ <target name="compile-analyzers-common" unless="analyzers-common.uptodate">
+ <subant target="default">
<fileset dir="${common.dir}/contrib/analyzers/common" includes="build.xml"/>
</subant>
</target>
- <target name="compile-memory">
- <subant target="compile">
+ <target name="compile-memory" unless="memory.uptodate">
+ <subant target="default">
<fileset dir="${common.dir}/contrib/memory" includes="build.xml"/>
</subant>
</target>
- <target name="init" depends="common.init,compile-demo,compile-memory,compile-highlighter"/>
+ <target name="init" depends="common.init,compile-demo,compile-memory,compile-highlighter,compile-analyzers-common"/>
</project>
diff --git a/lucene/contrib/contrib-build.xml b/lucene/contrib/contrib-build.xml
index da7ce09e758..4eff0267962 100644
--- a/lucene/contrib/contrib-build.xml
+++ b/lucene/contrib/contrib-build.xml
@@ -27,20 +27,20 @@
<import file="../common-build.xml"/>
- <property name="lucene.jar" location="${common.dir}/build/lucene-core-${version}.jar"/>
- <available property="lucene.jar.present" type="file" file="${lucene.jar}"/>
- <available property="lucene.tests.present" type="dir"
- file="${common.dir}/build/classes/test" />
<available property="contrib.has.tests" type="dir" file="src/test" />
- <path id="classpath">
- <pathelement path="${lucene.jar}"/>
+ <!-- if you extend the classpath refid in one contrib's build.xml (add JARs), use this as basis: -->
+ <path id="base.classpath">
+ <pathelement location="${common.dir}/build/classes/java"/>
<pathelement path="${project.classpath}"/>
</path>
-
+
+ <!-- default classpath refid, can be overridden by contrib's build.xml (use the above base.classpath as basis): -->
+ <path id="classpath" refid="base.classpath"/>
+
<path id="test.classpath">
<path refid="classpath"/>
- <pathelement location="../../build/classes/test/"/>
+ <pathelement location="${common.dir}/build/classes/test"/>
<path refid="junit-path"/>
<pathelement location="${build.dir}/classes/java"/>
</path>
@@ -52,16 +52,13 @@
<pathelement path="${java.class.path}"/>
</path>
- <target name="build-lucene" unless="lucene.jar.present">
- <ant dir="${common.dir}" target="jar-core" inheritAll="false"/>
- </target>
-
- <target name="build-lucene-tests" unless="lucene.tests.present">
+ <target name="build-lucene" unless="core.compiled">
<ant dir="${common.dir}" target="compile-test" inheritAll="false"/>
+ <!-- set the property for this ant execution to speed up later tasks depending on this -->
+ <property name="core.compiled" value="true"/>
</target>
-
- <target name="init" depends="common.init,build-lucene,build-lucene-tests"/>
+ <target name="init" depends="common.init,build-lucene"/>
<target name="compile-test" depends="init" if="contrib.has.tests">
<antcall target="common.compile-test" inheritRefs="true" />
</target>
@@ -111,4 +108,18 @@
]]></echo>
</target>
+ <macrodef name="contrib-uptodate">
+ <attribute name="name"/>
+ <attribute name="property" default="@{name}.uptodate"/>
+ <attribute name="classpath.property" default="@{name}.jar"/>
+ <!-- set jarfile only, if the target jar file has no generic name, applies to analyzers with its common and smartcn subdir -->
+ <attribute name="jarfile" default="${common.dir}/build/contrib/@{name}/lucene-@{name}-${version}.jar"/>
+ <sequential>
+ <!--<echo message="Checking '@{jarfile}' against source folder '${common.dir}/contrib/@{name}/src/java'"/>-->
+ <property name="@{classpath.property}" location="@{jarfile}"/>
+ <uptodate property="@{property}" targetfile="@{jarfile}">
+ <srcfiles dir="${common.dir}/contrib/@{name}/src/java" includes="**/*.java"/>
+ </uptodate>
+ </sequential>
+ </macrodef>
</project>
diff --git a/lucene/contrib/highlighter/build.xml b/lucene/contrib/highlighter/build.xml
index cd123293930..46f5d3d67f4 100644
--- a/lucene/contrib/highlighter/build.xml
+++ b/lucene/contrib/highlighter/build.xml
@@ -25,28 +25,24 @@
<import file="../contrib-build.xml"/>
- <property name="memory.jar" location="${common.dir}/build/contrib/memory/lucene-memory-${version}.jar"/>
- <available property="memory.jar.present" type="file" file="${memory.jar}"/>
-
- <property name="queries.jar" location="${common.dir}/build/contrib/queries/lucene-queries-${version}.jar"/>
- <available property="queries.jar.present" type="file" file="${queries.jar}"/>
+ <contrib-uptodate name="memory" property="memory.uptodate" classpath.property="memory.jar"/>
+ <contrib-uptodate name="queries" property="queries.uptodate" classpath.property="queries.jar"/>
<path id="classpath">
- <pathelement path="${lucene.jar}"/>
<pathelement path="${memory.jar}"/>
<pathelement path="${queries.jar}"/>
- <pathelement path="${project.classpath}"/>
+ <path refid="base.classpath"/>
</path>
<target name="compile-core" depends="build-memory, build-queries, common.compile-core" />
- <target name="build-memory" unless="memory.jar.present">
- <echo>Highlighter building dependency ${memory.jar}</echo>
+ <target name="build-memory" unless="memory.uptodate">
+ <echo>Highlighter building dependency contrib/memory</echo>
<ant antfile="../memory/build.xml" target="default" inheritall="false" dir="../memory" />
</target>
- <target name="build-queries" unless="queries.jar.present">
- <echo>Highlighter building dependency ${queries.jar}</echo>
+ <target name="build-queries" unless="queries.uptodate">
+ <echo>Highlighter building dependency contrib/queries</echo>
<ant antfile="../queries/build.xml" target="default" inheritall="false" dir="../queries" />
</target>
</project>
diff --git a/lucene/contrib/spatial/build.xml b/lucene/contrib/spatial/build.xml
index 8c82a9fe5bb..37c6f04b539 100644
--- a/lucene/contrib/spatial/build.xml
+++ b/lucene/contrib/spatial/build.xml
@@ -25,18 +25,16 @@
<import file="../contrib-build.xml"/>
- <property name="misc.jar" location="${common.dir}/build/contrib/misc/lucene-misc-${version}.jar"/>
- <available property="misc.jar.present" type="file" file="${misc.jar}"/>
+ <contrib-uptodate name="misc" property="misc.uptodate" classpath.property="misc.jar"/>
<path id="classpath">
- <pathelement path="${lucene.jar}"/>
<pathelement path="${misc.jar}"/>
- <pathelement path="${project.classpath}"/>
+ <path refid="base.classpath"/>
</path>
<target name="compile-core" depends="build-misc, common.compile-core" />
- <target name="build-misc" unless="misc.jar.present">
+ <target name="build-misc" unless="misc.uptodate">
<echo>Misc building dependency ${misc.jar}</echo>
<ant antfile="../misc/build.xml" target="default" inheritall="false" dir="../misc" />
</target>
diff --git a/lucene/contrib/spellchecker/build.xml b/lucene/contrib/spellchecker/build.xml
index 8ac6a25acbe..d89be94a268 100755
--- a/lucene/contrib/spellchecker/build.xml
+++ b/lucene/contrib/spellchecker/build.xml
@@ -24,6 +24,4 @@
</description>
<import file="../contrib-build.xml"/>
- <target name="compile-test"
- depends="build-lucene-tests,contrib-build.compile-test" />
</project>
diff --git a/lucene/contrib/xml-query-parser/build.xml b/lucene/contrib/xml-query-parser/build.xml
index 3201b6c835e..e646ed25057 100644
--- a/lucene/contrib/xml-query-parser/build.xml
+++ b/lucene/contrib/xml-query-parser/build.xml
@@ -25,28 +25,27 @@
<import file="../contrib-build.xml"/>
- <property name="queries.jar" location="${common.dir}/build/contrib/queries/lucene-queries-${version}.jar"/>
+ <contrib-uptodate name="queries" property="queries.uptodate" classpath.property="queries.jar"/>
+ <property name="lucene.jar" location="${common.dir}/build/lucene-core-${version}.jar"/>
<property name="servlet.jar" location="${common.dir}/lib/servlet-api-2.4.jar"/>
- <available property="queries.jar.present" type="file" file="${queries.jar}"/>
<available property="servlet.jar.present" type="file" file="${servlet.jar}"/>
<path id="classpath">
- <pathelement path="${lucene.jar}"/>
<pathelement path="${queries.jar}"/>
- <pathelement path="${project.classpath}"/>
+ <path refid="base.classpath"/>
</path>
<path id="web-classpath">
- <pathelement path="${lucene.jar}"/>
<pathelement path="${queries.jar}"/>
<pathelement path="${servlet.jar}"/>
<pathelement path="${build.dir}/${final.name}.jar"/>
+ <path refid="base.classpath"/>
</path>
<target name="compile-core" depends="build-queries, common.compile-core" />
- <target name="build-queries" unless="queries.jar.present">
+ <target name="build-queries" unless="queries.uptodate">
<echo>XML Parser building dependency ${queries.jar}</echo>
<ant antfile="../queries/build.xml" target="default" inheritall="false" dir="../queries" />
</target>
@@ -59,6 +58,9 @@
<target name="build-web-demo" description="Compiles demo" if="servlet.jar.present">
<echo>XML Parser compiling web demo</echo>
+
+ <ant dir="${common.dir}" target="jar-core" inheritAll="false"/>
+
<compile
srcdir="src/demo/java"
destdir="${build.dir}/classes/webdemo">