简体   繁体   中英

How to generate JPA Metamodel with Gradle 5.x

I am currently trying to upgrade from gradle 4.8.1 to 5.1.1 but fail with generating the hibernate metamodel for our code.

The problem is that gradle 5 ignores the annotation processor passed with the compile classpath, but all plugins I found are using this (ie "-proc:only" ).

I tried to specify the annotation processor explicitly as pointed out by gradle ( https://docs.gradle.org/4.6/release-notes.html#convenient-declaration-of-annotation-processor-dependencies ) annotationProcessor 'org.hibernate:hibernate-jpamodelgen'

But this does not help and I still get the following error:

warning: Annotation processing without compilation requested but no processors were found.

Maybe also the plugins need to be updated, but as I said all plugins which I found are passing the annotation processor with the classpath. We are currently using this one: https://github.com/Catalysts/cat-gradle-plugins/tree/master/cat-gradle-hibernate-plugin

you can just remove the plugin for the jpa modelgen and just use

annotationProcessor('org.hibernate:hibernate-jpamodelgen:<version>')

Addtionally i use those settings to configure where the generated code should live.

tasks.withType(JavaCompile) {
  options.annotationProcessorGeneratedSourcesDirectory = file("src/generated/java")
}


sourceSets {
    generated {
        java {
            srcDirs = ['src/generated/java']
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM