Eclipse-wtp facet creates duplicates


#1

Hello,

in a multiproject build, I want to enforce a certain facet configuration on all subprojects with plugin 'war’
So did this:

subprojects {
	def configureFacets = {
	// TODO configure facets according to ear/war type
		eclipse {
			wtp {
        		facet {
            		facet name: 'java', version: '1.8'
            		facet name: 'jst.web', version: '3.0'
            		facet name: 'com.ibm.websphere.coexistence.web', version: '8.5'
				facet name: 'com.ibm.websphere.extended.web', version: '8.5'
            		facet name: 'wst.jsdt.web', version: '1.0'
        		}
        	} 
		} 
	}  
	pluginManager.withPlugin('eclipse-wtp',configureFacets)
}

The problem is that the resulting facet configuration is different:

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
	<fixed facet="jst.java"/>
	<fixed facet="jst.web"/>
	<installed facet="jst.web" version="2.4"/>
	<installed facet="jst.java" version="1.8"/>
	<installed facet="java" version="1.8"/>
	<installed facet="jst.web" version="3.0"/>
	<installed facet="com.ibm.websphere.coexistence.web" version="8.5"/>
	<installed facet="com.ibm.websphere.extended.web" version="8.5"/>
	<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

I tried to delete the entire .settings directory and it gets recreated with ‘org.eclipse.wst.common.project.facet.core.xml’ containing the above.
I suspect gradle doing that as I can see from this code:

How can I overwrite?


#2

Update:
I came so far to be able to remove the line added by the eclipse using the following, but I miss the right syntax to add a facet. Any idea?

		eclipse.wtp.facet {
      		file {
        		whenMerged { wtpFacet ->
        			wtpFacet.facets.removeAll { entry -> entry.name == 'jst.web'}
        			wtpFacet.facets.add { entry -> ????}
        		}
//        		facet name: 'java', version: '1.8'
//				facet name: 'jst.web', version: '3.0'
//				facet name: 'com.ibm.websphere.coexistence.web', version: '8.5'
//				facet name: 'com.ibm.websphere.extended.web', version: '8.5'
//				facet name: 'wst.jsdt.web', version: '1.0'        		
  			}
		}

(Miro) #3

Hi, I have the same problem.
Have you found a solution?


#4

Unfortunately not. At the end I dropped the idea of manipulating facets. It was not critical


(Victor Ortiz) #5

Hi Andreas,

I found a solution that works for me just in case you want to give it a try. What I did is add the facets that I need and then remove any unwanted entries. In this case I removed jst.java since it is duplicated with our java entry and jst.web that is not version 3.0. Hope this helps.

eclipse.wtp.facet {
    facet name: 'java', version: '1.8' 
    facet name: 'jst.web', version: '3.0' 
    facet name: 'com.ibm.websphere.coexistence.web', version: '8.5' 
    facet name: 'com.ibm.websphere.extended.web', version: '8.5' 
    facet name: 'wst.jsdt.web', version: '1.0'

    file {
        whenMerged { 
            wtpFacet -> wtpFacet.facets.removeAll { 
                entry -> entry.name == 'jst.web' && entry.version != '3.0' || 
                entry.name == 'jst.java' 
            }
        }
    }
}