diff --git a/build.xml b/build.xml
index 3cb64c1..ed24705 100644
--- a/build.xml
+++ b/build.xml
@@ -65,7 +65,7 @@
     </subant></sequential>
   </target>
 
-  <target name="resolve" description="Resolves all dependencies">
+  <target name="resolve" depends="clean-jars" description="Resolves all dependencies">
     <sequential><subant target="resolve" inheritall="false" failonerror="true">
         <fileset dir="lucene" includes="build.xml" />
         <fileset dir="solr" includes="build.xml" />
@@ -116,7 +116,7 @@
     </sequential>
   </target>
 
-  <target name="eclipse" description="Setup Eclipse configuration" depends="resolve">
+  <target name="eclipse" depends="clean-jars, resolve" description="Setup Eclipse configuration">
     <copy file="dev-tools/eclipse/dot.project" tofile=".project" overwrite="false"/>
     <copy file="dev-tools/eclipse/dot.classpath" tofile=".classpath" overwrite="true"/>
     <mkdir dir=".settings"/>
@@ -129,7 +129,7 @@
     </echo>
   </target>
 
-  <target name="idea" description="Setup IntelliJ IDEA configuration" depends="resolve">
+  <target name="idea" depends="clean-jars, resolve" description="Setup IntelliJ IDEA configuration">
     <copy todir=".">
       <fileset dir="dev-tools/idea"/>
     </copy>
@@ -138,6 +138,7 @@
       File | Project Structure | Project | Project SDK.
     </echo>
   </target>
+
   <target name="clean-idea"
           description="Removes all IntelliJ IDEA configuration files">
     <delete dir=".idea" failonerror="true"/>
@@ -148,7 +149,7 @@
     </delete>
   </target>
 
-  <target name="clean" description="Clean Lucene and Solr">
+  <target name="clean" depends="clean-jars" description="Clean Lucene and Solr">
     <delete dir="dist" />
     <sequential>
       <subant target="clean" inheritall="false" failonerror="true">
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 2c8f144..539d626 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -1020,13 +1020,11 @@ ${tests-output}/junit4-*.suites     - per-JVM executed suites
 
   <target name="install-junit4-taskdef">
     <!-- JUnit4 taskdef. -->
+    <ivy:resolve   file="${common.dir}/test-framework/ivy.xml" type="jar" log="quiet" />
+    <ivy:cachepath file="${common.dir}/test-framework/ivy.xml" conf="junit4-stdalone" type="jar" transitive="false" pathid="path.junit4" />
+
     <taskdef resource="com/carrotsearch/junit4/antlib.xml">
-      <classpath>
-         <fileset dir="${common.dir}/test-framework/lib">
-            <include name="junit4-ant-*.jar" />
-            <include name="junit-*.jar" />
-         </fileset>
-      </classpath>
+      <classpath refid="path.junit4" />
     </taskdef>
   </target>
 
diff --git a/lucene/test-framework/ivy.xml b/lucene/test-framework/ivy.xml
index 7ee7270..048651e 100644
--- a/lucene/test-framework/ivy.xml
+++ b/lucene/test-framework/ivy.xml
@@ -18,13 +18,23 @@
 -->
 <ivy-module version="2.0">
     <info organisation="org.apache.lucene" module="core-test-framework"/>
-    <dependencies>
-      <dependency org="org.apache.ant" name="ant" rev="1.8.2" transitive="false"/>
-      <dependency org="org.apache.ant" name="ant-junit" rev="1.8.2" transitive="false"/>
-      <dependency org="junit" name="junit" rev="4.10" transitive="false"/>
 
-      <dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="1.5.0" transitive="false" />
-      <dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="1.5.0" transitive="false"/>
+    <configurations>
+      <conf name="default" />
+      <!-- 
+      JUnit4 ANT task only, no ANT.
+      This is used from build scripts for taskdefs.
+      -->
+      <conf name="junit4-stdalone" />
+    </configurations>
+
+    <dependencies defaultconf="default">
+      <dependency org="org.apache.ant" name="ant" rev="1.8.2" transitive="false" />
+      <dependency org="org.apache.ant" name="ant-junit" rev="1.8.2" transitive="false" />
+
+      <dependency org="junit" name="junit" rev="4.10" transitive="false" conf="default->*;junit4-stdalone->*" />
+      <dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="1.5.0" transitive="false" conf="default->*;junit4-stdalone->*" />
+      <dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="1.5.0" transitive="false" conf="default->*;junit4-stdalone->*" />
 
       <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/> 
     </dependencies>
