Generating JPA2 Metamodel from a Gradle build script

前端 未结 7 1404
长情又很酷
长情又很酷 2020-11-30 02:24

I\'m trying to set up a Gradle build script for a new project. That project will use JPA 2 along with Querydsl.

On the following page of Querydsl\'s reference docume

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 03:14

    To use the JPA Metamodel Generator with Gradle I'm successfully using the following in my build.gradle and it works like a charm:

    buildscript {
        ext {}
        repositories { // maven central & plugins.gradle.org/m2 }
        dependencies {
            // other dependencies, e.g. Spring
            classpath('gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.1')
        }
    
        apply plugin: 'at.comm_unity.gradle.plugins.jpamodelgen'
    
        dependencies {
            compile('org.hibernate:hibernate-jpamodelgen:5.1.0.Final')
        }
    
        jpaModelgen {
            jpaModelgenSourcesDir = "src/main/java"
        }
    
        compileJava.options.compilerArgs += ["-proc:none"]
    }
    

    Within the build task, the static metamodel classes suffixed with '_' are generated. Afterwards they are located in the same directory as my @Entity models are.

提交回复
热议问题