I updated gradle version from 4.10.1 to 5.2.1, then this error occured.
> Configure project :
deleteFilesWithType Start
deleteFilesWithType End
> Task :initJpaModelgenSourcesDir
> Task :compileJpaModelgen FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJpaModelgen'.
> Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
2 actionable tasks: 2 executed
Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found
Using Gradle >= 5, you can get rid of additional plugins for JPA meta model generation (like at.comm_unity.gradle.plugins.jpamodelgen is one fo those). Key is to use the new annotationProcessor configuration.
As an additional hint, rather than configuring the JavaCompile task (as it is mentioned in the first answer), we are specifying the following in our builds (excerpt):
ext
{
// Directory for generated main Java soures.
generatedMainJava = "${buildDir}/generated/main/java"
}
sourceSets
{
// Add generated sources directory.
main.java.srcDir generatedMainJava
}
compileJava
{
options.compilerArgs += ['-AaddGenerationDate=true'] // Specific to Hibernate JPA meta model generation processor.
options.annotationProcessorGeneratedSourcesDirectory = file(generatedMainJava)
}
Hi, when I use annotationProcessor "org.hibernate:hibernate-jpamodelgen" like your setup I got a weird behavior:
Metamodel files is correctly generated under "${buildDir}/generated/main/java"
Other metamodel files are also generated under "${buildDir}/classes/java/main/.../entity" but seem has different semantic. Noticeably is that the date="2019-04-09T16:54:02.476+0700" is not generated.
So I think something messes with my processor. Could you give me a hint to debug?
Seems that you still have two processors running during your build. Which one (perhaps a plugin?) and when, I don’t know. You need to check your build scripts.
With your code @twwwt I’m getting this error when build:
Task :compileJava
Note: Hibernate JPA 2 Static-Metamodel Generator 5.3.7.Final
An exception has occurred in the compiler (1.8.0_202-release). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.IllegalStateException: endPosTable already set
If you only want to use the annotation processor it is clearly no implementation dependency. You should therefore remove implementation 'org.hibernate:hibernate-jpamodelgen'.
Ok. Solved.
The build.gradle I posted is correct.
I had a problem of basic understanding of gradle (I thought launching a SpringApplication build from Eclipse would always launch gradle tasks too. Wrong!).
Another problem was that I got installed two versions of jdk on my system, and the old one conflicted with gradle
Could not target platform: ‘Java SE 11’ using tool chain: ‘JDK 10 (1.10)’.