How do I configure JPA with the Eclipse plugin?

(Thanh Phan) #1

I have been trying to find a way to configure JPA platform/implementation for Eclipse but could not find anything relevant. Did I miss anything or there is just no such support?

If I have to roll my own, mainly generating two files .settings/org.eclipse.jpt.core.prefs and .settings/org.eclipse.wst.common.project.facet.core.prefs.xml, are there examples out there that I can follow?


EclipseWtpFacet generating org.eclipse.wst.common.project.facet.core.prefs.xml file
(Peter Niederwieser) #2

The Gradle Eclipse plugin doesn’t have any particular support for JPA. Are you already applying the ‘eclipse-wtp’ plugin? If you need to create files other than those created by that plugin, you’ll need to write some tasks from scratch, perhaps leveraging Groovy’s MarkupBuilder to generate the XML.

(Thanh Phan) #3

Thank you for the confirmation and the XML tip. I ended up adding this block to my eclipse.wtp for now:

eclipse {
 wtp {
   facet {
   facet name:'jpt.jpa', version:'2.0'
      File prefsFile = file('.settings/org.eclipse.jpt.core.prefs')
    def writer = new StringWriter()
  def xml = new MarkupBuilder(writer)
  xml.root() {
   facet(id:'jpt.jpa') {
    node(name:'libprov') {
     attribute(name:'provider-id', value:'jpa-no-op-library-provider')
  prefsFile = file('.settings/org.eclipse.wst.common.project.facet.core.prefs.xml')

Maybe someday I will learn to write a proper plug-in for JPA :slight_smile: