Skip to content

Commit

Permalink
Re-enable import into Eclipse IDE
Browse files Browse the repository at this point in the history
The migration to Gradle 7.2 resulted in a regression for our Eclipse
IDE support: several projects ended up with recursive classpath entries
in their generated .classpath files which prevent those projects from
being built within Eclipse.

This commit addresses this issue with a solution that may well be a
"hack". Nonetheless, a working hack is better than not being able to
import into Eclipse at all.

See gh-26870
  • Loading branch information
sbrannen committed Sep 14, 2021
1 parent 9e986c0 commit 3faf445
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gradle/ide.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ eclipse.classpath.file.whenMerged { classpath ->
if (matcher) {
def projectName = matcher[0][1]
def path = "/${projectName}"
if(!classpath.entries.find { e -> e instanceof ProjectDependency && e.path == path }) {
def dependency = new ProjectDependency(path)
dependency.exported = true
classpath.entries.add(dependency)
if (!classpath.entries.find { e -> e instanceof ProjectDependency && e.path == path }) {
// Avoid recursive dependency on current project.
if (!entry.path.matches('.+/' + projectName + '/build/([^/]+/)+(?:main|test)')) {
def dependency = new ProjectDependency(path)
dependency.exported = true
classpath.entries.add(dependency)
}
}
classpath.entries.remove(entry)
}
Expand Down

0 comments on commit 3faf445

Please sign in to comment.