title: Spring Boot Test not working with Java 11
body: <p>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:</p>
  
  <p><strong>Error:java: Attempt to recreate a file for type {QueryDsl classes}</strong></p>
  
  <p>It is trying to generate the Querydsl classes but since those classes are already there, the test is throwing exception.</p>
  
  <p>I'm using Java11, IntelliJ 2019, Gradle 5 to run the application.</p>
  
  <p>These tests are working as expected in Java8.</p>
  
  <p>I've no idea what is causing this error. Can anybody please help me in understanding this.</p>
  
  <p>Code snippets are given below.</p>
  
  <p>Root project build.gradle:</p>
  
  <pre><code>buildscript {
    repositories {
      maven {
        url "https://plugins.gradle.org/m2/"
      }
       mavenCentral()
    }
    dependencies {
      classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE)
      classpath("net.ltgt.gradle:gradle-apt-plugin:0.21")
    }
  }
  subprojects {
  
    apply plugin: 'java'
  
    repositories {
      mavenCentral()
    }
  
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
  
    task allDependencies(type: DependencyReportTask) {}
  
    jar {
      baseName = "${parent.name}-${project.name}"
    }
  
    sourceSets {
      main {
        java {
          srcDirs 'src/main/java', 'build/generated/sources/main/java', 'build/generated/sources/annotationProcessor/java/main'
        }
      }
    }
  }
  
  
  </code></pre>
  
  <p>Sub-project build.gradle:</p>
  
  <pre><code>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")
  }
  
  </code></pre>
  
  <p>Integration test</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest(classes = MainClass.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  public class ServiceImplTest {
  
    @Autowired
    private Service1Impl service;
  
    @Test
    public void getData() {
      Data data = service.getData();
      Assert.assertEquals(0, data.size());
    }
  }
  </code></pre>