K2 kapt: add kapt.use.k2 Gradle property
... and `-Kapt-use-k2` CLI flag to enable K2 kapt. #KT-61114 Fixed
This commit is contained in:
committed by
Space Team
parent
059046a2b1
commit
761221904c
@@ -107,6 +107,7 @@ private fun transformKaptToolArgs(args: List<String>, messageCollector: MessageC
|
||||
}
|
||||
KaptCliOption.APT_MODE_OPTION -> aptModePassed = true
|
||||
KaptCliOption.VERBOSE_MODE_OPTION -> kaptVerboseModePassed = true
|
||||
KaptCliOption.USE_K2 -> transformed.add("-Xuse-kapt4")
|
||||
else -> {}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,6 +221,13 @@ enum class KaptCliOption(
|
||||
cliToolOption = CliToolOption("-Kapt-use-jvm-ir", FLAG)
|
||||
),
|
||||
|
||||
USE_K2(
|
||||
"useK2",
|
||||
"true | false",
|
||||
"Use K2",
|
||||
cliToolOption = CliToolOption("-Kapt-use-k2", FLAG)
|
||||
),
|
||||
|
||||
DETECT_MEMORY_LEAKS_OPTION("detectMemoryLeaks", "true | false", "Detect memory leaks in annotation processors"),
|
||||
INCLUDE_COMPILE_CLASSPATH(
|
||||
"includeCompileClasspath",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# kapt
|
||||
-language-version 2.0
|
||||
-Xsuppress-version-warnings
|
||||
-Kapt-use-k2=true
|
||||
-Kapt-mode=compile
|
||||
../simple/Test.kt
|
||||
|
||||
# after
|
||||
Return code: 1
|
||||
|
||||
error: [kapt] KAPT "compile" mode is not supported in Kotlin 2.x. Run kapt with -Kapt-mode=stubsAndApt and use kotlinc for the final compilation step.
|
||||
+6
@@ -48,6 +48,12 @@ public class Kapt4ToolIntegrationTestGenerated extends AbstractKapt4ToolIntegrat
|
||||
runTest("plugins/kapt3/kapt3-cli/testData/integration-kapt4/defaultPackage/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kaptUseK2Flag")
|
||||
public void testKaptUseK2Flag() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-cli/testData/integration-kapt4/kaptUseK2Flag/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinFileGeneration")
|
||||
public void testKotlinFileGeneration() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user