Using Gradle 1.11 & JDk1.7, We are unable to customize ‘java’ facet for web project.
I am trying to customize facet, how ever, I end up getting two records.
eclipse {
wtp {
facet {
facet name: 'java', version: '1.6', type: org.gradle.plugins.ide.eclipse.model.Facet.FacetType.fixed
}
}
}
Below facet xml is what I am getting:
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.web" version="2.5"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.java" version="1.6"/>
<installed facet="jst.java" version="1.7"/>
<fixed facet="java"/>
</faceted-project>
Any suggestion how to use jst.java = 1.6 using JDK1.7 ??
Hi,
I have/had the same issue in projects with ‘java’ plugin (in projects with ‘war’/‘ear’ plugin it works).
As far as I see, this should be fixed with 2.3: https://issues.gradle.org/browse/GRADLE-2221 https://issues.gradle.org/browse/GRADLE-2186
In the meantime I use a “ugly” workaround (i.e. change the file manually):
eclipseWtp << {
File facetXmlFile = new File(project.projectDir.path + '/.settings/org.eclipse.wst.common.project.facet.core.xml')
if(facetXmlFile.exists()){
def xmlRootNode = new XmlSlurper().parse(facetXmlFile)
def changed = false
xmlRootNode.children().findAll{ childNode ->
childNode.name() == 'installed' && childNode['@facet'] == 'jst.java'
}.each{ installedNodeForJava ->
installedNodeForJava['@version'] = javaVersionCompatibility
changed = true
}
if( changed ){
def writer = new FileWriter(facetXmlFile)
XmlUtil.serialize(xmlRootNode, writer)
}
}
}
I’m not the groovy expert so maybe there is a nicer/easier solution for that.
daz
January 27, 2015, 6:13pm
3
Please try again with Gradle-2.3-rc-1 (http://gradle.org/release-candidate) . There have been many improvements to the ‘eclipse-wtp’ plugin in this release.