Remove 'kotlin.parallel.tasks.in.project' property.
^KT-46406 In Progress
This commit is contained in:
+1
-5
@@ -55,11 +55,7 @@ class WorkersIT : BaseGradleIT() {
|
||||
build("assemble", traceLoading, options = options) {
|
||||
assertSuccessful()
|
||||
val tasks = arrayOf(":compileKotlinMetadata", ":compileKotlinJvm", ":compileKotlinJs")
|
||||
if (isParallel) {
|
||||
assertTasksSubmittedWork(*tasks)
|
||||
} else {
|
||||
assertTasksDidNotSubmitWork(*tasks)
|
||||
}
|
||||
assertTasksSubmittedWork(*tasks)
|
||||
val expectedKotlinOutputFiles = listOf(
|
||||
kotlinClassesDir(sourceSet = "metadata/main") + "common/A.kotlin_metadata",
|
||||
kotlinClassesDir(sourceSet = "jvm/main") + "common/A.class",
|
||||
|
||||
+8
-1
@@ -22,6 +22,7 @@ import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
@@ -34,9 +35,15 @@ import org.jetbrains.kotlin.incremental.classpathAsList
|
||||
import org.jetbrains.kotlin.incremental.destinationAsFile
|
||||
import java.io.File
|
||||
import java.util.concurrent.Callable
|
||||
import javax.inject.Inject
|
||||
|
||||
@CacheableTask
|
||||
abstract class KaptGenerateStubsTask : KotlinCompile(KotlinJvmOptionsImpl()) {
|
||||
abstract class KaptGenerateStubsTask @Inject constructor(
|
||||
workerExecutor: WorkerExecutor
|
||||
): KotlinCompile(
|
||||
KotlinJvmOptionsImpl(),
|
||||
workerExecutor
|
||||
) {
|
||||
|
||||
internal class Configurator(
|
||||
private val kotlinCompileTaskProvider: TaskProvider<KotlinCompile>,
|
||||
|
||||
-23
@@ -165,29 +165,6 @@ internal fun PropertiesProvider.mapKotlinDaemonProperties(task: CompileUsingKotl
|
||||
val ignoreIncorrectNativeDependencies: Boolean?
|
||||
get() = booleanProperty(KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES)
|
||||
|
||||
private val parallelTasksInProjectPropName = "kotlin.parallel.tasks.in.project"
|
||||
|
||||
/**
|
||||
* Enables parallel tasks execution within a project with Workers API.
|
||||
* Does not enable using actual worker proccesses
|
||||
* (Kotlin Daemon can be shared which uses less memory)
|
||||
*/
|
||||
val parallelTasksInProject: Boolean?
|
||||
get() {
|
||||
return if (property(parallelTasksInProjectPropName) != null) {
|
||||
SingleWarningPerBuild.show(
|
||||
project,
|
||||
"""
|
||||
Project property '$parallelTasksInProjectPropName' is deprecated.
|
||||
By default it depends on Gradle parallel project execution option value.
|
||||
""".trimIndent()
|
||||
)
|
||||
booleanProperty(parallelTasksInProjectPropName)
|
||||
} else {
|
||||
return project.gradle.startParameter.isParallelProjectExecutionEnabled
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables individual test task reporting for aggregated test tasks.
|
||||
*
|
||||
|
||||
+8
-2
@@ -15,6 +15,7 @@ import org.gradle.api.logging.Logger
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.work.InputChanges
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
||||
@@ -42,8 +43,13 @@ import javax.inject.Inject
|
||||
|
||||
@CacheableTask
|
||||
abstract class KotlinJsIrLink @Inject constructor(
|
||||
objectFactory: ObjectFactory
|
||||
) : Kotlin2JsCompile(KotlinJsOptionsImpl(), objectFactory) {
|
||||
objectFactory: ObjectFactory,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : Kotlin2JsCompile(
|
||||
KotlinJsOptionsImpl(),
|
||||
objectFactory,
|
||||
workerExecutor
|
||||
) {
|
||||
|
||||
class Configurator(compilation: KotlinCompilationData<*>) : Kotlin2JsCompile.Configurator<KotlinJsIrLink>(compilation) {
|
||||
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.targets.js.ir
|
||||
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.CacheableTask
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers
|
||||
import org.jetbrains.kotlin.gradle.utils.propertyWithConvention
|
||||
import javax.inject.Inject
|
||||
|
||||
@CacheableTask
|
||||
internal abstract class KotlinJsIrLinkWithWorkers
|
||||
@Inject
|
||||
constructor(
|
||||
objectFactory: ObjectFactory,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : KotlinJsIrLink(objectFactory) {
|
||||
override val compilerRunner: Provider<GradleCompilerRunner> =
|
||||
objects.propertyWithConvention(
|
||||
gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
null,
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
) as GradleCompilerRunner
|
||||
}
|
||||
)
|
||||
}
|
||||
+18
-1
@@ -21,8 +21,11 @@ import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.work.InputChanges
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers
|
||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.internal.tasks.allOutputFiles
|
||||
@@ -36,12 +39,14 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinMetadataCompilationData
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.refinesClosure
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.resolveAllDependsOnSourceSets
|
||||
import org.jetbrains.kotlin.gradle.utils.propertyWithConvention
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@CacheableTask
|
||||
abstract class KotlinCompileCommon @Inject constructor(
|
||||
override val kotlinOptions: KotlinMultiplatformCommonOptions
|
||||
override val kotlinOptions: KotlinMultiplatformCommonOptions,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : AbstractKotlinCompile<K2MetadataCompilerArguments>(), KotlinCommonCompile {
|
||||
|
||||
class Configurator(compilation: KotlinCompilationData<*>) : AbstractKotlinCompile.Configurator<KotlinCompileCommon>(compilation) {
|
||||
@@ -77,6 +82,18 @@ abstract class KotlinCompileCommon @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override val compilerRunner: Provider<GradleCompilerRunner> =
|
||||
objects.propertyWithConvention(
|
||||
gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
null,
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
||||
K2MetadataCompilerArguments()
|
||||
|
||||
|
||||
+19
-59
@@ -467,7 +467,8 @@ internal inline val <reified T : Task> T.thisTaskProvider: TaskProvider<out T>
|
||||
|
||||
@CacheableTask
|
||||
abstract class KotlinCompile @Inject constructor(
|
||||
override val kotlinOptions: KotlinJvmOptions
|
||||
override val kotlinOptions: KotlinJvmOptions,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : AbstractKotlinCompile<K2JVMCompilerArguments>(),
|
||||
KotlinJvmCompile,
|
||||
UsesKotlinJavaToolchain {
|
||||
@@ -635,10 +636,11 @@ abstract class KotlinCompile @Inject constructor(
|
||||
// From Gradle 6.6 better to replace flatMap with provider.zip()
|
||||
defaultKotlinJavaToolchain.flatMap { toolchain ->
|
||||
objects.property(gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunner(
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
toolchain.currentJvmJdkToolsJar.orNull,
|
||||
normalizedKotlinDaemonJvmArguments.orNull
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -847,65 +849,11 @@ abstract class KotlinCompile @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@CacheableTask
|
||||
internal abstract class KotlinCompileWithWorkers @Inject constructor(
|
||||
kotlinOptions: KotlinJvmOptions,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : KotlinCompile(kotlinOptions) {
|
||||
override val compilerRunner: Provider<GradleCompilerRunner> =
|
||||
defaultKotlinJavaToolchain.flatMap { toolchain ->
|
||||
objects.property(gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
toolchain.currentJvmJdkToolsJar.orNull,
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
) as GradleCompilerRunner
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@CacheableTask
|
||||
internal abstract class Kotlin2JsCompileWithWorkers @Inject constructor(
|
||||
kotlinOptions: KotlinJsOptions,
|
||||
objectFactory: ObjectFactory,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : Kotlin2JsCompile(kotlinOptions, objectFactory) {
|
||||
override val compilerRunner: Provider<GradleCompilerRunner> =
|
||||
objects.propertyWithConvention(
|
||||
gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
null,
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
) as GradleCompilerRunner
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@CacheableTask
|
||||
internal abstract class KotlinCompileCommonWithWorkers @Inject constructor(
|
||||
kotlinOptions: KotlinMultiplatformCommonOptions,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : KotlinCompileCommon(kotlinOptions) {
|
||||
override val compilerRunner: Provider<GradleCompilerRunner> =
|
||||
objects.propertyWithConvention(
|
||||
gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
null,
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
) as GradleCompilerRunner
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@CacheableTask
|
||||
abstract class Kotlin2JsCompile @Inject constructor(
|
||||
override val kotlinOptions: KotlinJsOptions,
|
||||
objectFactory: ObjectFactory
|
||||
objectFactory: ObjectFactory,
|
||||
workerExecutor: WorkerExecutor
|
||||
) : AbstractKotlinCompile<K2JSCompilerArguments>(), KotlinJsCompile {
|
||||
|
||||
init {
|
||||
@@ -989,6 +937,18 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
||||
@get:Optional
|
||||
abstract val optionalOutputFile: RegularFileProperty
|
||||
|
||||
override val compilerRunner: Provider<GradleCompilerRunner> =
|
||||
objects.propertyWithConvention(
|
||||
gradleCompileTaskProvider.map {
|
||||
GradleCompilerRunnerWithWorkers(
|
||||
it,
|
||||
null,
|
||||
normalizedKotlinDaemonJvmArguments.orNull,
|
||||
workerExecutor
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
override fun createCompilerArgs(): K2JSCompilerArguments =
|
||||
K2JSCompilerArguments()
|
||||
|
||||
|
||||
+20
-14
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
||||
import org.jetbrains.kotlin.gradle.plugin.runOnceAfterEvaluated
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.applyLanguageSettingsToKotlinOptions
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLinkWithWorkers
|
||||
|
||||
/**
|
||||
* Registers the task with [name] and [type] and initialization script [body]
|
||||
@@ -87,12 +86,14 @@ internal open class KotlinTasksProvider {
|
||||
configureAction: (KotlinCompile) -> (Unit)
|
||||
): TaskProvider<out KotlinCompile> {
|
||||
val properties = PropertiesProvider(project)
|
||||
val taskClass = taskOrWorkersTask<KotlinCompile, KotlinCompileWithWorkers>(properties)
|
||||
val kotlinCompile = project.registerTask(name, taskClass, constructorArgs = listOf(compilation.kotlinOptions))
|
||||
val kotlinCompile = project.registerTask(
|
||||
name,
|
||||
KotlinCompile::class.java,
|
||||
constructorArgs = listOf(compilation.kotlinOptions)
|
||||
)
|
||||
|
||||
val configurator = KotlinCompile.Configurator<KotlinCompile>(compilation, properties)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
configurator.runAtConfigurationTime(kotlinCompile as TaskProvider<KotlinCompile>, project)
|
||||
configurator.runAtConfigurationTime(kotlinCompile, project)
|
||||
|
||||
kotlinCompile.configure {
|
||||
configureAction(it)
|
||||
@@ -110,8 +111,11 @@ internal open class KotlinTasksProvider {
|
||||
configureAction: (Kotlin2JsCompile) -> Unit
|
||||
): TaskProvider<out Kotlin2JsCompile> {
|
||||
val properties = PropertiesProvider(project)
|
||||
val taskClass = taskOrWorkersTask<Kotlin2JsCompile, Kotlin2JsCompileWithWorkers>(properties)
|
||||
val result = project.registerTask(name, taskClass, constructorArgs = listOf(compilation.kotlinOptions)) {
|
||||
val result = project.registerTask(
|
||||
name,
|
||||
Kotlin2JsCompile::class.java,
|
||||
constructorArgs = listOf(compilation.kotlinOptions)
|
||||
) {
|
||||
configureAction(it)
|
||||
Kotlin2JsCompile.Configurator<Kotlin2JsCompile>(compilation).configure(it)
|
||||
}
|
||||
@@ -126,8 +130,10 @@ internal open class KotlinTasksProvider {
|
||||
configureAction: (KotlinJsIrLink) -> Unit
|
||||
): TaskProvider<out KotlinJsIrLink> {
|
||||
val properties = PropertiesProvider(project)
|
||||
val taskClass = taskOrWorkersTask<KotlinJsIrLink, KotlinJsIrLinkWithWorkers>(properties)
|
||||
val result = project.registerTask(name, taskClass) {
|
||||
val result = project.registerTask(
|
||||
name,
|
||||
KotlinJsIrLink::class.java
|
||||
) {
|
||||
it.compilation = compilation
|
||||
configureAction(it)
|
||||
KotlinJsIrLink.Configurator(compilation).configure(it)
|
||||
@@ -143,8 +149,11 @@ internal open class KotlinTasksProvider {
|
||||
configureAction: (KotlinCompileCommon) -> (Unit)
|
||||
): TaskProvider<out KotlinCompileCommon> {
|
||||
val properties = PropertiesProvider(project)
|
||||
val taskClass = taskOrWorkersTask<KotlinCompileCommon, KotlinCompileCommonWithWorkers>(properties)
|
||||
val result = project.registerTask(name, taskClass, constructorArgs = listOf(compilation.kotlinOptions)) {
|
||||
val result = project.registerTask(
|
||||
name,
|
||||
KotlinCompileCommon::class.java,
|
||||
constructorArgs = listOf(compilation.kotlinOptions)
|
||||
) {
|
||||
configureAction(it)
|
||||
KotlinCompileCommon.Configurator(compilation).configure(it)
|
||||
}
|
||||
@@ -167,9 +176,6 @@ internal open class KotlinTasksProvider {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <reified Task, reified WorkersTask : Task> taskOrWorkersTask(properties: PropertiesProvider): Class<out Task> =
|
||||
if (properties.parallelTasksInProject != true) Task::class.java else WorkersTask::class.java
|
||||
}
|
||||
|
||||
internal class AndroidTasksProvider : KotlinTasksProvider() {
|
||||
|
||||
Reference in New Issue
Block a user