Skip to content

Commit d2f7442

Browse files
committed
Work around bug in Gradle's Eclipse model
The model incorrectly marks the Gradle API and all of its dependencies as test dependencies, making them unavailable in Eclipse to code in src/main/java. We work around this by modifying the classpath container to remove the test attribute from the dependencies that should be available to main code. See gh-41228
1 parent 3e98a93 commit d2f7442

File tree

1 file changed

+20
-0
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin

1 file changed

+20
-0
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import org.gradle.plugins.ide.eclipse.EclipsePlugin
2+
import org.gradle.plugins.ide.eclipse.model.Classpath
3+
import org.gradle.plugins.ide.eclipse.model.Library
4+
15
plugins {
26
id "java-gradle-plugin"
37
id "maven-publish"
@@ -219,3 +223,19 @@ publishing {
219223
}
220224
}
221225
}
226+
227+
plugins.withType(EclipsePlugin) {
228+
eclipse {
229+
classpath.file { merger ->
230+
merger.whenMerged { content ->
231+
if (content instanceof Classpath) {
232+
content.entries.each { entry ->
233+
if (entry instanceof Library && (entry.path.contains("gradle-api-") || entry.path.contains("groovy-"))) {
234+
entry.entryAttributes.remove("test")
235+
}
236+
}
237+
}
238+
}
239+
}
240+
}
241+
}

0 commit comments

Comments
 (0)