Remove 'kapt.user.worker.api' property
Now Kapt is always run via Gradle workers. ^KT-48827 Fixed
This commit is contained in:
+1
-1
@@ -118,7 +118,7 @@ open class KotlinAndroid36GradleIT : KotlinAndroid3GradleIT() {
|
||||
|
||||
build(
|
||||
":Android:kaptFlavor1DebugKotlin", "--dry-run",
|
||||
options = defaultBuildOptions().copy(kaptOptions = KaptOptions(verbose = false, useWorkers = false))
|
||||
options = defaultBuildOptions().copy(kaptOptions = KaptOptions(verbose = false))
|
||||
) {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
-2
@@ -287,7 +287,6 @@ abstract class BaseGradleIT {
|
||||
|
||||
data class KaptOptions(
|
||||
val verbose: Boolean,
|
||||
val useWorkers: Boolean,
|
||||
val incrementalKapt: Boolean = false,
|
||||
val includeCompileClasspath: Boolean = true,
|
||||
val classLoadersCacheSize: Int? = null
|
||||
@@ -897,7 +896,6 @@ Finished executing task ':$taskName'|
|
||||
|
||||
options.kaptOptions?.also { kaptOptions ->
|
||||
add("-Pkapt.verbose=${kaptOptions.verbose}")
|
||||
add("-Pkapt.use.worker.api=${kaptOptions.useWorkers}")
|
||||
add("-Pkapt.incremental.apt=${kaptOptions.incrementalKapt}")
|
||||
add("-Pkapt.include.compile.classpath=${kaptOptions.includeCompileClasspath}")
|
||||
kaptOptions.classLoadersCacheSize?.also { cacheSize ->
|
||||
|
||||
-1
@@ -383,7 +383,6 @@ class BuildCacheRelocationIT : KGPBaseTest() {
|
||||
val options = defaultBuildOptions.copy(
|
||||
kaptOptions = BuildOptions.KaptOptions(
|
||||
verbose = true,
|
||||
useWorkers = false,
|
||||
incrementalKapt = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
|
||||
-1
@@ -143,7 +143,6 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
|
||||
incremental = true,
|
||||
kaptOptions = BuildOptions.KaptOptions(
|
||||
verbose = true,
|
||||
useWorkers = true,
|
||||
incrementalKapt = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
|
||||
-1
@@ -20,7 +20,6 @@ class Kapt3AndGradleDaemon : KGPDaemonsBaseTest() {
|
||||
.copy(
|
||||
kaptOptions = BuildOptions.KaptOptions(
|
||||
verbose = true,
|
||||
useWorkers = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
)
|
||||
|
||||
+2
-7
@@ -11,11 +11,6 @@ import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class Kapt3WorkersAndroid36IT : Kapt3Android36IT() {
|
||||
override fun kaptOptions(): KaptOptions =
|
||||
super.kaptOptions().copy(useWorkers = true)
|
||||
}
|
||||
|
||||
open class Kapt3Android36IT : Kapt3AndroidIT() {
|
||||
override val androidGradlePluginVersion: AGPVersion
|
||||
get() = AGPVersion.v3_6_0
|
||||
@@ -142,7 +137,7 @@ class Kapt3Android42IT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
private fun kaptOptions(): KaptOptions =
|
||||
KaptOptions(verbose = true, useWorkers = false)
|
||||
KaptOptions(verbose = true)
|
||||
|
||||
private fun CompiledProject.assertKaptSuccessful() {
|
||||
KAPT_SUCCESSFUL_REGEX.findAll(this.output).count() > 0
|
||||
@@ -174,7 +169,7 @@ abstract class Kapt3AndroidIT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
protected open fun kaptOptions(): KaptOptions =
|
||||
KaptOptions(verbose = true, useWorkers = false)
|
||||
KaptOptions(verbose = true)
|
||||
|
||||
fun CompiledProject.assertKaptSuccessful() {
|
||||
KAPT_SUCCESSFUL_REGEX.findAll(this.output).count() > 0
|
||||
|
||||
+45
-53
@@ -51,7 +51,6 @@ abstract class Kapt3BaseIT : KGPBaseTest() {
|
||||
|
||||
protected open fun kaptOptions(): BuildOptions.KaptOptions = BuildOptions.KaptOptions(
|
||||
verbose = true,
|
||||
useWorkers = false
|
||||
)
|
||||
|
||||
fun BuildResult.assertKaptSuccessful() {
|
||||
@@ -68,11 +67,52 @@ abstract class Kapt3BaseIT : KGPBaseTest() {
|
||||
protected val String.withPrefix get() = "kapt2/$this"
|
||||
}
|
||||
|
||||
@DisplayName("Kapt executing via workers")
|
||||
open class Kapt3WorkersIT : Kapt3IT() {
|
||||
override fun kaptOptions(): BuildOptions.KaptOptions =
|
||||
super.kaptOptions().copy(useWorkers = true)
|
||||
@DisplayName("Kapt with classloaders cache")
|
||||
class Kapt3ClassLoadersCacheIT : Kapt3IT() {
|
||||
override fun kaptOptions(): BuildOptions.KaptOptions = super.kaptOptions().copy(
|
||||
classLoadersCacheSize = 10,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
|
||||
@Disabled("classloaders cache is incompatible with AP discovery in classpath")
|
||||
override fun testDisableDiscoveryInCompileClasspath(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
@Disabled("classloaders cache is leaking file descriptors that prevents cleaning test project")
|
||||
override fun testChangesInLocalAnnotationProcessor(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
@Disabled("classloaders cache is leaking file descriptors that prevents cleaning test project")
|
||||
override fun testKt19179andKt37241(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
@Disabled("classloaders cache is leaking file descriptors that prevents cleaning test project")
|
||||
override fun testChangesToKaptConfigurationDoNotTriggerStubGeneration(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
override fun testAnnotationProcessorAsFqName(gradleVersion: GradleVersion) {
|
||||
project("annotationProcessorAsFqName".withPrefix, gradleVersion) {
|
||||
//classloaders caching is not compatible with includeCompileClasspath
|
||||
buildGradle.modify {
|
||||
it.addBeforeSubstring(
|
||||
"kapt \"org.jetbrains.kotlin:annotation-processor-example:\$kotlin_version\"\n",
|
||||
"implementation \"org.jetbrains.kotlin:annotation-processor-example"
|
||||
)
|
||||
}
|
||||
|
||||
build("build") {
|
||||
assertKaptSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
||||
assertFileInProjectExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
||||
assertFileExists(kotlinClassesDir().resolve("example/TestClass.class"))
|
||||
assertFileExists(javaClassesDir().resolve("example/TestClassGenerated.class"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kapt base checks")
|
||||
open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("Kapt is skipped when no annotation processors are added")
|
||||
@GradleTest
|
||||
fun testKaptSkipped(gradleVersion: GradleVersion) {
|
||||
@@ -188,54 +228,6 @@ open class Kapt3WorkersIT : Kapt3IT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kapt with classloaders cache executing via workers ")
|
||||
class Kapt3ClassLoadersCacheIT : Kapt3WorkersIT() {
|
||||
override fun kaptOptions(): BuildOptions.KaptOptions = super.kaptOptions().copy(
|
||||
classLoadersCacheSize = 10,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
|
||||
@Disabled("classloaders cache is incompatible with AP discovery in classpath")
|
||||
override fun testDisableDiscoveryInCompileClasspath(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
@Disabled("classloaders cache is leaking file descriptors that prevents cleaning test project")
|
||||
override fun testChangesInLocalAnnotationProcessor(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
@Disabled("classloaders cache is leaking file descriptors that prevents cleaning test project")
|
||||
override fun testKt19179andKt37241(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
@Disabled("classloaders cache is leaking file descriptors that prevents cleaning test project")
|
||||
override fun testChangesToKaptConfigurationDoNotTriggerStubGeneration(gradleVersion: GradleVersion) {
|
||||
}
|
||||
|
||||
override fun testAnnotationProcessorAsFqName(gradleVersion: GradleVersion) {
|
||||
project("annotationProcessorAsFqName".withPrefix, gradleVersion) {
|
||||
//classloaders caching is not compatible with includeCompileClasspath
|
||||
buildGradle.modify {
|
||||
it.addBeforeSubstring(
|
||||
"kapt \"org.jetbrains.kotlin:annotation-processor-example:\$kotlin_version\"\n",
|
||||
"implementation \"org.jetbrains.kotlin:annotation-processor-example"
|
||||
)
|
||||
}
|
||||
|
||||
build("build") {
|
||||
assertKaptSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
||||
assertFileInProjectExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
||||
assertFileExists(kotlinClassesDir().resolve("example/TestClass.class"))
|
||||
assertFileExists(javaClassesDir().resolve("example/TestClassGenerated.class"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kapt without workers")
|
||||
open class Kapt3IT : Kapt3BaseIT() {
|
||||
|
||||
@DisplayName("Should find annotation processor via FQName")
|
||||
@GradleTest
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
incremental = true,
|
||||
kaptOptions = super.defaultBuildOptions.kaptOptions!!.copy(
|
||||
verbose = true,
|
||||
useWorkers = true,
|
||||
incrementalKapt = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
|
||||
-1
@@ -30,7 +30,6 @@ class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
||||
incremental = true,
|
||||
kaptOptions = super.defaultBuildOptions.kaptOptions!!.copy(
|
||||
verbose = true,
|
||||
useWorkers = true,
|
||||
incrementalKapt = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
|
||||
-2
@@ -40,7 +40,6 @@ data class BuildOptions(
|
||||
) {
|
||||
data class KaptOptions(
|
||||
val verbose: Boolean = false,
|
||||
val useWorkers: Boolean = false,
|
||||
val incrementalKapt: Boolean = false,
|
||||
val includeCompileClasspath: Boolean = false,
|
||||
val classLoadersCacheSize: Int? = null
|
||||
@@ -102,7 +101,6 @@ data class BuildOptions(
|
||||
|
||||
if (kaptOptions != null) {
|
||||
arguments.add("-Pkapt.verbose=${kaptOptions.verbose}")
|
||||
arguments.add("-Pkapt.use.worker.api=${kaptOptions.useWorkers}")
|
||||
arguments.add("-Pkapt.incremental.apt=${kaptOptions.incrementalKapt}")
|
||||
arguments.add("-Pkapt.include.compile.classpath=${kaptOptions.includeCompileClasspath}")
|
||||
kaptOptions.classLoadersCacheSize?.let { cacheSize ->
|
||||
|
||||
+6
-60
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.gradle.tasks.configuration.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild
|
||||
import org.jetbrains.kotlin.gradle.utils.isParentOf
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.ObjectOutputStream
|
||||
@@ -93,17 +92,6 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
return getBooleanOptionValue(BooleanOption.KAPT_VERBOSE)
|
||||
}
|
||||
|
||||
fun Project.isUseWorkerApi(): Boolean {
|
||||
return getBooleanOptionValue(BooleanOption.KAPT_USE_WORKER_API) {
|
||||
"""
|
||||
|Warning: '${BooleanOption.KAPT_USE_WORKER_API.optionName}' is deprecated and scheduled to be removed in Kotlin 1.8 release.
|
||||
|
|
||||
|By default Kapt plugin is using Gradle workers to run annotation processing. Running annotation processing
|
||||
|directly in the Kotlin compiler is deprecated.
|
||||
""".trimMargin()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.isIncrementalKapt(): Boolean {
|
||||
return getBooleanOptionValue(BooleanOption.KAPT_INCREMENTAL_APT)
|
||||
}
|
||||
@@ -214,10 +202,6 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
val defaultValue: Boolean
|
||||
) {
|
||||
KAPT_VERBOSE("kapt.verbose", false),
|
||||
KAPT_USE_WORKER_API(
|
||||
"kapt.use.worker.api", // Currently doesn't have a matching KaptFlag
|
||||
true
|
||||
),
|
||||
KAPT_INCREMENTAL_APT(
|
||||
"kapt.incremental.apt",
|
||||
true // Currently doesn't match the default value of KaptFlag.INCREMENTAL_APT, but it's fine (see https://github.com/JetBrains/kotlin/pull/3942#discussion_r532578690).
|
||||
@@ -302,7 +286,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
)
|
||||
|
||||
val kaptGenerateStubsTaskProvider: TaskProvider<KaptGenerateStubsTask> = context.createKaptGenerateStubsTask()
|
||||
val kaptTaskProvider: TaskProvider<out KaptTask> = context.createKaptKotlinTask(useWorkerApi = project.isUseWorkerApi())
|
||||
val kaptTaskProvider: TaskProvider<out KaptTask> = context.createKaptKotlinTask()
|
||||
|
||||
kaptGenerateStubsTaskProvider.configure { kaptGenerateStubsTask ->
|
||||
kaptGenerateStubsTask.dependsOn(*buildDependencies.toTypedArray())
|
||||
@@ -333,25 +317,6 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
return project.provider { emptyList<SubpluginOption>() }
|
||||
}
|
||||
|
||||
// This method should be called no more than once for each Kapt3SubpluginContext
|
||||
private fun Kapt3SubpluginContext.buildOptionsForAptMode(
|
||||
javacOptions: Provider<Map<String, String>>
|
||||
): Provider<List<SubpluginOption>> {
|
||||
return project.provider {
|
||||
buildKaptSubpluginOptions(
|
||||
kaptExtension,
|
||||
project,
|
||||
javacOptions.get(),
|
||||
"apt",
|
||||
generatedSourcesDir = listOf(sourcesOutputDir),
|
||||
generatedClassesDir = listOf(getKaptGeneratedClassesDir(project, sourceSetName)),
|
||||
incrementalDataDir = listOf(getKaptIncrementalDataDir()),
|
||||
includeCompileClasspath = includeCompileClasspath,
|
||||
kaptStubsDir = listOf(getKaptStubsDir())
|
||||
) + getAPOptions().get() // apOptions are needed only for "apt" mode
|
||||
}
|
||||
}
|
||||
|
||||
private fun Kapt3SubpluginContext.getAPOptions(): Provider<CompositeSubpluginOption> = project.provider {
|
||||
val androidVariantData = KaptWithAndroid.androidVariantData(this)
|
||||
|
||||
@@ -395,15 +360,9 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
).get()
|
||||
}
|
||||
|
||||
private fun Kapt3SubpluginContext.createKaptKotlinTask(useWorkerApi: Boolean): TaskProvider<out KaptTask> {
|
||||
val taskClass = if (useWorkerApi) KaptWithoutKotlincTask::class.java else KaptWithKotlincTask::class.java
|
||||
private fun Kapt3SubpluginContext.createKaptKotlinTask(): TaskProvider<out KaptTask> {
|
||||
val taskName = getKaptTaskName("kapt")
|
||||
|
||||
val taskConfigAction = if (taskClass == KaptWithoutKotlincTask::class.java ) {
|
||||
KaptWithoutKotlincConfig(kotlinCompilation.compileKotlinTaskProvider.get() as KotlinCompile, kaptExtension)
|
||||
} else {
|
||||
KaptWithKotlincConfig(kotlinCompilation.compileKotlinTaskProvider.get() as KotlinCompile, kaptExtension)
|
||||
}
|
||||
val taskConfigAction = KaptWithoutKotlincConfig(kotlinCompilation.compileKotlinTaskProvider.get() as KotlinCompile, kaptExtension)
|
||||
|
||||
val kaptClasspathConfiguration = project.configurations.create("kaptClasspath_$taskName")
|
||||
.setExtendsFrom(kaptClasspathConfigurations).also {
|
||||
@@ -451,26 +410,13 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
task.annotationProcessorOptionProviders.add(it)
|
||||
}
|
||||
|
||||
val pluginOptions: Provider<CompilerPluginOptions> = if (taskClass == KaptWithKotlincTask::class.java) {
|
||||
buildOptionsForAptMode(taskConfigAction.getJavaOptions(task.defaultJavaSourceCompatibility))
|
||||
} else {
|
||||
check(taskClass == KaptWithoutKotlincTask::class.java)
|
||||
getDslKaptApOptions()
|
||||
}.toCompilerPluginOptions()
|
||||
val pluginOptions: Provider<CompilerPluginOptions> = getDslKaptApOptions().toCompilerPluginOptions()
|
||||
|
||||
task.kaptPluginOptions.add(pluginOptions)
|
||||
}
|
||||
|
||||
return if (taskClass == KaptWithoutKotlincTask::class.java) {
|
||||
taskConfigAction as KaptWithoutKotlincConfig
|
||||
project.registerTask(taskName, KaptWithoutKotlincTask::class.java, emptyList()).also {
|
||||
taskConfigAction.execute(it)
|
||||
}
|
||||
} else {
|
||||
taskConfigAction as KaptWithKotlincConfig
|
||||
project.registerTask(taskName, KaptWithKotlincTask::class.java, emptyList()).also {
|
||||
taskConfigAction.execute(it)
|
||||
}
|
||||
return project.registerTask(taskName, KaptWithoutKotlincTask::class.java, emptyList()).also {
|
||||
taskConfigAction.execute(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.internal
|
||||
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.work.InputChanges
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.CompilerExecutionSettings
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
||||
import org.jetbrains.kotlin.gradle.internal.kapt.incremental.KaptIncrementalChanges
|
||||
import org.jetbrains.kotlin.gradle.internal.tasks.allOutputFiles
|
||||
import org.jetbrains.kotlin.gradle.logging.GradleKotlinLogger
|
||||
import org.jetbrains.kotlin.gradle.logging.GradlePrintingMessageCollector
|
||||
import org.jetbrains.kotlin.gradle.plugin.CompilerPluginConfig
|
||||
import org.jetbrains.kotlin.gradle.report.ReportingSettings
|
||||
import org.jetbrains.kotlin.gradle.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||
import org.jetbrains.kotlin.gradle.utils.property
|
||||
import org.jetbrains.kotlin.gradle.utils.toPathsArray
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class KaptWithKotlincTask @Inject constructor(
|
||||
objectFactory: ObjectFactory
|
||||
) : KaptTask(objectFactory),
|
||||
CompilerArgumentAwareWithInput<K2JVMCompilerArguments>,
|
||||
CompileUsingKotlinDaemonWithNormalization {
|
||||
|
||||
@get:Classpath
|
||||
abstract val pluginClasspath: ConfigurableFileCollection
|
||||
|
||||
@get:Internal
|
||||
val taskProvider: Provider<GradleCompileTaskProvider> = objectFactory.property(
|
||||
objectFactory.newInstance<GradleCompileTaskProvider>(project.gradle, this, project)
|
||||
)
|
||||
|
||||
/** Used only as task input, actual values come from [compileKotlinArgumentsContributor]. */
|
||||
@get:Nested
|
||||
internal abstract val additionalPluginOptionsAsInputs: ListProperty<CompilerPluginConfig>
|
||||
|
||||
override fun createCompilerArgs(): K2JVMCompilerArguments = K2JVMCompilerArguments()
|
||||
|
||||
abstract override val kotlinDaemonJvmArguments: ListProperty<String>
|
||||
|
||||
@get:Internal
|
||||
internal abstract val compileKotlinArgumentsContributor: Property<CompilerArgumentsContributor<K2JVMCompilerArguments>>
|
||||
|
||||
override fun setupCompilerArgs(args: K2JVMCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
||||
compileKotlinArgumentsContributor.get().contributeArguments(
|
||||
args, compilerArgumentsConfigurationFlags(
|
||||
defaultsOnly,
|
||||
ignoreClasspathResolutionErrors
|
||||
))
|
||||
|
||||
args.pluginClasspaths = pluginClasspath.toPathsArray()
|
||||
val pluginOptionsWithKapt: CompilerPluginOptions = kaptPluginOptions.toSingleCompilerPluginOptions().withWrappedKaptOptions(
|
||||
withApClasspath = kaptClasspath,
|
||||
changedFiles = changedFiles,
|
||||
classpathChanges = classpathChanges,
|
||||
compiledSourcesDir = compiledSources.toList(),
|
||||
processIncrementally = processIncrementally
|
||||
)
|
||||
|
||||
args.pluginOptions = (pluginOptionsWithKapt.arguments + args.pluginOptions!!).toTypedArray()
|
||||
args.verbose = verbose.get()
|
||||
}
|
||||
|
||||
/**
|
||||
* This will be part of the subplugin options that is not part of the input snapshotting, so just initialize it. Actual value is set
|
||||
* in the task action.
|
||||
*/
|
||||
private var changedFiles: List<File> = emptyList()
|
||||
private var classpathChanges: List<String> = emptyList()
|
||||
private var processIncrementally = false
|
||||
|
||||
@get:Internal
|
||||
internal abstract val javaPackagePrefix: Property<String>
|
||||
|
||||
@get:Internal
|
||||
internal abstract val reportingSettings: Property<ReportingSettings>
|
||||
|
||||
@TaskAction
|
||||
fun compile(inputChanges: InputChanges) {
|
||||
logger.debug("Running kapt annotation processing using the Kotlin compiler")
|
||||
checkAnnotationProcessorClasspath()
|
||||
|
||||
val incrementalChanges = getIncrementalChanges(inputChanges)
|
||||
if (incrementalChanges is KaptIncrementalChanges.Known) {
|
||||
changedFiles = incrementalChanges.changedSources.toList()
|
||||
classpathChanges = incrementalChanges.changedClasspathJvmNames.toList()
|
||||
processIncrementally = true
|
||||
}
|
||||
|
||||
val args = prepareCompilerArguments()
|
||||
|
||||
val messageCollector = GradlePrintingMessageCollector(GradleKotlinLogger(logger), args.allWarningsAsErrors)
|
||||
val outputItemCollector = OutputItemsCollectorImpl()
|
||||
val environment = GradleCompilerEnvironment(
|
||||
compilerClasspath.files.toList(), messageCollector, outputItemCollector,
|
||||
reportingSettings = reportingSettings.get(),
|
||||
outputFiles = allOutputFiles()
|
||||
)
|
||||
|
||||
val compilerRunner = GradleCompilerRunner(
|
||||
taskProvider.get(),
|
||||
defaultKotlinJavaToolchain.get().currentJvmJdkToolsJar.orNull,
|
||||
CompilerExecutionSettings(
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
compilerExecutionStrategy.get(),
|
||||
useDaemonFallbackStrategy.get()
|
||||
),
|
||||
metrics.get(),
|
||||
)
|
||||
compilerRunner.runJvmCompilerAsync(
|
||||
sourcesToCompile = source.files.toList(),
|
||||
commonSources = emptyList(),
|
||||
javaPackagePrefix = javaPackagePrefix.orNull,
|
||||
args = args,
|
||||
environment = environment,
|
||||
jdkHome = defaultKotlinJavaToolchain.get().providedJvm.get().javaHome,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
-31
@@ -226,35 +226,4 @@ internal class KaptWithoutKotlincConfig : KaptConfig<KaptWithoutKotlincTask> {
|
||||
}
|
||||
}
|
||||
|
||||
internal class KaptWithKotlincConfig(kotlinCompileTask: KotlinCompile, ext: KaptExtension) :
|
||||
KaptConfig<KaptWithKotlincTask>(kotlinCompileTask, ext) {
|
||||
|
||||
init {
|
||||
configureTask { task ->
|
||||
if (project.isIncrementalKapt()) {
|
||||
val incAptCacheOption = task.incAptCache.locationOnly.map { incAptCacheDir ->
|
||||
CompilerPluginOptions().also {
|
||||
it.addPluginArgument(
|
||||
KAPT_SUBPLUGIN_ID, SubpluginOption("incrementalCache", lazy { incAptCacheDir.asFile.absolutePath })
|
||||
)
|
||||
}
|
||||
}
|
||||
task.kaptPluginOptions.add(incAptCacheOption)
|
||||
}
|
||||
|
||||
task.compilerClasspath.from(providers.provider { kotlinCompileTask.defaultCompilerClasspath })
|
||||
task.pluginClasspath.from(kotlinCompileTask.pluginClasspath)
|
||||
task.additionalPluginOptionsAsInputs.value(kotlinCompileTask.pluginOptions).disallowChanges()
|
||||
task.compileKotlinArgumentsContributor.set(providers.provider { kotlinCompileTask.compilerArgumentsContributor })
|
||||
task.javaPackagePrefix.set(providers.provider { kotlinCompileTask.javaPackagePrefix })
|
||||
task.reportingSettings.set(providers.provider { kotlinCompileTask.reportingSettings() })
|
||||
propertiesProvider.kotlinDaemonJvmArgs?.let {
|
||||
task.kotlinDaemonJvmArguments.value(it.split("\\s+".toRegex())).disallowChanges()
|
||||
}
|
||||
task.compilerExecutionStrategy.convention(propertiesProvider.kotlinCompilerExecutionStrategy).finalizeValueOnRead()
|
||||
task.useDaemonFallbackStrategy.convention(propertiesProvider.kotlinDaemonUseFallbackStrategy).finalizeValueOnRead()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val artifactType = Attribute.of("artifactType", String::class.java)
|
||||
Reference in New Issue
Block a user