My current configuration includes a Java WAR project using gradle with the java and eclipse-wtp plugins, and the latest version of Buildship for Eclipse integration (1.0.3 till this morning and 1.0.4 right now) along with Eclipse Luna.
After following this solution http://stackoverflow.com/a/9820317/1544713 (successfully) to avoid deploying the test classes to my local server, I noticed that every time I refreshed the project or closed and opened Eclipse, the .classpath
file and .settings/org.eclipse.wst.common.component
were changed to their previous state, which is something I that gives me problems (deploying the test classes to the local server implies that they will fail to be loaded due to the lack of some test time dependencies, and of course an undesired behaviour).
The content of .classpath
is changed from (the right one):
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
to this undesired state:
<classpathentry kind="src" path="src/test/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/resources">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
And in the case of .settings/org.eclipse.wst.common.component
, these two lines are added (which again, I don’t want them to be present):
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
I can’t figure out if it is Gradle that is changing the files or Buildship, or even Eclipse. In any case, I guess there is a way to stop this happening. I have tried many alternatives, like the following configs in build.gradle:
eclipse.classpath.file.whenMerged { cp ->
cp.entries.findAll { it.kind = "src" && it.path.startsWith("src/test/") }*.output = "target/test-classes"
}
eclipse {
wtp.component {
file.withXml { xml ->
def node = xml.asNode()
def wbrNodes = node.'**'.findAll { it.name() == 'wb-resource' && it.'@source-path'.startsWith("/src/test/")}
if (wbrNodes.size() > 0) {
wbrNodes.each { n -> n.parent().remove(n) }
}
}
}
}
But this configuration works erratically (sometimes it seems to work, some other times it doesn’t, and actually the first piece of code that starts with eclipse.classpath.file.whenMerged never works).
Thanks in advance.