From f89885224ef724ebc9cf57ffdf3bf6205ecb5ed5 Mon Sep 17 00:00:00 2001 From: Ivan Gavrilovic Date: Mon, 23 Sep 2019 16:50:23 +0100 Subject: [PATCH] Add tests for running incremental KAPT on JDK9 Add test for aggregating incremental annotation processors and JDK9. This makes sure the implementation is not using any types that have been removed in JDK 9. --- .../build.gradle.kts | 1 + .../KaptIncrementalWithAggregatingApt.kt | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index 9ce9168fabc..fc2a97da3b3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -118,6 +118,7 @@ tasks.withType { systemProperty("kotlinVersion", rootProject.extra["kotlinVersion"] as String) systemProperty("runnerGradleVersion", gradle.gradleVersion) + systemProperty("jdk9Home", rootProject.extra["JDK_9"] as String) systemProperty("jdk10Home", rootProject.extra["JDK_10"] as String) systemProperty("jdk11Home", rootProject.extra["JDK_11"] as String) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KaptIncrementalWithAggregatingApt.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KaptIncrementalWithAggregatingApt.kt index 832129a8422..beea7dc933e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KaptIncrementalWithAggregatingApt.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KaptIncrementalWithAggregatingApt.kt @@ -8,7 +8,9 @@ package org.jetbrains.kotlin.gradle import org.jetbrains.kotlin.gradle.util.modify import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue +import org.junit.Assume import org.junit.Test +import java.io.File import kotlin.test.assertFalse class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() { @@ -73,6 +75,32 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() { } } + @Test + fun testIncrementalChangesWithJdk9() { + val javaHome = File(System.getProperty("jdk9Home")!!) + Assume.assumeTrue("JDK 9 isn't available", javaHome.isDirectory) + val options = defaultBuildOptions().copy(javaHome = javaHome) + val project = getProject() + + project.build("clean", "build", options = options) { + assertSuccessful() + } + + project.projectFile("useB.kt").modify { current -> "$current\nfun otherFunction() {}" } + project.build("build", options = options) { + assertSuccessful() + + assertEquals( + setOf( + fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath, + fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/B.java").canonicalPath, + fileInWorkingDir("build/tmp/kapt3/stubs/main/baz/UtilKt.java").canonicalPath, + fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath + ), getProcessedSources(output) + ) + } + } + @Test fun testClasspathChanges() { val project = Project(