KT-33028, KT-33050: Fix how kapt invokes javac on JDK 9+
This commit fixes KT-33028 by not setting empty boot classpath when running on JDK9+. When compiling with -source 8 and below, this allows classes from java.base module to be available in the boot classpath. This commit also fixes KT-33050 by passing the source level of Java compile task in the KAPT javac options. This is important as some annotation processors are using ProcessingEnvironment.getSourceVersion() in order to decide what code to generate. Test: Kapt3IT test added for worker and non-worker invocations
This commit is contained in:
committed by
Yan Zhulanow
parent
5846db4eab
commit
f3acd8d10c
+31
-12
@@ -69,28 +69,30 @@ class Kapt3WorkersIT : Kapt3IT() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun testSimpleWithCustomJdk(gradleVersion: String, javaHome: File, jdkDescription: String) {
|
||||
val gradleVersionRequired = GradleVersionRequired.AtLeast(gradleVersion)
|
||||
|
||||
Assume.assumeTrue("$jdkDescription isn't available", javaHome.isDirectory)
|
||||
@Test
|
||||
fun testSimpleWithJdk10() {
|
||||
val javaHome = File(System.getProperty("jdk10Home")!!)
|
||||
Assume.assumeTrue("JDK 10 isn't available", javaHome.isDirectory)
|
||||
val options = defaultBuildOptions().copy(javaHome = javaHome)
|
||||
|
||||
val project =
|
||||
Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = gradleVersionRequired)
|
||||
val project = Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = GradleVersionRequired.AtLeast("4.7"))
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
assertKaptSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSimpleWithJdk10() {
|
||||
testSimpleWithCustomJdk("4.7", File(System.getProperty("jdk10Home")!!), "JDK 10")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSimpleWithJdk11() {
|
||||
testSimpleWithCustomJdk("5.0", File(System.getProperty("jdk11Home")!!), "JDK 11")
|
||||
val javaHome = File(System.getProperty("jdk11Home")!!)
|
||||
Assume.assumeTrue("JDK 11 isn't available", javaHome.isDirectory)
|
||||
val options = defaultBuildOptions().copy(javaHome = javaHome)
|
||||
|
||||
val project = Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = GradleVersionRequired.AtLeast("5.0"))
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
assertKaptSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,4 +643,21 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
assertTasksSkipped(":compileJava")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSimpleWithJdk11AndSourceLevel8() {
|
||||
val javaHome = File(System.getProperty("jdk11Home")!!)
|
||||
Assume.assumeTrue("JDK 11 isn't available", javaHome.isDirectory)
|
||||
val options = defaultBuildOptions().copy(javaHome = javaHome)
|
||||
|
||||
val project = Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = GradleVersionRequired.AtLeast("5.0")).also {
|
||||
it.setupWorkingDir()
|
||||
it.gradleBuildScript().appendText("\nsourceCompatibility = '8'")
|
||||
}
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
assertKaptSuccessful()
|
||||
assertContains("Javac options: {-source=1.8}")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user