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
@@ -94,9 +94,11 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
|
||||
|
||||
put(Option.PROC, "only") // Only process annotations
|
||||
|
||||
if (!withJdk) {
|
||||
@Suppress("SpellCheckingInspection")
|
||||
putJavacOption("BOOTCLASSPATH", "BOOT_CLASS_PATH", "") // No boot classpath
|
||||
if (!withJdk && !isJava9OrLater()) {
|
||||
// No boot classpath for JDK 8 and below. When running on JDK9+ and specifying source level 8 and below,
|
||||
// boot classpath is not set to empty. This is to allow types to be resolved using boot classpath which defaults to
|
||||
// classes defined in java.base module. See https://youtrack.jetbrains.com/issue/KT-33028 for details.
|
||||
put(Option.valueOf("BOOTCLASSPATH"), "")
|
||||
}
|
||||
|
||||
if (isJava9OrLater()) {
|
||||
|
||||
Reference in New Issue
Block a user