Revert "[MPP] Emit a warning when kotlin-test testing framework couldn't be inferred"
This reverts commit256d9da24c. Revert "[MPP] Only add test framework dependency once per configuration" This reverts commit65649673a7. ^KT-56828
This commit is contained in:
committed by
Space Team
parent
5e63d1a5e5
commit
14bed668d4
+20
-28
@@ -28,9 +28,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension
|
||||||
import org.jetbrains.kotlin.gradle.execution.KotlinAggregateExecutionSource
|
import org.jetbrains.kotlin.gradle.execution.KotlinAggregateExecutionSource
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.reportDiagnostic
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope
|
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope
|
||||||
@@ -93,29 +90,28 @@ private fun KotlinTarget.configureKotlinTestDependency(
|
|||||||
if (platformType in jvmPlatforms) {
|
if (platformType in jvmPlatforms) {
|
||||||
// Checking dependencies which were added via dependsOn(KotlinSourceSet) call
|
// Checking dependencies which were added via dependsOn(KotlinSourceSet) call
|
||||||
// Compilation has own configurations for these that are different from KotlinSourceSet configurations
|
// Compilation has own configurations for these that are different from KotlinSourceSet configurations
|
||||||
|
KotlinDependencyScope.values()
|
||||||
val configurationsToAddTestDependencyTo = linkedSetOf<Configuration>()
|
.map { configurations.sourceSetDependencyConfigurationByScope(compilation, it) }
|
||||||
|
.forEach {
|
||||||
configurationsToAddTestDependencyTo.addAll(
|
it.maybeAddTestDependencyCapability(
|
||||||
KotlinDependencyScope.values()
|
compilation,
|
||||||
.map { configurations.sourceSetDependencyConfigurationByScope(compilation, it) }
|
coreLibrariesVersion,
|
||||||
)
|
dependencyHandler,
|
||||||
|
tasks
|
||||||
configurationsToAddTestDependencyTo.addAll(
|
)
|
||||||
compilation.kotlinSourceSets.flatMap { sourceSet ->
|
|
||||||
KotlinDependencyScope.values().map {
|
|
||||||
configurations.sourceSetDependencyConfigurationByScope(sourceSet, it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
configurationsToAddTestDependencyTo.forEach {
|
compilation.kotlinSourceSets.forEach { sourceSet ->
|
||||||
it.maybeAddTestDependencyCapability(
|
KotlinDependencyScope.values()
|
||||||
compilation,
|
.map { configurations.sourceSetDependencyConfigurationByScope(sourceSet, it) }
|
||||||
coreLibrariesVersion,
|
.forEach {
|
||||||
dependencyHandler,
|
it.maybeAddTestDependencyCapability(
|
||||||
tasks
|
compilation,
|
||||||
)
|
coreLibrariesVersion,
|
||||||
|
dependencyHandler,
|
||||||
|
tasks
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,10 +144,6 @@ private fun Configuration.maybeAddTestDependencyCapability(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
compilation.project.reportDiagnostic(
|
|
||||||
KotlinToolingDiagnostics.KotlinTestFrameworkInferenceFailed(name)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-10
@@ -529,16 +529,6 @@ object KotlinToolingDiagnostics {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
object KotlinTestFrameworkInferenceFailed : ToolingDiagnosticFactory(WARNING) {
|
|
||||||
operator fun invoke(configurationName: String) = build(
|
|
||||||
"""
|
|
||||||
kotlin-test was added to a non-testing configuration "$configurationName" where test framework couldn't be inferred.
|
|
||||||
|
|
||||||
Learn how to configure kotlin-test at: https://kotl.in/kotlin-test-frameworks
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
object XCFrameworkDifferentInnerFrameworksName : ToolingDiagnosticFactory(WARNING) {
|
object XCFrameworkDifferentInnerFrameworksName : ToolingDiagnosticFactory(WARNING) {
|
||||||
operator fun invoke(xcFramework: String, innerFrameworks: String) = build(
|
operator fun invoke(xcFramework: String, innerFrameworks: String) = build(
|
||||||
"Name of XCFramework '$xcFramework' differs from inner frameworks name '$innerFrameworks'! Framework renaming is not supported yet"
|
"Name of XCFramework '$xcFramework' differs from inner frameworks name '$innerFrameworks'! Framework renaming is not supported yet"
|
||||||
|
|||||||
-116
@@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2023 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@file:Suppress("FunctionName")
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.dependencyResolutionTests
|
|
||||||
|
|
||||||
import org.gradle.api.NamedDomainObjectProvider
|
|
||||||
import org.gradle.api.artifacts.Configuration
|
|
||||||
import org.gradle.api.internal.project.ProjectInternal
|
|
||||||
import org.gradle.kotlin.dsl.dependencies
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformSourceSetConventionsImpl.dependencies
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
|
||||||
import org.jetbrains.kotlin.gradle.util.*
|
|
||||||
import org.jetbrains.kotlin.gradle.util.assertNoDiagnostics
|
|
||||||
import kotlin.test.Test
|
|
||||||
|
|
||||||
class KotlinTestFrameworkInferenceFailedTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `KMP project - when jvmTest depends on kotlin-test - emits no diagnostics`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
kmpProjectWithJvm { sourceSets.jvmTest.dependOnKotlinTest() }
|
|
||||||
}.assertNoDiagnostics()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `KMP project - when commonTest depends on kotlin-test - emits no diagnostics`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
kmpProjectWithJvm { sourceSets.commonTest.dependOnKotlinTest() }
|
|
||||||
}.assertNoDiagnostics()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `KMP project - when jvmMain depends on kotlin-test - emits a diagnostic`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
kmpProjectWithJvm { sourceSets.jvmMain.dependOnKotlinTest() }
|
|
||||||
}.checkDiagnostics("kotlin-test-kmp-jvmMain")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `KMP project - when commonMain depends on kotlin-test - emits a diagnostic`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
kmpProjectWithJvm { sourceSets.commonMain.dependOnKotlinTest() }
|
|
||||||
}.checkDiagnostics("kotlin-test-kmp-commonMain")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `KMP project without jvm - when commonMain depends on kotlin-test - emits no diagnostics`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
buildProjectWithMPP {
|
|
||||||
kotlin {
|
|
||||||
linuxArm64()
|
|
||||||
linuxX64()
|
|
||||||
|
|
||||||
sourceSets.commonMain.dependOnKotlinTest()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.assertNoDiagnostics()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `JVM project - when testImplementation depends on kotlin-test - emits no diagnostics`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
buildProjectWithJvm {
|
|
||||||
dependencies {
|
|
||||||
"testImplementation"("org.jetbrains.kotlin:kotlin-test")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.assertNoDiagnostics()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `JVM project - when implementation depends on kotlin-test - emits a diagnostic`() {
|
|
||||||
evaluateProjectAndResolveConfigurationsWhen {
|
|
||||||
buildProjectWithJvm {
|
|
||||||
dependencies {
|
|
||||||
"implementation"("org.jetbrains.kotlin:kotlin-test")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.checkDiagnostics("kotlin-test-jvm-implementation")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun kmpProjectWithJvm(configure: KotlinMultiplatformExtension.() -> Unit): ProjectInternal {
|
|
||||||
return buildProjectWithMPP {
|
|
||||||
kotlin {
|
|
||||||
jvm()
|
|
||||||
linuxArm64()
|
|
||||||
|
|
||||||
configure(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun NamedDomainObjectProvider<KotlinSourceSet>.dependOnKotlinTest() {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun evaluateProjectAndResolveConfigurationsWhen(
|
|
||||||
projectFactory: () -> ProjectInternal
|
|
||||||
): ProjectInternal {
|
|
||||||
val project = projectFactory()
|
|
||||||
project.repositories.mavenLocal()
|
|
||||||
project.repositories.mavenCentralCacheRedirector()
|
|
||||||
project.evaluate()
|
|
||||||
project.configurations.filter(Configuration::isCanBeResolved).forEach(Configuration::resolve)
|
|
||||||
return project
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
[KotlinTestFrameworkInferenceFailed | WARNING] kotlin-test was added to a non-testing configuration "implementation" where test framework couldn't be inferred.
|
|
||||||
|
|
||||||
Learn how to configure kotlin-test at: https://kotl.in/kotlin-test-frameworks
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
[KotlinTestFrameworkInferenceFailed | WARNING] kotlin-test was added to a non-testing configuration "jvmCompilationImplementation" where test framework couldn't be inferred.
|
|
||||||
|
|
||||||
Learn how to configure kotlin-test at: https://kotl.in/kotlin-test-frameworks
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
[KotlinTestFrameworkInferenceFailed | WARNING] kotlin-test was added to a non-testing configuration "jvmMainImplementation" where test framework couldn't be inferred.
|
|
||||||
|
|
||||||
Learn how to configure kotlin-test at: https://kotl.in/kotlin-test-frameworks
|
|
||||||
----
|
|
||||||
[KotlinTestFrameworkInferenceFailed | WARNING] kotlin-test was added to a non-testing configuration "jvmCompilationImplementation" where test framework couldn't be inferred.
|
|
||||||
|
|
||||||
Learn how to configure kotlin-test at: https://kotl.in/kotlin-test-frameworks
|
|
||||||
Reference in New Issue
Block a user