Regression: wrong org.eclipse.wst.common.component file generation after upgrade to Gradle >= 4.4
I upgraded my build script wrapper from Gradle 4.1 to 4.4 and I see the following problem. I tested al versions from 4.1 to 4.6 and I verified it's happening only on Gradle >= 4.4. Same Buildship version 2.2.2.v20180125-2333-s under Oxygen.2.
When I do a "Refresh Gradle Project" on my project applying plugin eclipse-wtp, I get the following:
Gradle < 4.4:
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="shop-backend">
<property name="context-root" value="shop-backend"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/groovy"/>
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/shop-commons/shop-commons">
<dependency-type>uses</dependency-type>
</dependent-module>
</wb-module>
</project-modules>
Gradle >= 4.4:
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="shop-backend">
<property name="context-root" value="shop-backend"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/groovy"/>
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/groovy"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/shop-commons/shop-commons">
<dependency-type>uses</dependency-type>
</dependent-module>
</wb-module>
</project-modules>
As you can see:
- test sources are now deployed (which should not be the case)
- main resources entries are duplicated
I suspect this may be somewhat related to multiple output folders per source set support introduced when Gradle >=4.4 is in use.
~~I am observing the same issue but for me <deployment-module>s are missing as well.~~
I removed the java plugin from my project and moved dependencies from implementation to compile, now it's working as expected.
Any thought on this? I think it's quite an important issue.
Hmmm... the strange thing is that a subsequent "Refresh Gradle Project" seems to fix the issue and put the component file back to normal... At least this is what has just happened to me (wrong component file generated on first "refresh" after Gradle 4.2=>4.7 upgrade, right component file after a second "refresh"). If this is actually the case, the severity is indeed lower.
I can reproduce the issue, even with Gradle 5.5.1. Most probably it's a bug in the eclipse-wtp plugin
With the simple workaround available (running synchronization twice) we can indeed treat this as low prio.
Recently I found a bug related to this issue and the Jboss plugin for eclipse, if the source-path of dependencies from an EAR project (WARs and EJBs) points to src/main/java instead of /src/main/java the 'Add and Remove...' deployment of a Wildfly Server not works properly when selecting my EAR project. When I try to run it I got a null pointer exception.
Without slash before the src/main/java:

With slash before the /src/main/java deployment structure:

My way to fix this was adding a xml hook inside the build.gradle of the projects, duplicating the wb-resource deploy-path inside org.eclipse.wst.common.component including both the /src/... and src/...
eclipse.wtp.component.file.withXml { def node = it.asNode().children()[0] node.appendNode('wb-resource', ["deploy-path": '/', "source-path": '/src/main/java']) node.appendNode('wb-resource', ["deploy-path": '/', "source-path": '/src/main/resources']) }
Related to this thread: https://discuss.gradle.org/t/cant-configure-eclipse-wtp-component-resource-source-path-to-use-eclipse-project-linked-resource/9644