Add kotlin-test variant dependency in a lazy way
^KT-41642 In Progress
This commit is contained in:
+36
@@ -250,6 +250,42 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmGradlePluginTests
|
||||||
|
@DisplayName("KT-41642: adding kotlin.test should not resolve dependencies eagerly")
|
||||||
|
@GradleTest
|
||||||
|
fun testKotlinTestEagerDependencies(gradleVersion: GradleVersion) {
|
||||||
|
project("simpleProject", gradleVersion) {
|
||||||
|
|
||||||
|
// Disabling auto-adding kotlin stdlib dependencies
|
||||||
|
gradleProperties.appendText(
|
||||||
|
"""
|
||||||
|
|
||||||
|
kotlin.stdlib.default.dependency=false
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
buildGradle.appendText(
|
||||||
|
//language=Groovy
|
||||||
|
"""
|
||||||
|
|
||||||
|
configurations.each { config ->
|
||||||
|
config.dependencies.addAllLater(
|
||||||
|
project.objects.listProperty(Dependency.class).value(
|
||||||
|
project.provider {
|
||||||
|
throw new Throwable("Dependency resolved in ${'$'}{config.name}!")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
build("help") {
|
||||||
|
assertOutputDoesNotContain("Dependency resolved in")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@AndroidGradlePluginTests
|
@AndroidGradlePluginTests
|
||||||
@DisplayName("Android: Kotlin test single dependency in unit tests")
|
@DisplayName("Android: Kotlin test single dependency in unit tests")
|
||||||
@GradleAndroidTest
|
@GradleAndroidTest
|
||||||
|
|||||||
+133
-109
@@ -7,13 +7,14 @@ package org.jetbrains.kotlin.gradle.internal
|
|||||||
|
|
||||||
import com.android.build.gradle.api.TestVariant
|
import com.android.build.gradle.api.TestVariant
|
||||||
import com.android.build.gradle.api.UnitTestVariant
|
import com.android.build.gradle.api.UnitTestVariant
|
||||||
import org.gradle.api.InvalidUserDataException
|
import org.gradle.api.NamedDomainObjectSet
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.artifacts.*
|
import org.gradle.api.artifacts.*
|
||||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
import org.gradle.api.tasks.testing.AbstractTestTask
|
import org.gradle.api.tasks.TaskContainer
|
||||||
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.gradle.api.tasks.testing.Test
|
import org.gradle.api.tasks.testing.Test
|
||||||
import org.gradle.api.tasks.testing.junit.JUnitOptions
|
import org.gradle.api.tasks.testing.junit.JUnitOptions
|
||||||
import org.gradle.api.tasks.testing.junitplatform.JUnitPlatformOptions
|
import org.gradle.api.tasks.testing.junitplatform.JUnitPlatformOptions
|
||||||
@@ -33,7 +34,6 @@ import org.jetbrains.kotlin.gradle.plugin.sources.android.AndroidVariantType
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.sources.android.androidSourceSetInfoOrNull
|
import org.jetbrains.kotlin.gradle.plugin.sources.android.androidSourceSetInfoOrNull
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.dependsOnClosure
|
import org.jetbrains.kotlin.gradle.plugin.sources.dependsOnClosure
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope
|
import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.withDependsOnClosure
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer
|
import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer
|
||||||
import org.jetbrains.kotlin.gradle.targets.jvm.JvmCompilationsTestRunSource
|
import org.jetbrains.kotlin.gradle.targets.jvm.JvmCompilationsTestRunSource
|
||||||
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||||
@@ -48,15 +48,19 @@ internal const val PLATFORM_INTEGERS_SUPPORT_LIBRARY = "platform-integers"
|
|||||||
|
|
||||||
internal fun customizeKotlinDependencies(project: Project) {
|
internal fun customizeKotlinDependencies(project: Project) {
|
||||||
val topLevelExtension = project.topLevelExtension
|
val topLevelExtension = project.topLevelExtension
|
||||||
|
val propertiesProvider = PropertiesProvider(project)
|
||||||
val coreLibrariesVersion = project.objects.providerWithLazyConvention {
|
val coreLibrariesVersion = project.objects.providerWithLazyConvention {
|
||||||
topLevelExtension.coreLibrariesVersion
|
topLevelExtension.coreLibrariesVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PropertiesProvider(project).stdlibDefaultDependency)
|
if (propertiesProvider.stdlibDefaultDependency)
|
||||||
project.configureStdlibDefaultDependency(topLevelExtension, coreLibrariesVersion)
|
project.configureStdlibDefaultDependency(topLevelExtension, coreLibrariesVersion)
|
||||||
|
|
||||||
if (topLevelExtension is KotlinProjectExtension) { // TODO: extend this logic to PM20
|
if (propertiesProvider.kotlinTestInferJvmVariant) { // TODO: extend this logic to PM20
|
||||||
configureKotlinTestDependency(project)
|
project.configureKotlinTestDependency(
|
||||||
|
topLevelExtension,
|
||||||
|
coreLibrariesVersion,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
project.configurations.configureDefaultVersionsResolutionStrategy(
|
project.configurations.configureDefaultVersionsResolutionStrategy(
|
||||||
@@ -129,6 +133,7 @@ private fun Project.configureStdlibDefaultDependency(
|
|||||||
topLevelExtension is KotlinSingleTargetExtension<*> -> topLevelExtension
|
topLevelExtension is KotlinSingleTargetExtension<*> -> topLevelExtension
|
||||||
.target
|
.target
|
||||||
.addStdlibDependency(configurations, dependencies, coreLibrariesVersion)
|
.addStdlibDependency(configurations, dependencies, coreLibrariesVersion)
|
||||||
|
|
||||||
topLevelExtension is KotlinMultiplatformExtension -> topLevelExtension
|
topLevelExtension is KotlinMultiplatformExtension -> topLevelExtension
|
||||||
.targets
|
.targets
|
||||||
.configureEach { target ->
|
.configureEach { target ->
|
||||||
@@ -278,107 +283,144 @@ private val stdlibModules = setOf("kotlin-stdlib-common", "kotlin-stdlib", "kotl
|
|||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region kotlin-test
|
//region kotlin-test
|
||||||
internal fun configureKotlinTestDependency(project: Project) {
|
private val Dependency.isKotlinTestRootDependency: Boolean
|
||||||
if (!PropertiesProvider(project).kotlinTestInferJvmVariant)
|
get() = group == KOTLIN_MODULE_GROUP && name == KOTLIN_TEST_ROOT_MODULE_NAME
|
||||||
return
|
|
||||||
|
|
||||||
fun isKotlinTestRootDependency(dependency: Dependency) =
|
private val kotlin150Version = SemVer(1.toBigInteger(), 5.toBigInteger(), 0.toBigInteger())
|
||||||
dependency.group == KOTLIN_MODULE_GROUP && dependency.name == KOTLIN_TEST_ROOT_MODULE_NAME
|
|
||||||
|
|
||||||
val versionPrefixRegex = Regex("""^(\d+)\.(\d+)""")
|
private fun isAtLeast1_5(version: String) = SemVer.from(version) >= kotlin150Version
|
||||||
fun isAtLeast1_5(version: String) = versionPrefixRegex.find(version)?.let {
|
|
||||||
val c1 = it.groupValues[1].toInt()
|
|
||||||
val c2 = it.groupValues[2].toInt()
|
|
||||||
c1 > 1 || c1 == 1 && c2 >= 5
|
|
||||||
} ?: false
|
|
||||||
|
|
||||||
KotlinDependencyScope.values().forEach { scope ->
|
private val jvmPlatforms = setOf(KotlinPlatformType.jvm, KotlinPlatformType.androidJvm)
|
||||||
val versionOrNullBySourceSet = mutableMapOf<KotlinSourceSet, String?>()
|
|
||||||
|
|
||||||
project.kotlinExtension.sourceSets.all { kotlinSourceSet ->
|
private fun Project.configureKotlinTestDependency(
|
||||||
val configuration = project.configurations.sourceSetDependencyConfigurationByScope(kotlinSourceSet, scope)
|
topLevelExtension: KotlinTopLevelExtension,
|
||||||
var finalizingDependencies = false
|
coreLibrariesVersion: Provider<String>,
|
||||||
|
) {
|
||||||
|
when (topLevelExtension) {
|
||||||
|
is KotlinSingleTargetExtension<*> -> topLevelExtension.target.configureKotlinTestDependency(
|
||||||
|
configurations,
|
||||||
|
coreLibrariesVersion,
|
||||||
|
dependencies,
|
||||||
|
tasks
|
||||||
|
)
|
||||||
|
|
||||||
configuration.nonProjectDependencies().matching(::isKotlinTestRootDependency).apply {
|
is KotlinMultiplatformExtension -> topLevelExtension.targets.configureEach { target ->
|
||||||
firstOrNull()?.let { versionOrNullBySourceSet[kotlinSourceSet] = it.version }
|
target.configureKotlinTestDependency(
|
||||||
whenObjectRemoved {
|
configurations,
|
||||||
if (!finalizingDependencies && !any())
|
coreLibrariesVersion,
|
||||||
versionOrNullBySourceSet.remove(kotlinSourceSet)
|
dependencies,
|
||||||
|
tasks
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun KotlinTarget.configureKotlinTestDependency(
|
||||||
|
configurations: ConfigurationContainer,
|
||||||
|
coreLibrariesVersion: Provider<String>,
|
||||||
|
dependencyHandler: DependencyHandler,
|
||||||
|
tasks: TaskContainer
|
||||||
|
) {
|
||||||
|
compilations.configureEach { compilation ->
|
||||||
|
val platformType = compilation.platformType
|
||||||
|
if (platformType in jvmPlatforms) {
|
||||||
|
// Checking dependencies which were added via dependsOn(KotlinSourceSet) call
|
||||||
|
// Compilation has own configurations for these that are different from KotlinSourceSet configurations
|
||||||
|
KotlinDependencyScope.values()
|
||||||
|
.map { configurations.sourceSetDependencyConfigurationByScope(compilation, it) }
|
||||||
|
.forEach {
|
||||||
|
it.maybeAddTestDependencyCapability(
|
||||||
|
compilation,
|
||||||
|
coreLibrariesVersion,
|
||||||
|
dependencyHandler,
|
||||||
|
tasks
|
||||||
|
)
|
||||||
}
|
}
|
||||||
whenObjectAdded { item ->
|
|
||||||
versionOrNullBySourceSet[kotlinSourceSet] = item.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
project.tryWithDependenciesIfUnresolved(configuration) { dependencies ->
|
compilation.kotlinSourceSets.forEach { sourceSet ->
|
||||||
val parentOrOwnVersions: List<String?> =
|
KotlinDependencyScope.values()
|
||||||
kotlinSourceSet.withDependsOnClosure.filter(versionOrNullBySourceSet::contains)
|
.map { configurations.sourceSetDependencyConfigurationByScope(sourceSet, it) }
|
||||||
.map(versionOrNullBySourceSet::get)
|
.forEach {
|
||||||
|
it.maybeAddTestDependencyCapability(
|
||||||
finalizingDependencies = true
|
compilation,
|
||||||
|
coreLibrariesVersion,
|
||||||
for (version in parentOrOwnVersions.distinct()) { // add dependencies with each version and let Gradle disambiguate them
|
dependencyHandler,
|
||||||
val effectiveVersion = version ?: project.kotlinExtension.coreLibrariesVersion
|
tasks
|
||||||
if (!isAtLeast1_5(effectiveVersion)) continue
|
)
|
||||||
val clarifyCapability = kotlinTestCapabilityForJvmSourceSet(project, kotlinSourceSet) ?: continue
|
}
|
||||||
val clarifiedDependency =
|
|
||||||
(project.dependencies.kotlinDependency(KOTLIN_TEST_ROOT_MODULE_NAME, version) as ExternalDependency).apply {
|
|
||||||
if (version == null) {
|
|
||||||
version { constraint -> constraint.require(project.kotlinExtension.coreLibrariesVersion) }
|
|
||||||
}
|
|
||||||
capabilities {
|
|
||||||
it.requireCapability(clarifyCapability)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies.add(clarifiedDependency)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun kotlinTestCapabilityForJvmSourceSet(project: Project, kotlinSourceSet: KotlinSourceSet): String? {
|
private fun Configuration.maybeAddTestDependencyCapability(
|
||||||
val compilations = CompilationSourceSetUtil.compilationsBySourceSets(project).getValue(kotlinSourceSet)
|
compilation: KotlinCompilation<*>,
|
||||||
.filter { it.target !is KotlinMetadataTarget }
|
coreLibrariesVersion: Provider<String>,
|
||||||
.ifEmpty { return null }
|
dependencyHandler: DependencyHandler,
|
||||||
|
tasks: TaskContainer
|
||||||
|
) {
|
||||||
|
withDependencies { dependencies ->
|
||||||
|
val testRootDependency = allNonProjectDependencies()
|
||||||
|
.singleOrNull { it.isKotlinTestRootDependency }
|
||||||
|
|
||||||
val platformTypes = compilations.map { it.platformType }
|
if (testRootDependency != null) {
|
||||||
// TODO: Extract jvmPlatformTypes to public constant?
|
val depVersion = testRootDependency.version ?: coreLibrariesVersion.get()
|
||||||
val jvmPlatforms = setOf(KotlinPlatformType.jvm, KotlinPlatformType.androidJvm)
|
if (!isAtLeast1_5(depVersion)) return@withDependencies
|
||||||
if (!jvmPlatforms.containsAll(platformTypes)) return null
|
|
||||||
|
|
||||||
val testTaskLists: List<List<Task>?> = compilations.map { compilation ->
|
val testCapability = compilation.kotlinTestCapabilityForJvmSourceSet(tasks)
|
||||||
val target = compilation.target
|
if (testCapability != null) {
|
||||||
when {
|
dependencies.addLater(
|
||||||
target is KotlinTargetWithTests<*, *> ->
|
testCapability.map { capability ->
|
||||||
target.findTestRunsByCompilation(compilation)?.filterIsInstance<KotlinTaskTestRun<*, *>>()?.map { it.executionTask.get() }
|
dependencyHandler
|
||||||
target is KotlinWithJavaTarget<*> ->
|
.kotlinDependency(KOTLIN_TEST_ROOT_MODULE_NAME, depVersion)
|
||||||
if (compilation.name == KotlinCompilation.TEST_COMPILATION_NAME)
|
.apply {
|
||||||
project.locateTask<AbstractTestTask>(target.testTaskName)?.get()?.let(::listOf)
|
(this as ExternalDependency).capabilities {
|
||||||
else null
|
it.requireCapability(capability)
|
||||||
compilation is KotlinJvmAndroidCompilation -> when (compilation.androidVariant) {
|
}
|
||||||
is UnitTestVariant ->
|
}
|
||||||
project.locateTask<AbstractTestTask>(lowerCamelCaseName("test", compilation.androidVariant.name))?.get()?.let(::listOf)
|
}
|
||||||
is TestVariant -> (compilation.androidVariant as TestVariant).connectedInstrumentTestProvider.orNull?.let(::listOf)
|
)
|
||||||
else -> null
|
|
||||||
}
|
}
|
||||||
else -> null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null in testTaskLists) {
|
}
|
||||||
return null
|
|
||||||
}
|
private fun KotlinCompilation<*>.kotlinTestCapabilityForJvmSourceSet(
|
||||||
val testTasks = testTaskLists.flatMap { checkNotNull(it) }
|
tasks: TaskContainer
|
||||||
val frameworks = testTasks.mapTo(mutableSetOf()) { testTask ->
|
): Provider<String>? {
|
||||||
when (testTask) {
|
val compilationTarget = target
|
||||||
is Test -> testFrameworkOf(testTask)
|
val testTaskList: List<TaskProvider<out Task>> = when {
|
||||||
else -> // Android connected test tasks don't inherit from Test, but we use JUnit for them
|
compilationTarget is KotlinTargetWithTests<*, *> -> compilationTarget
|
||||||
KotlinTestJvmFramework.junit
|
.findTestRunsByCompilation(this)
|
||||||
|
.matching { it is KotlinTaskTestRun<*, *> }
|
||||||
|
.mapNotNull { (it as KotlinTaskTestRun<*, *>).executionTask }
|
||||||
|
|
||||||
|
compilationTarget is KotlinWithJavaTarget<*> &&
|
||||||
|
name == KotlinCompilation.TEST_COMPILATION_NAME ->
|
||||||
|
listOfNotNull(tasks.locateTask(compilationTarget.testTaskName))
|
||||||
|
|
||||||
|
this is KotlinJvmAndroidCompilation -> when (androidVariant) {
|
||||||
|
is UnitTestVariant -> listOfNotNull(tasks.locateTask(lowerCamelCaseName("test", androidVariant.name)))
|
||||||
|
is TestVariant -> listOfNotNull((androidVariant as TestVariant).connectedInstrumentTestProvider)
|
||||||
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Review Sergey Igushkin: https://youtrack.jetbrains.com/issue/KT-48885
|
if (testTaskList.isEmpty()) return null
|
||||||
return "$KOTLIN_MODULE_GROUP:$KOTLIN_TEST_ROOT_MODULE_NAME-framework-${frameworks.singleOrNull() ?: return null}"
|
|
||||||
|
return testTaskList
|
||||||
|
.singleOrNull()
|
||||||
|
?.map { task ->
|
||||||
|
val framework = when (task) {
|
||||||
|
is Test -> testFrameworkOf(task)
|
||||||
|
else -> // Android connected test tasks don't inherit from Test, but we use JUnit for them
|
||||||
|
KotlinTestJvmFramework.junit
|
||||||
|
}
|
||||||
|
|
||||||
|
"$KOTLIN_MODULE_GROUP:$KOTLIN_TEST_ROOT_MODULE_NAME-framework-$framework"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal const val KOTLIN_TEST_ROOT_MODULE_NAME = "kotlin-test"
|
internal const val KOTLIN_TEST_ROOT_MODULE_NAME = "kotlin-test"
|
||||||
@@ -395,38 +437,20 @@ private fun testFrameworkOf(testTask: Test): KotlinTestJvmFramework = when (test
|
|||||||
KotlinTestJvmFramework.junit
|
KotlinTestJvmFramework.junit
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinTargetWithTests<*, *>.findTestRunsByCompilation(byCompilation: KotlinCompilation<*>): List<KotlinTargetTestRun<*>>? {
|
private fun KotlinTargetWithTests<*, *>.findTestRunsByCompilation(
|
||||||
|
byCompilation: KotlinCompilation<*>
|
||||||
|
): NamedDomainObjectSet<out KotlinTargetTestRun<*>> {
|
||||||
fun KotlinExecution.ExecutionSource.isProducedFromTheCompilation(): Boolean = when (this) {
|
fun KotlinExecution.ExecutionSource.isProducedFromTheCompilation(): Boolean = when (this) {
|
||||||
is CompilationExecutionSource<*> -> compilation == byCompilation
|
is CompilationExecutionSource<*> -> compilation == byCompilation
|
||||||
is JvmCompilationsTestRunSource -> byCompilation in testCompilations
|
is JvmCompilationsTestRunSource -> byCompilation in testCompilations
|
||||||
is KotlinAggregateExecutionSource<*> -> this.executionSources.any { it.isProducedFromTheCompilation() }
|
is KotlinAggregateExecutionSource<*> -> this.executionSources.any { it.isProducedFromTheCompilation() }
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
return testRuns.filter { it.executionSource.isProducedFromTheCompilation() }.takeIf { it.isNotEmpty() }
|
return testRuns.matching { it.executionSource.isProducedFromTheCompilation() }
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
internal fun DependencyHandler.kotlinDependency(moduleName: String, versionOrNull: String?) =
|
internal fun DependencyHandler.kotlinDependency(moduleName: String, versionOrNull: String?) =
|
||||||
create("$KOTLIN_MODULE_GROUP:$moduleName${versionOrNull?.prependIndent(":").orEmpty()}")
|
create("$KOTLIN_MODULE_GROUP:$moduleName${versionOrNull?.prependIndent(":").orEmpty()}")
|
||||||
|
|
||||||
private fun Project.tryWithDependenciesIfUnresolved(configuration: Configuration, action: (DependencySet) -> Unit) {
|
|
||||||
fun reportAlreadyResolved() {
|
|
||||||
logger.info("Could not setup Kotlin-specific dependencies for $configuration as it is already resolved")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.state != Configuration.State.UNRESOLVED)
|
|
||||||
return reportAlreadyResolved()
|
|
||||||
|
|
||||||
// Gradle doesn't provide any public API to check if it's safe to modify a configuration's dependencies.
|
|
||||||
// The state of the configuration may still be UNRESOLVED but it might have 'participated' in dependency resolution and its dependencies
|
|
||||||
// may now be frozen.
|
|
||||||
try {
|
|
||||||
configuration.withDependencies(action)
|
|
||||||
} catch (e: InvalidUserDataException) {
|
|
||||||
reportAlreadyResolved()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Configuration.allNonProjectDependencies() = allDependencies.matching { it !is ProjectDependency }
|
private fun Configuration.allNonProjectDependencies() = allDependencies.matching { it !is ProjectDependency }
|
||||||
|
|
||||||
private fun Configuration.nonProjectDependencies() = dependencies.matching { it !is ProjectDependency }
|
|
||||||
|
|||||||
+7
@@ -20,6 +20,7 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.UnknownTaskException
|
import org.gradle.api.UnknownTaskException
|
||||||
import org.gradle.api.tasks.TaskCollection
|
import org.gradle.api.tasks.TaskCollection
|
||||||
|
import org.gradle.api.tasks.TaskContainer
|
||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
||||||
@@ -69,6 +70,12 @@ internal inline fun <reified T : Task> Project.locateTask(name: String): TaskPro
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locates a task by [name] and [type], without triggering its creation or configuration.
|
||||||
|
*/
|
||||||
|
internal inline fun <reified T : Task> TaskContainer.locateTask(name: String): TaskProvider<T>? =
|
||||||
|
if (names.contains(name)) named(name, T::class.java) else null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates a task by [name] and [type], without triggering its creation or configuration or registers new task
|
* Locates a task by [name] and [type], without triggering its creation or configuration or registers new task
|
||||||
* with [name], type [T] and initialization script [body]
|
* with [name], type [T] and initialization script [body]
|
||||||
|
|||||||
Reference in New Issue
Block a user