Index: contrib/gdata-server/build.xml
===================================================================
--- contrib/gdata-server/build.xml	(revision 545679)
+++ contrib/gdata-server/build.xml	(working copy)
@@ -90,8 +90,7 @@
 		<ant dir="src/gom" target="jar-core" inheritRefs="true" />
 	</target>
 
-
-	<target name="test" depends="init" if="build-1-5-contrib">
+	<target name="test" depends="compile-test" if="build-1-5-contrib">
 		<ant dir="src/core" target="test" inheritRefs="true" />
 		<ant dir="src/gom" target="test" inheritRefs="true" />
 		<ant dir="src/hivemind" target="test" inheritRefs="true" />
@@ -129,5 +128,6 @@
   <target name="check-1-5" unless="build-1-5-contrib" >
      <echo>Java 1.5 support not availabble (or prohibited by explicitly set property) ... skipping task</echo>
   </target>
-         
+
+  <target name="build-jar-and-tests" depends="default,compile-test" />        
 </project>
Index: contrib/db/build.xml
===================================================================
--- contrib/db/build.xml	(revision 545679)
+++ contrib/db/build.xml	(working copy)
@@ -7,6 +7,8 @@
       - bdb-je: using Berkeley DB Java Edition
   </description>
 
+  <import file="../contrib-build.xml" />
+  
   <target name="bdb">
     <ant dir="bdb" />
   </target>
@@ -22,6 +24,15 @@
     <ant dir="bdb-je" target="clean" />
   </target>
 
+  <target name="compile-core">
+    <ant dir="bdb" target="compile-core" />
+    <ant dir="bdb-je" target="compile-core" />
+  </target>
+  <target name="compile-test">
+    <ant dir="bdb" target="compile-test" />
+    <ant dir="bdb-je" target="compile-test" />
+  </target>
+
   <target name="test">
     <ant dir="bdb" target="test" />
     <ant dir="bdb-je" target="test" />
Index: contrib/contrib-build.xml
===================================================================
--- contrib/contrib-build.xml	(revision 545679)
+++ contrib/contrib-build.xml	(working copy)
@@ -10,7 +10,10 @@
 
   <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}"/>
    <pathelement path="${project.classpath}"/>
@@ -30,9 +33,20 @@
   </path>
 
   <target name="build-lucene" unless="lucene.jar.present">
-    <!-- TODO: some tests need some of Lucene's own test classes too -->
     <ant antfile="${common.dir}/build.xml" target="jar-core" inheritall="false"/>
   </target>
 
+  <target name="build-lucene-tests" unless="lucene.tests.present">
+    <ant antfile="${common.dir}/build.xml" target="compile-test" inheritall="false"/>
+  </target>
+
+  
   <target name="init" depends="common.init,build-lucene"/>
+  <target name="compile-test" depends="init" if="contrib.has.tests">
+    <antcall target="common.compile-test" />
+  </target>
+  <target name="test" depends="init" if="contrib.has.tests">
+    <antcall target="common.test" />
+  </target>
+  <target name="build-jar-and-tests" depends="jar, compile-test" />
 </project>
Index: contrib/spellchecker/build.xml
===================================================================
--- contrib/spellchecker/build.xml	(revision 545679)
+++ contrib/spellchecker/build.xml	(working copy)
@@ -7,4 +7,6 @@
   </description>
 
   <import file="../contrib-build.xml"/>
+  <target name="compile-test"
+          depends="build-lucene-tests,contrib-build.compile-test" />
 </project>
Index: build.xml
===================================================================
--- build.xml	(revision 545679)
+++ build.xml	(working copy)
@@ -79,7 +79,7 @@
           description="Runs unit tests for the core Lucene code"
   />
   <target name="test" depends="test-core, test-contrib"
-          description="Runs all unit tests"
+          description="Runs all unit tests (including contribs)"
   />
   
   <!-- ================================================================== -->
@@ -418,11 +418,12 @@
     </sequential>
   </macrodef>
 
-  <target name="build-contrib" depends="compile-test">
-    <contrib-crawl/>
+  <target name="build-contrib"
+          description="Builds all contrib modules and their tests">
+    <contrib-crawl target="build-jar-and-tests"/>
   </target>
 
-  <target name="test-contrib" depends="compile-test">
+  <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
