From 43f331788d85bbdd6ba9fed175f1a2f7c1b9f8ce Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 14 Sep 2021 21:05:57 +0200 Subject: [PATCH] Re-enable import into Eclipse IDE 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 --- gradle/ide.gradle | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gradle/ide.gradle b/gradle/ide.gradle index 6c112fd5b39e..20bf5f494e73 100644 --- a/gradle/ide.gradle +++ b/gradle/ide.gradle @@ -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) }