Additional eclipse wtp facet overwrites default facets

I have following build script. which tries to add the JavaScript facet to a eclipse web project. But the resulting project only contains the JavaScript facet. The default Java and Java Web facets are missing. This is contrary to my understanding of the EclipseWtpFacet documentation, which says that the facet method adds a facet.

apply plugin: "war"
apply plugin: 'eclipse-wtp'
  eclipse {
 wtp {
  facet {
   facet name: "wst.jsdt.web", version: "1.0"
  }
 }
}

Resulting org.eclipse.wst.common.project.facet.core.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
 <installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

Note: the java and eclipse plugin are applied from the root project build script.

Hi Rainer,

I’am just trying to fix some issues in Gradle’s Eclipse-WTP plugin (GRADLE-2186, GRADLE-2221, …) and I have also found this issue.

First of all documentation in http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseWtpFacet.html is wrong as you described in your comment above.

But the question is, what should the default behavior are? The advantage of not adding the default facets is that you don’t have to delete unwanted facets. The obvious disadvantage is that you also have to add the default facets again if you really want to add some new …

@Gradle: I would suggest adding a new method which adds the default facets (from the convention container), so everybody can choose what he/she really want? What do you mean? I think I could fix that providing a pull request!

I don’t use Eclipse anymore, so I don’t care much right now.

Still I believe that most configuration blocks add to or transform existing (default) configuration, and don’t reset it, i.e. methods or blocks add, assignments overwrite.

Therefore I think the better solution would be a clear method within the facet block to make the use case of removing the default facets possible, and implement the documented behavior. It feels more natural and gradle-like than to be surprised with a “destructive” behavior.

To follow up on this topic: Andres’ patch is merged now. Thanks for the contribution.

Re facet customization behavior: Andreas’ proposal sounds good to me. We can add a method to populate list of facets with default content (same as content defined by convention mapping). It means it is possible to achieve state with new facets and with or without default facets. And existing build scripts will not change their behavior this way. I like it more than introducing a method to remove content added as default.

Just to give you an update on this.

We removed the defaultFacets() method in favour of fixing the facet(Closure) behaviour. It is a breaking change though, but it is worth it I think.

You can still remove facets automatically applied by simply manipulating the list of facets though

Thanks to Andreas for the pull request and pushing us to fix this.

cheers, René

Hi Rene Groeschke,

for me that is ok as well! If you would have said that earlier, I could have fixed that as well :wink:

Are there any further issues in the Eclipse or Eclipse-WTP plugins you would like to get fixed and you have already a concept?

Cheers, Andreas