Kapt: Add flag to keep KDoc comments in stubs
Currently, KaptGenerateStubsTask may not generate KDoc comments correctly. See KT-43593 for more details. This commit provides a Kapt flag called `kapt.keep.kdoc.comments.in.stubs` to control whether KDoc comments will be included in the generated stubs. This flag is currently enabled by default to keep the existing behavior and avoid breaking existing users. Users who don't need KDoc comments in stubs but are hitting KT-43593 can disable the flag. Whether this flag will be disabled by default later is to be determined. Bug: https://youtrack.jetbrains.com/issue/KT-43593 (Note that this commit only provides a workaround, it doesn't actually fix the bug.) Test: (Ir)ClassFileToSourceStubConverterTestGenerated#testCommentsRemoved
This commit is contained in:
committed by
nataliya.valtman
parent
dcda47b502
commit
e2521718dd
+6
@@ -79,6 +79,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
private val INFO_AS_WARNINGS = "kapt.info.as.warnings"
|
||||
private val INCLUDE_COMPILE_CLASSPATH = "kapt.include.compile.classpath"
|
||||
private val INCREMENTAL_APT = "kapt.incremental.apt"
|
||||
private val KAPT_KEEP_KDOC_COMMENTS_IN_STUBS = "kapt.keep.kdoc.comments.in.stubs"
|
||||
|
||||
const val KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME = "kotlinKaptWorkerDependencies"
|
||||
|
||||
@@ -119,6 +120,10 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
fun includeCompileClasspath(project: Project): Boolean? =
|
||||
project.findProperty(INCLUDE_COMPILE_CLASSPATH)?.run { toString().toBoolean() }
|
||||
|
||||
fun Project.isKaptKeepKdocCommentsInStubs(): Boolean {
|
||||
return !(hasProperty(KAPT_KEEP_KDOC_COMMENTS_IN_STUBS) && property(KAPT_KEEP_KDOC_COMMENTS_IN_STUBS) == "false")
|
||||
}
|
||||
|
||||
fun findMainKaptConfiguration(project: Project) = project.findKaptConfiguration(SourceSet.MAIN_SOURCE_SET_NAME)
|
||||
|
||||
fun createAptConfigurationIfNeeded(project: Project, sourceSetName: String): Configuration {
|
||||
@@ -392,6 +397,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
pluginOptions += SubpluginOption("mapDiagnosticLocations", "${kaptExtension.mapDiagnosticLocations}")
|
||||
pluginOptions += SubpluginOption("strictMode", "${kaptExtension.strictMode}")
|
||||
pluginOptions += SubpluginOption("stripMetadata", "${kaptExtension.stripMetadata}")
|
||||
pluginOptions += SubpluginOption("keepKdocCommentsInStubs", "${project.isKaptKeepKdocCommentsInStubs()}")
|
||||
pluginOptions += SubpluginOption("showProcessorTimings", "${kaptExtension.showProcessorTimings}")
|
||||
pluginOptions += SubpluginOption("detectMemoryLeaks", kaptExtension.detectMemoryLeaks)
|
||||
pluginOptions += SubpluginOption("infoAsWarnings", "${project.isInfoAsWarnings()}")
|
||||
|
||||
Reference in New Issue
Block a user