One git repository I’m working with contains 50+ eclipse projects, which are all generated in a working copy by ./gradlew eclipse
(eclipse stuff is not under source control). When one switches between branches or commits, the set of these projects sometimes changes. Calling ./gradlew eclipse
after git checkout
works, but it only creates newly discovered projects.
The projects that no longer exist in a commit one have switched to become orphans – no longer needed .eclipse
, .classpath
and .settings
remain in the directory tree. Because of this, Import existing projects wizard in Eclipse executes with errors and some dependencies in the workspace become corrupt as well.
I tried writing a gradle task that would remove all existing eclipse files and then recreate them using a standard eclipse
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 Search for nested projects.
// /.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")
Despite me setting up all dependencies, eclipse
command does not always get executed. How do I force it?
P.S: I know there exists ./gradlew cleanEclipse
, but it does not delete orphan eclipse files for some reason.
UPD: Console output:
$ ./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
$ ./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