Add project property to disable AP discovery in compile classpath
AP discovery in compile classpath can be disabled in all subprojects
by adding "kapt.include.compile.classpath = false" to 'gradle.properties' file.
KT-24530
The setting can be overrided per project by using KAPT DSL
in a 'build.gradle' file:
```
kapt {
includeCompileClasspath = false
}
```
This commit is contained in:
+10
-3
@@ -89,6 +89,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
private val VERBOSE_OPTION_NAME = "kapt.verbose"
|
||||
private val USE_WORKER_API = "kapt.use.worker.api"
|
||||
private val INFO_AS_WARNINGS = "kapt.info.as.warnings"
|
||||
private val INCLUDE_COMPILE_CLASSPATH = "kapt.include.compile.classpath"
|
||||
|
||||
const val KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME = "kotlinKaptWorkerDependencies"
|
||||
|
||||
@@ -122,6 +123,9 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
return hasProperty(INFO_AS_WARNINGS) && property(INFO_AS_WARNINGS) == "true"
|
||||
}
|
||||
|
||||
fun includeCompileClasspath(project: Project): Boolean? =
|
||||
project.findProperty(INCLUDE_COMPILE_CLASSPATH)?.run { toString().toBoolean() }
|
||||
|
||||
fun findMainKaptConfiguration(project: Project) = project.findKaptConfiguration(SourceSet.MAIN_SOURCE_SET_NAME)
|
||||
|
||||
fun createAptConfigurationIfNeeded(project: Project, sourceSetName: String): Configuration {
|
||||
@@ -172,6 +176,10 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
val sourcesOutputDir = getKaptGeneratedSourcesDir(project, sourceSetName)
|
||||
val kotlinSourcesOutputDir = getKaptGeneratedKotlinSourcesDir(project, sourceSetName)
|
||||
val classesOutputDir = getKaptGeneratedClassesDir(project, sourceSetName)
|
||||
val includeCompileClasspath =
|
||||
kaptExtension.includeCompileClasspath
|
||||
?: Kapt3KotlinGradleSubplugin.includeCompileClasspath(project)
|
||||
?: true
|
||||
}
|
||||
|
||||
override fun apply(
|
||||
@@ -266,7 +274,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
|
||||
pluginOptions += SubpluginOption("javacArguments", encodeList(kaptExtension.getJavacOptions()))
|
||||
|
||||
pluginOptions += SubpluginOption("includeCompileClasspath", kaptExtension.includeCompileClasspath.toString())
|
||||
pluginOptions += SubpluginOption("includeCompileClasspath", includeCompileClasspath.toString())
|
||||
|
||||
addMiscOptions(pluginOptions)
|
||||
|
||||
@@ -367,6 +375,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
kaptTask.destinationDir = sourcesOutputDir
|
||||
kaptTask.kotlinSourcesDestinationDir = kotlinSourcesOutputDir
|
||||
kaptTask.classesDir = classesOutputDir
|
||||
kaptTask.includeCompileClasspath = includeCompileClasspath
|
||||
|
||||
kotlinCompilation?.run {
|
||||
output.apply {
|
||||
@@ -392,8 +401,6 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
kaptTask.annotationProcessorOptionProviders.add(it)
|
||||
}
|
||||
|
||||
kaptTask.includeCompileClasspath = kaptExtension.includeCompileClasspath
|
||||
|
||||
if (kaptTask is KaptWithKotlincTask) {
|
||||
buildAndAddOptionsTo(kaptTask, kaptTask.pluginOptions, aptMode = "apt")
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ open class KaptExtension {
|
||||
|
||||
open var detectMemoryLeaks: String = "default"
|
||||
|
||||
open var includeCompileClasspath: Boolean = true
|
||||
open var includeCompileClasspath: Boolean? = null
|
||||
|
||||
@Deprecated("Use `annotationProcessor()` and `annotationProcessors()` instead")
|
||||
open var processors: String = ""
|
||||
|
||||
Reference in New Issue
Block a user