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 (i.e "-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
In case of IDE Eclipse 1. goto Project->Properties->Java Compiler->Annotation Processing and enable it. 2. Expand Annotation Processing->Factory Path-> Add External Jar add Hibernate JPA 2 Metamodel Generator jar check the newly added jar and say OK.
JPA (Java persistence API) metamodel classes are classes that describe the structure of JPA entity classes (classes used to store database state as Java objects). They enable you to write Java code for creating database queries in a typesafe way.
An annotation processor is a class which extends AbstractProcessor (in the package javax. annotation. processing ) providing the functionality needed to generate whatever it needs to generate, such as classes in the case of mapstruct.
Hibernate Static Metamodel Generator is an annotation processor based on JSR_269 with the task of creating JPA 2 static metamodel classes. The following example shows two JPA 2 entities Order and Item , together with the metamodel class Order_ and a typesafe query.
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']
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With