[mpp] Don't report kotlin-test as pre-HMPP dependency
- Exclude kotlin-stdlib and kotlin-test from reporting - kotlin-stdlib wasn't reported, because it doesn't even have Gradle modular metadata (so no o.j.k.platform.type attribute, and check doesn't work). This commit explicitly excludes kotlin-stdlib, so that when it starts publishing Gradle Modular Metadata, nothing would break - kotlin-test was reported only when it is declared in commonMain, because we're checking only metadata compilations, and commonTest isn't compiled to metadata - Depending on kotlin-test is an odd configuration, but it arises sometimes (e.g. when people extract some test utilities in a separate Gradle project) ^KT-58872
This commit is contained in:
committed by
Space Team
parent
14b340c61e
commit
38cd8ee7e7
+5
@@ -60,6 +60,11 @@ class PreHmppDependenciesDeprecationIT : KGPBaseTest() {
|
|||||||
checkDiagnostics(gradleVersion, "noWarningsOnPopularDependencies")
|
checkDiagnostics(gradleVersion, "noWarningsOnPopularDependencies")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GradleTest
|
||||||
|
fun testNoWarningsOnKotlinTestIfAddedInCommonMain(gradleVersion: GradleVersion) {
|
||||||
|
checkDiagnostics(gradleVersion, "noWarningsOnKotlinTestIfAddedInCommonMain")
|
||||||
|
}
|
||||||
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testNoWarningsOnProjectDependencies(gradleVersion: GradleVersion) {
|
fun testNoWarningsOnProjectDependencies(gradleVersion: GradleVersion) {
|
||||||
checkDiagnostics(gradleVersion, "noWarningsOnProjectDependencies", projectPathToCheck = ":consumer")
|
checkDiagnostics(gradleVersion, "noWarningsOnProjectDependencies", projectPathToCheck = ":consumer")
|
||||||
|
|||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
maven("<localRepo>")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm() {
|
||||||
|
}
|
||||||
|
linuxX64()
|
||||||
|
|
||||||
|
sourceSets.getByName("commonMain").dependencies {
|
||||||
|
implementation(kotlin("test"))
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.getByName("jvmMain").dependencies {
|
||||||
|
implementation(kotlin("test-junit"))
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -72,6 +72,7 @@ internal object PreHmppDependenciesUsageChecker : KotlinGradleProjectChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isPreHmppDependency(dependency: ResolvedDependencyResult): Boolean {
|
private fun isPreHmppDependency(dependency: ResolvedDependencyResult): Boolean {
|
||||||
|
if (isAllowedDependency(dependency.selected.id)) return false
|
||||||
val attributes = dependency.resolvedVariant.attributes
|
val attributes = dependency.resolvedVariant.attributes
|
||||||
val kotlinPlatformAttribute = attributes.getAttribute(Attribute.of(KotlinPlatformType.attribute.name, String::class.java))
|
val kotlinPlatformAttribute = attributes.getAttribute(Attribute.of(KotlinPlatformType.attribute.name, String::class.java))
|
||||||
?: return false
|
?: return false
|
||||||
@@ -79,4 +80,13 @@ internal object PreHmppDependenciesUsageChecker : KotlinGradleProjectChecker {
|
|||||||
|
|
||||||
return kotlinPlatformAttribute == KotlinPlatformType.common.name && usageAttribute != KotlinUsages.KOTLIN_METADATA
|
return kotlinPlatformAttribute == KotlinPlatformType.common.name && usageAttribute != KotlinUsages.KOTLIN_METADATA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isAllowedDependency(identifier: ComponentIdentifier): Boolean {
|
||||||
|
return when {
|
||||||
|
identifier !is ModuleComponentIdentifier -> false
|
||||||
|
identifier.group != "org.jetbrains.kotlin" -> false
|
||||||
|
identifier.module.contains("kotlin-stdlib") || identifier.module.contains("kotlin-test") -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user