title: eclipse ant build failed Unable to delete file lib\build
body: <p>When running certain build.xml targets, the clean has a hit or miss on deleting the ivy jar directory. The "locked" files are by eclipse, using explorer on the directory or rerunning ant from eclipse refuses to delete it until restart of eclipse.  This is very time consuming. 
  Some reason eclipse is holding on to this files after running ant build/clean.<br>
  It's not all the projects and only at certain times for unknown reasons.  </p>
  
  <p>There is this existing discussion.  <a href="https://stackoverflow.com/questions/1486910/eclipse-wont-delete-files/16922616#16922616">Eclipse won&#39;t delete files</a></p>
  
  <p>but it doesn't answer the question for me about how to get eclipse to run ant without having to restart every time. </p>
  
  <p>Is there a way to use eclipse -console  to see the file handles what is holding it? or does somebody know a root cause to why eclipse/ant/ivy wont let go of these targets after a build or two (1st time after a fresh start of Eclipse works fine) but then some subsequent ant build after that it becomes unhappy. </p>
  
  <p>In my case it is eclipse which is locking the file for sure. 
  Restarting Eclipse is not a solution.  Otherwise, I'll just go back to a command line window. I've tried setting the run in same jvm, and all sorts of settings. </p>
  
  <p>Do I need to debug the eclipse plugins? Is there an easier way to find out what's not release the lock within Eclipse and it's plugins?   This is my first time ever to see this and I suspect it's IVY causing it. </p>
  
  <p>Running juno, ivy, spring, ant and have the problem when run-as Ant Build from Eclipse that clean is unable to delete the lib/build directory of the artifacts. </p>
  
  <pre><code>eclipse.buildId=M20130204-1200
  java.version=1.6.0_43
  java.vendor=Sun Microsystems Inc.
  BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
  Framework arguments:  -product org.eclipse.epp.package.jee.product
  Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product
  
  !ENTRY org.apache.ivyde.eclipse 1 0 2013-06-04 11:36:50.344 
  !MESSAGE starting IvyDE plugin
  </code></pre>
  
  <p>ant target: </p>
  
  <pre><code>    &lt;target name="clean-retrieved" &gt;
      &lt;delete includeemptydirs="true" &gt;
              &lt;fileset dir="${basedir}"&gt;
                  &lt;include name="lib/**" /&gt;
              &lt;/fileset&gt;
      &lt;/delete&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>ERROR: </p>
  
  <pre><code>clean-retrieved:
  
  BUILD FAILED
  C:\scripts\common-build-targets.xml:238: Unable to delete file C:\scripts\lib\build\annotations-1.3.8.jar &lt;&lt;just first jar file in directory..
  </code></pre>