Index: contrib/gdata-server/build.xml
===================================================================
--- contrib/gdata-server/build.xml	(revision 545831)
+++ 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-artifacts-and-tests" depends="default,compile-test" />        
 </project>
Index: contrib/db/bdb/build.xml
===================================================================
--- contrib/db/bdb/build.xml	(revision 545831)
+++ contrib/db/bdb/build.xml	(working copy)
@@ -55,6 +55,6 @@
   </target>
 
   <target name="check-and-get-db-jar" depends="get-db-jar" />
-  <target name="init" depends="common.init,check-and-get-db-jar" />
+  <target name="init" depends="contrib-build.init,check-and-get-db-jar" />
 
 </project>
Index: contrib/db/build.xml
===================================================================
--- contrib/db/build.xml	(revision 545831)
+++ contrib/db/build.xml	(working copy)
@@ -39,10 +39,19 @@
     <ant dir="bdb" target="clean" />
     <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" />
   </target>
 
+  <target name="build-artifacts-and-tests" depends="default,compile-test" />
+
 </project>
Index: contrib/contrib-build.xml
===================================================================
--- contrib/contrib-build.xml	(revision 545831)
+++ contrib/contrib-build.xml	(working copy)
@@ -28,7 +28,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}"/>
@@ -48,9 +51,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"/>
+    <ant dir="${common.dir}" target="jar-core" inheritAll="false"/>
   </target>
 
+  <target name="build-lucene-tests" unless="lucene.tests.present">
+    <ant dir="${common.dir}" 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-artifacts-and-tests" depends="jar, compile-test" />
 </project>
Index: contrib/spellchecker/build.xml
===================================================================
--- contrib/spellchecker/build.xml	(revision 545831)
+++ contrib/spellchecker/build.xml	(working copy)
@@ -24,4 +24,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 545831)
+++ build.xml	(working copy)
@@ -96,7 +96,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)"
   />
   
   <!-- ================================================================== -->
@@ -435,14 +435,20 @@
     </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-artifacts-and-tests"/>
   </target>
 
-  <target name="test-contrib" depends="compile-test">
-    <!-- don't fail on error, instead check for flag file so we run
+  <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
+         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">
