4

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?

Community
  • 1
  • 1
seansand
  • 1,492
  • 4
  • 18
  • 23

2 Answers2

1

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/"
    }
}
seansand
  • 1,492
  • 4
  • 18
  • 23
0

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.

David Ding
  • 1,473
  • 1
  • 15
  • 13