[Gradle] Make check for illegal target names case-insensitive

^KT-59733 Verification Pending
This commit is contained in:
Artem Daugel-Dauge
2023-06-28 15:43:35 +02:00
committed by Space Team
parent 0b912b0200
commit 27600eecb3
3 changed files with 7 additions and 4 deletions
@@ -85,8 +85,11 @@ private suspend fun Project.illegalTargetNamesUsed(): Set<String> {
val targetNames = targets.map { it.name }.toSet()
return targets.flatMap { it.compilations }.mapNotNull { compilation ->
val hierarchy = KotlinHierarchyTemplate.default.buildHierarchy(compilation) ?: return@mapNotNull null
val nodeNames = hierarchy.childrenClosure.mapNotNull { it.node as? KotlinHierarchy.Node.Group }.map { it.name }.toSet()
nodeNames.intersect(targetNames)
val nodeNames = hierarchy.childrenClosure
.mapNotNull { it.node as? KotlinHierarchy.Node.Group }
.map { it.name }
.toSortedSet(String.CASE_INSENSITIVE_ORDER)
targetNames.intersect(nodeNames)
}.flatten().toSet()
}
@@ -39,7 +39,7 @@ class DefaultHierarchySetupDiagnosticTest {
fun `test - warning KotlinTargetHierarchyFallbackIllegalTargetNames`() = buildProjectWithMPP().runLifecycleAwareTest {
val kotlin = multiplatformExtension
kotlin.linuxX64("linux") // <- illegal: Will clash with 'linux' group
kotlin.linuxArm64("native") // <-- illegal: Will clash with 'native' group
kotlin.linuxArm64("Native") // <-- illegal: Will clash with 'native' group
kotlin.jvm()
project.launchInStage(KotlinPluginLifecycle.Stage.ReadyForExecution) {
@@ -1,6 +1,6 @@
[KotlinDefaultHierarchyFallbackIllegalTargetNames | WARNING] The Default Kotlin Hierarchy was not applied to 'root project 'test'':
Illegal target names were found:
[native, linux]
[Native, linux]
To suppress the 'Default Hierarchy Template' add
'kotlin.mpp.applyDefaultHierarchyTemplate=false'