[mpp] Report commonTest with dependsOn similarly to commonMain
^KT-60556
This commit is contained in:
committed by
Space Team
parent
890e53b8e7
commit
c9b7063d96
+2
-2
@@ -6,7 +6,7 @@ kotlin.mpp.enableCompatibilityMetadataVariant, kotlin.mpp.hierarchicalStructureS
|
|||||||
Read the details here: https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#deprecate-hmpp-properties
|
Read the details here: https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#deprecate-hmpp-properties
|
||||||
#diagnostic-end
|
#diagnostic-end
|
||||||
|
|
||||||
e: [CommonMainWithDependsOnDiagnostic | ERROR] commonMain can't declare dependsOn on other source sets
|
e: [CommonMainOrTestWithDependsOnDiagnostic | ERROR] commonMain can't declare dependsOn on other source sets
|
||||||
#diagnostic-end
|
#diagnostic-end
|
||||||
|
|
||||||
w: [KotlinDefaultHierarchyFallbackDependsOnUsageDetected | WARNING] The Default Kotlin Hierarchy was not applied to 'project ':subprojectA'':
|
w: [KotlinDefaultHierarchyFallbackDependsOnUsageDetected | WARNING] The Default Kotlin Hierarchy was not applied to 'project ':subprojectA'':
|
||||||
@@ -20,7 +20,7 @@ to your gradle.properties
|
|||||||
|
|
||||||
|
|
||||||
> Configure project :subprojectB
|
> Configure project :subprojectB
|
||||||
e: [CommonMainWithDependsOnDiagnostic | ERROR] commonMain can't declare dependsOn on other source sets
|
e: [CommonMainOrTestWithDependsOnDiagnostic | ERROR] commonMain can't declare dependsOn on other source sets
|
||||||
#diagnostic-end
|
#diagnostic-end
|
||||||
|
|
||||||
w: [KotlinDefaultHierarchyFallbackDependsOnUsageDetected | WARNING] The Default Kotlin Hierarchy was not applied to 'project ':subprojectB'':
|
w: [KotlinDefaultHierarchyFallbackDependsOnUsageDetected | WARNING] The Default Kotlin Hierarchy was not applied to 'project ':subprojectB'':
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ internal interface KotlinGradleProjectChecker {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ALL_CHECKERS: List<KotlinGradleProjectChecker> = listOf(
|
val ALL_CHECKERS: List<KotlinGradleProjectChecker> = listOf(
|
||||||
CommonMainWithDependsOnChecker,
|
CommonMainOrTestWithDependsOnChecker,
|
||||||
DeprecatedKotlinNativeTargetsChecker,
|
DeprecatedKotlinNativeTargetsChecker,
|
||||||
MissingNativeStdlibChecker,
|
MissingNativeStdlibChecker,
|
||||||
UnusedSourceSetsChecker,
|
UnusedSourceSetsChecker,
|
||||||
|
|||||||
+3
-3
@@ -35,8 +35,8 @@ object KotlinToolingDiagnostics {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
object CommonMainWithDependsOnDiagnostic : ToolingDiagnosticFactory(ERROR) {
|
object CommonMainOrTestWithDependsOnDiagnostic : ToolingDiagnosticFactory(ERROR) {
|
||||||
operator fun invoke() = build("commonMain can't declare dependsOn on other source sets")
|
operator fun invoke(suffix: String) = build("common$suffix can't declare dependsOn on other source sets")
|
||||||
}
|
}
|
||||||
|
|
||||||
object NativeStdlibIsMissingDiagnostic : ToolingDiagnosticFactory(WARNING) {
|
object NativeStdlibIsMissingDiagnostic : ToolingDiagnosticFactory(WARNING) {
|
||||||
@@ -587,4 +587,4 @@ private fun String.indentLines(nSpaces: Int = 4, skipFirstLine: Boolean = true):
|
|||||||
if (skipFirstLine && index == 0) return@joinToString line
|
if (skipFirstLine && index == 0) return@joinToString line
|
||||||
if (line.isNotBlank()) "$spaces$line" else line
|
if (line.isNotBlank()) "$spaces$line" else line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-7
@@ -6,19 +6,27 @@
|
|||||||
package org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers
|
package org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnosticsCollector
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectCheckerContext
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectCheckerContext
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnosticsCollector
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||||
|
|
||||||
internal object CommonMainWithDependsOnChecker : KotlinGradleProjectChecker {
|
internal object CommonMainOrTestWithDependsOnChecker : KotlinGradleProjectChecker {
|
||||||
override suspend fun KotlinGradleProjectCheckerContext.runChecks(collector: KotlinToolingDiagnosticsCollector) {
|
override suspend fun KotlinGradleProjectCheckerContext.runChecks(collector: KotlinToolingDiagnosticsCollector) {
|
||||||
|
fun KotlinSourceSet.registerReporting(suffix: String) {
|
||||||
|
internal.dependsOn.forAll {
|
||||||
|
collector.reportOncePerGradleProject(
|
||||||
|
project,
|
||||||
|
KotlinToolingDiagnostics.CommonMainOrTestWithDependsOnDiagnostic(suffix),
|
||||||
|
key = suffix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
multiplatformExtension?.sourceSets?.all {
|
multiplatformExtension?.sourceSets?.all {
|
||||||
if (it.name == KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) {
|
when (it.name) {
|
||||||
it.internal.dependsOn.forAll {
|
KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME -> it.registerReporting("Main")
|
||||||
collector.reportOncePerGradleProject(project, KotlinToolingDiagnostics.CommonMainWithDependsOnDiagnostic())
|
KotlinSourceSet.COMMON_TEST_SOURCE_SET_NAME -> it.registerReporting("Test")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-2
@@ -14,8 +14,8 @@ import org.junit.Test
|
|||||||
class MppDiagnosticsFunctionalTest {
|
class MppDiagnosticsFunctionalTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCommonMainWithDependsOn() {
|
fun testCommonMainOrTestWithDependsOn() {
|
||||||
checkDiagnosticsWithMppProject("commonMainWithDependsOn") {
|
checkDiagnosticsWithMppProject("commonMainOrTestWithDependsOn") {
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm()
|
jvm()
|
||||||
linuxX64()
|
linuxX64()
|
||||||
@@ -29,6 +29,13 @@ class MppDiagnosticsFunctionalTest {
|
|||||||
dependsOn(myCustomCommonMain)
|
dependsOn(myCustomCommonMain)
|
||||||
dependsOn(myCustomCommonMain2) // check that diagnostic isn't duplicated
|
dependsOn(myCustomCommonMain2) // check that diagnostic isn't duplicated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val myCustomCommonTest = create("myCustomCommonTest")
|
||||||
|
val myCustomCommonTest2 = create("myCustomCommonTest2")
|
||||||
|
commonTest {
|
||||||
|
dependsOn(myCustomCommonTest)
|
||||||
|
dependsOn(myCustomCommonTest2) // check that diagnostic isn't duplicated
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
[CommonMainOrTestWithDependsOnDiagnostic | ERROR] commonMain can't declare dependsOn on other source sets
|
||||||
|
----
|
||||||
|
[CommonMainOrTestWithDependsOnDiagnostic | ERROR] commonTest can't declare dependsOn on other source sets
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
[CommonMainWithDependsOnDiagnostic | ERROR] commonMain can't declare dependsOn on other source sets
|
|
||||||
Reference in New Issue
Block a user