Easily customize the eclipse-wtp facet version

Continuing the discussion from Be able to easily customize the eclipse-wtp facet version:

Continuing the discussion from Be able to easily customize the eclipse-wtp facet version:

This no longer works in Gradle 2.3 because the facet method adds facets instead of updating them. I couldn’t get @jnizet’s suggested workaround to work either. I’m not even sure how to do this in Gradle 2.3.

1 Like

It’s still a little clunky, but could you try:


eclipse {
    wtp {
        facet {
            facet name: 'jst.web', version: '3.0'
            def oldJstWebFacet = facets.findAll {
                it.name == 'jst.web' && it.version == '2.4'
            }
            facets.removeAll(oldJstWebFacet)
        }
    }
}
1 Like

That didn’t work for me. I copy+pasted your exact code but I still ended up with 2 jst.web facets in my Eclipse project: 2.4 and 3.0.

So is this a regression in Gradle 2.3?

Ah, it’s merging existing .settings files too. So if you generate a bad .settings/org.eclipse.wst.common.project.facet.core.xml (with jst.web 2.4), even with my bit of code, it’ll retain both versions. If you clean the .settings directory, that doesn’t happen.

You’re right, I cleaned the .settings directory and ran gradle eclipse and it generated fine with your code. Thanks.

I still wouldn’t call this easy, though. Could Gradle support overriding a default facet version somehow? Maybe the facet() method could override an existing facet with the same name?

Definitely agree with David on this one. Applying a facet should replace an existing facet with the same name.

The behavior has changed recently (can’t remember when). In the old days, setting any facet would clear all default facets and you would start from a clean slate. This was already a pain since it meant you had to recreate everything gradle does out of the box if you want a different facet version. The new behavior is only different, not better.