I have a multiproject and some of my subprojects uses JPA over Querydsl. To do that, at compile time we need to generate the querydsl classes (Q) using APT
I tried with and without the gradle-apt-plugin. During compile time I got the following error
Caused by: java.lang.NoClassDefFoundError: javax/persistence/Entity
at com.querydsl.apt.jpa.JPAAnnotationProcessor.createConfiguration(JPAAnnotationProcessor.java:37)
at com.querydsl.apt.AbstractQuerydslProcessor.process(AbstractQuerydslProcessor.java:79)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
I have the following build.gradle for my subproject
Looks like the queryDsl processor depends on javax.persistence, but doesn’t declare a dependency on it. To work around, you’ll have to manually add it to the annotationProcessor configuration. Consider opening a bug for queryDsl. They should add a dependency on it so it automatically brings it in for processing.
Note that the processor path (used for loading annotation processors and compiler plugins) and the compile classpath (what your code is allowed to link against) are two separate and different things. Dependencies on one are not visible to the other.
I am facing the similar issue like this only. The issue I am facing:
What went wrong:
Execution failed for task ‘:generateQueryDSL’.
Annotation processor ‘com.querydsl.apt.jpa.JPAAnnotationProcessor’ not found
Can you please help me out how to manually add the annotation processor configuration. I am using querydsl 4.1.4 version. already adding the JAVAX Persistence.
I don’t have a new task dedicated to querydsl generation
I’m relying to the annotationProcessor scope (i’m currently using kotlin kapt but using the java annotationProcessor is OK too)