The package Hibernate-Jpamodelgen
is an annotation processor / code generator that operates on JPA @Entity classes. It is often needed in applications that use JPA Criterion Queries.
Gradle provides an "incremental compilation" mode, but plugins have to be updated to support this mode. As of version 5.4.2.Final, JpaModelGen has not been updated to provide that support, meaning that any time the :compile task is executed, all source files in the project are re-compiled.
All of our @Entity classes are in a single package, 5 levels below the root directory.
We are seeking a way to partition the application such that the @Entities are correctly scanned by JpaModelGen, but the rest of the application is still able to support incremental compilation/build.
Environment:
------------------------------------------------------------
Gradle 5.4
------------------------------------------------------------
Build time: 2019-04-16 02:44:16 UTC
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.1 (Oracle Corporation 11.0.1+13)
OS: Windows 10 10.0 amd64
gradle.build file excepts:
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:2.1.4.RELEASE"
compileOnly "org.hibernate:hibernate-jpamodelgen:5.4.2.Final"
testCompileOnly "org.hibernate:hibernate-jpamodelgen:5.4.2.Final"
gradle --info classes
output excerpt:
Full recompilation is required because org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor is not incremental.
update: we are becoming more pessimistic that such a partition will be successful for our application, as entities refer to objects outside our model package so they cannot be compiled , and code cannot be generated without access to the rest of the application classes.
ultimately the solution appears to be updating the jpa model generator to support gradle incremental mode.