I'm using Gradle and Eclipse with the Buildship plugin.
Buildship creates the .classpath
file for Eclipse to use. I need one classpath entry (com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER
) to appear after the org.eclipse.buildship.core.gradleclasspathcontainer
entry, for class-loading reasons.
So the relevant part of my .classpath
file should look like this (having the GWT_CONTAINER
on the bottom).
<classpath>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer" />
<classpathentry kind="con" path="com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER"/>
</classpath>
Buildship always has the gradleclasspathcontainer
on the last position. So I tried to change the sorting like this in my build.gradle
(excerpt):
eclipse {
classpath {
file {
beforeMerged { classpath ->
def gwtClasspath = classpath.entries.find { entry -> entry.path == 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' }
classpath.entries.remove gwtClasspath
classpath.entries << gwtClasspath
}
}
}
When using ./gradlew eclipseClasspath
, the .classpath
file is created correctly. But as soon as Buildship runs, the file is again overwritten with the wrong ordering.
I also tried using whenMerged
instead of beforeMerged
, but that doesn't change anything.
Here's the output of Gradle when started by Buildship (e.g. by clicking on Gradle -> Refresh on the Eclipse project's properties):
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.5/userguide/command_line_interface.html#sec:command_line_warnings
CONFIGURE SUCCESSFUL in 0s
:cleanEclipseWtpComponent
:cleanEclipseWtpFacet
:cleanEclipseWtp
:eclipseWtpComponent
:eclipseWtpFacet
:eclipseWtp
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 0s
4 actionable tasks: 4 executed
It seems Buildship doesn't even execute the eclipseClasspath
task, but does create the .classpath
file by some other means.
How can I get Buildship to honor my wish to have the classpath sorted my way?