问题
Gradle version: 5.1
Java version: 11
I have the following task defined in gradle
file to generate QueryDSL
classes:
task generateQClasses (type: JavaCompile) {
source = sourceSets.main.java.srcDirs
classpath = sourceSets.main.compileClasspath
destinationDir = file('src/main/java')
options.annotationProcessorPath = configurations.annotationProcessor
options.compilerArgs = ['-proc:only', '-processor', 'com.querydsl.apt.jpa.JPAAnnotationProcessor', '-Aquerydsl.packageSuffix=.querydsl']
}
Below is my dependencies block:
annotationProcessor "com.querydsl:querydsl-apt:4.2.1:jpa"
annotationProcessor "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final"
annotationProcessor "javax.annotation:javax.annotation-api:1.3.2"
If I execute `gradlew generateQClasses, I see the following in the logs:
Attempt to recreate a file for type foo.bar.QClass
error: Attempt to recreate a file for type foo.bar.QClass
It fails with error saying the file already exists. How can I configure this task to overwrite the files if they exist?
Also, the above config is the config for the root project and it has 5 subprojects. AnnotationProcessor
is able to overwrite the files in one of the sub project but not the others (all the subprojects have the same config). Am I missing anything?
来源:https://stackoverflow.com/questions/62320937/gradle-unable-to-generate-querydsl-classes