[MPP] Don't enable commonization in subprojects of a project where

CocoaPods plugin was applied

^KT-58712
This commit is contained in:
Timofey Solonin
2023-07-04 17:52:12 +02:00
committed by Space Team
parent 3c8c20f8d2
commit 5d8e23e971
2 changed files with 38 additions and 4 deletions
@@ -387,7 +387,10 @@ internal class PropertiesProvider private constructor(private val project: Proje
private val enableCInteropCommonizationSetByExternalPluginKey = "kotlin.internal.mpp.enableCInteropCommonization.setByExternalPlugin" private val enableCInteropCommonizationSetByExternalPluginKey = "kotlin.internal.mpp.enableCInteropCommonization.setByExternalPlugin"
internal var enableCInteropCommonizationSetByExternalPlugin: Boolean? internal var enableCInteropCommonizationSetByExternalPlugin: Boolean?
get() = booleanProperty(enableCInteropCommonizationSetByExternalPluginKey) get() {
if (!project.extensions.extraProperties.has(enableCInteropCommonizationSetByExternalPluginKey)) return null
return booleanProperty(enableCInteropCommonizationSetByExternalPluginKey)
}
set(value) { set(value) {
project.extensions.extraProperties.set(enableCInteropCommonizationSetByExternalPluginKey, "$value") project.extensions.extraProperties.set(enableCInteropCommonizationSetByExternalPluginKey, "$value")
} }
@@ -10,10 +10,9 @@ package org.jetbrains.kotlin.gradle.unitTests
import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.internal.project.ProjectInternal
import org.gradle.testfixtures.ProjectBuilder import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
import org.jetbrains.kotlin.gradle.targets.native.internal.cInteropCommonizationEnabled
import org.jetbrains.kotlin.gradle.util.* import org.jetbrains.kotlin.gradle.util.*
import kotlin.test.Test import kotlin.test.*
import kotlin.test.assertNotNull
import kotlin.test.assertNull
class CommonizerTaskTests { class CommonizerTaskTests {
@@ -136,4 +135,36 @@ class CommonizerTaskTests {
subproject.tasks.getByName("commonize").assertDependsOn(commonizeCInteropTask) subproject.tasks.getByName("commonize").assertDependsOn(commonizeCInteropTask)
rootProject.assertContainsNoTaskWithName(commonizeCInteropTaskName) rootProject.assertContainsNoTaskWithName(commonizeCInteropTaskName)
} }
@Test
fun `test applying CocoaPods plugin - enables commonization`() {
val rootProject = ProjectBuilder.builder().build() as ProjectInternal
rootProject.applyMultiplatformPlugin()
rootProject.runLifecycleAwareTest {
assertFalse(rootProject.cInteropCommonizationEnabled())
rootProject.applyCocoapodsPlugin()
assertTrue(rootProject.cInteropCommonizationEnabled())
}
}
@Test
fun `test applying CocoaPods plugin - in a root project - enables commonization only in the root project`() {
val rootProject = ProjectBuilder.builder().build() as ProjectInternal
val subproject = ProjectBuilder.builder().withParent(rootProject).build() as ProjectInternal
rootProject.applyMultiplatformPlugin()
subproject.applyMultiplatformPlugin()
rootProject.runLifecycleAwareTest {
assertFalse(rootProject.cInteropCommonizationEnabled())
assertFalse(subproject.cInteropCommonizationEnabled())
rootProject.applyCocoapodsPlugin()
assertTrue(rootProject.cInteropCommonizationEnabled())
assertFalse(subproject.cInteropCommonizationEnabled())
}
}
} }