seansand
seansand

Reputation: 1504

What is the proper gradle setup for JPA Static Metamodel Generator?

I'm trying to use the JPA Static Metamodel generator. I found a tutorial page that explains how to set it up in Gradle. I also found a stackoverflow comment that says to use the same classpath. It is:

classpath "gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.1"

However, when I attempt to use this, I get a gradle build error:

Error:Could not find gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.1.
Searched in the following locations:
https://repo1.maven.org/maven2/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.pom
https://repo1.maven.org/maven2/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.jar
https://jcenter.bintray.com/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.pom
https://jcenter.bintray.com/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.jar

What is the problem? Is this location out-of-date? If so, what's the new one?

Upvotes: 4

Views: 5801

Answers (2)

David Ding
David Ding

Reputation: 1749

First declare gradle plugin libs:

buildscript {
   repositories {
      jcenter()
      maven {
         url "https://plugins.gradle.org/m2/"
      }
      //... other repositories
   }

   dependencies {
      classpath "at.comm_unity.gradle.plugins.jpamodelgen:plugin:1.1.2"
   }
} 

Apply gradle plugin:

apply plugin: "com.github.iboyko.gradle.plugins.jpamodelgen"

jpaModelgen {
    library = "org.hibernate:hibernate-jpamodelgen:4.3.8.Final"
    jpaModelgenSourcesDir = "src/src/java"
}

compileJava.options.compilerArgs += ["-proc:none"]

The last line of the configuration should ALWAYS be present, or it will remove your original source code.

Upvotes: 0

seansand
seansand

Reputation: 1504

It turns out that the original tutorial page does have the answer, it's just commented out in the example. The proper maven repository has to be specified. This worked for me:

repositories {
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}

Upvotes: 1

Related Questions