Error:java: Attempt to recreate a file for type {QueryDsl classes}

Answered

I'm trying to upgrade my existing Java 8 multi-project gradle application to Java 11. After fixing a few compilation issues, I ended up getting issues in test cases. When i run a test in Intellij, it throws the following error:

Error:java: Attempt to recreate a file for type {QueryDsl classes}

It is trying to generate the Querydsl classes but since those classes are already there, the test is throwing exception.

I'm using Java11, IntelliJ 2019, Gradle 5 to run the application.

Sub project build.gradle:

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.ltgt.apt'

bootJar {
  baseName = "test"
  version =  "1.0.0"
}

dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa: 2.1.4.RELEASE")
    compile("com.querydsl:querydsl-core:4.1.3")
    compile("com.querydsl:querydsl-jpa:4.1.3")
    annotationProcessor(
          "com.querydsl:querydsl-apt:4.1.3:jpa",
          "javax.annotation:javax.annotation-api:1.3.2"
  )
  annotationProcessor("org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final")

  testCompile("org.springframework.boot:spring-boot-starter-test:2.1.4.RELEASE")
  testCompile("com.h2database:h2:2.1.4.RELEASE")
}


The tests are getting executed successfully in gradle and from command line. I'm getting the error only when i try to execute the test from Intellij.

1

Please sign in to leave a comment.