I’m using Buildship and Gradle with Eclipse. I have an issue I described on Stackoverflow, but I haven’t found a solution so far, so I’m asking here.
I’m wondering how Buildship creates the .classpath file for Eclipse, because apparently the Gradle task eclipseClasspath is never executed, but the .classpath file gets modified. In the end, I need to modify the order Buildship writes the classpath entries into .classpath, so I’m wondering how to do that. Is there a way to convince Buildship to use the Gradle task, or is there some other way to modify the behaviour?
Your observation is correct, Buildship doesn’t call eclipseClasspath directly. It reads the configuration from the java and the eclipse Gradle plugins via the Gradle Tooling API and sets the values by using Eclipse JDT’s API. You can customize the content of the .classpath file via the eclipse.classpath.file.whenMerged block. You’ll find examples how to that in the Buildship 1.0.18 release announcement.
So the reordering seems to work, but <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"> will still end up last. Is there any way to get an entry behind this one?
Buildship appends the Gradle classpath container to the end of the classpath if it’s not defined in the eclipse plugin configuration. The following snippet fixes this behavior: