IDE: Add a flag to disable native libraries propagation

This commit is contained in:
Ilya Matveev
2019-09-27 12:29:18 +07:00
parent becdd7a5e6
commit 95cbb4e8b4
10 changed files with 112 additions and 21 deletions
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.ide.konan.gradle
import com.intellij.openapi.roots.DependencyScope
import org.jetbrains.kotlin.gradle.ModuleInfo
import org.jetbrains.kotlin.gradle.checkProjectStructure
import org.jetbrains.kotlin.idea.codeInsight.gradle.GradleImportingTestCase
import org.jetbrains.kotlin.idea.configuration.externalCompilerVersion
import org.jetbrains.plugins.gradle.util.GradleConstants
import org.junit.Test
@@ -63,12 +62,47 @@ class GradleNativeLibrariesPropagationTest : TestCaseWithFakeKotlinNative() {
}
}
@Test
fun testCommonIOSWithDisabledPropagation() {
configureProject()
importProject()
// No dependencies should be propagated.
checkProjectStructure(
myProject,
projectPath,
exhaustiveModuleList = false,
exhaustiveSourceSourceRootList = false,
exhaustiveDependencyList = false,
exhaustiveTestsList = false
) {
module("project_commonMain") {
noPlatformLibrary("Foundation")
noPlatformLibrary("CFNetwork")
noPlatformLibrary("WatchKit")
}
module("project_appleMain") {
noPlatformLibrary("Foundation")
noPlatformLibrary("CFNetwork")
noPlatformLibrary("WatchKit")
}
module("project_iosMain") {
noPlatformLibrary("Foundation")
noPlatformLibrary("CFNetwork")
noPlatformLibrary("WatchKit")
}
}
}
private val ModuleInfo.kotlinVersion: String
get() = requireNotNull(module.externalCompilerVersion) { "External compiler version should not be null" }
private fun ModuleInfo.noPlatformLibrary(libraryName: String, targets: Collection<String> = testedTargets) {
targets.forEach { target ->
assertNoDepForModule(module.name,"Kotlin/Native $kotlinVersion - $libraryName [$target]")
assertNoLibraryDepForModule(module.name, "Kotlin/Native $kotlinVersion - $libraryName [$target]")
}
}