title: Call gradle eclipse task from another task
body: <p>One git repository I’m working with contains 50+ eclipse projects, which are all generated in a working copy by <code>./gradlew eclipse</code> (eclipse stuff is not under source control). When one switches between branches or commits, the set of these projects sometimes changes. Calling <code>./gradlew eclipse</code> after <code>git checkout</code> works, but it only creates newly discovered projects.</p>
  
  <p>The projects that no longer exist in a commit one have switched to become orphans – no longer needed <code>.eclipse</code>, <code>.classpath</code> and <code>.settings</code> remain in the directory tree. Because of this, <em>Import existing projects</em> wizard in Eclipse executes with errors and some dependencies in the workspace become corrupt as well. </p>
  
  <p>I tried writing a gradle task that would remove all existing eclipse files and then recreate them using a standard <code>eclipse</code> task. Finally, I'd like to remove eclipse files in the root of the repo, so that the import wizard showed all projects with no need to tick <em>Search for nested projects</em>.</p>
  
  <pre><code>// /.gradlew eclipse does not remove old projects' eclipse files
  // so there is a chance of importing a deleted project to eclipse after its removal.
  // This creates name conflicts and failures in eclipse build.
  // /.gradlew eclipsex fixes this issue
  
  task deleteEclipseStuffInAllDirs(type: Delete) {
    delete fileTree(dir: '.' , include: '**/.project')
    delete fileTree(dir: '.' , include: '**/.classpath')
    delete fileTree(dir: '.' , include: '**/.settings/*') // could not find how to delete such dirs themselves
  }
  
  task deleteEclipseStuffInRootDir(type: Delete) {
    delete fileTree(dir: '.' , include: '.project')
    delete fileTree(dir: '.' , include: '.classpath')
    delete '.settings'
  }
  deleteEclipseStuffInRootDir.dependsOn(":eclipse")
  
  task eclipsex() {
  }
  eclipsex.dependsOn(":deleteEclipseStuffInAllDirs")
  eclipsex.dependsOn(":eclipse")
  eclipsex.dependsOn(":deleteEclipseStuffInRootDir")
  </code></pre>
  
  <p>Despite me setting up all dependencies, <code>eclipse</code> command does not always get executed. How do I force it?</p>
  
  <p><strong>P.S:</strong> I know there exists <code>./gradlew cleanEclipse</code>, but it does not delete orphan eclipse files for some reason.</p>
  
  <p><strong>UPD:</strong> Console output:</p>
  
  <pre><code>$ ./gradlew eclipse
  Starting a new Gradle Daemon for this build (subsequent builds will be faster).
  Parallel execution with configuration on demand is an incubating feature.
  :eclipseClasspath
  :back-end:proj1:eclipseClasspath
  :back-end:proj2:eclipseClasspath
  :back-end:proj3:eclipseClasspath
  ...
  :front-end:proj42:eclipseJdt
  :front-end:proj42:eclipseProject
  :front-end:proj42:eclipse
  
  BUILD SUCCESSFUL
  
  Total time: 13.677 secs
  </code></pre>
  
  <p> </p>
  
  <pre><code>$ ./gradlew eclipsex
  Parallel execution with configuration on demand is an incubating feature.
  :deleteEclipseStuffInAllDirs
  :eclipseClasspath
  :eclipseJdt
  :eclipseProject
  :eclipse
  :deleteEclipseStuffInRootDir
  :eclipsex
  
  BUILD SUCCESSFUL
  
  Total time: 3.788 secs
  </code></pre>