diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/HierarchicalMultiplatformProjectImportingTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/HierarchicalMultiplatformProjectImportingTest.kt index 35f7d3f14fb..a20b10700e3 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/HierarchicalMultiplatformProjectImportingTest.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/HierarchicalMultiplatformProjectImportingTest.kt @@ -340,6 +340,86 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl } } + @Test + @PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) + fun testPrecisePlatformsHmpp() { + configureByFiles() + importProject() + + val jvm = JvmPlatforms.defaultJvmPlatform + val anyNative = NativePlatforms.unspecifiedNativePlatform + val linux = NativePlatforms.nativePlatformBySingleTarget(KonanTarget.LINUX_X64) + val macos = NativePlatforms.nativePlatformBySingleTarget(KonanTarget.MACOS_X64) + + checkProjectStructure(exhaustiveModuleList = true, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) { + module("my-app") { + targetPlatform(jvm) + } + + module("my-app.commonMain") { targetPlatform(jvm, anyNative) } + module("my-app.commonTest") { targetPlatform(jvm, anyNative) } + + module("my-app.jvmAndLinuxMain") { targetPlatform(jvm, anyNative) } + module("my-app.jvmAndLinuxTest") { targetPlatform(jvm, anyNative) } + + module("my-app.jvmMain") { targetPlatform(jvm) } + module("my-app.jvmTest") { targetPlatform(jvm) } + + module("my-app.linuxX64Main") { targetPlatform(linux) } + module("my-app.linuxX64Test") { targetPlatform(linux) } + + module("my-app.macosX64Main") { targetPlatform(macos) } + module("my-app.macosX64Test") { targetPlatform(macos) } + } + } + + @Test + @PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) + fun testPrecisePlatformsWithUnrelatedModuleHmpp() { + configureByFiles() + importProject() + + val jvm = JvmPlatforms.defaultJvmPlatform + val anyNative = NativePlatforms.unspecifiedNativePlatform + val js = JsPlatforms.defaultJsPlatform + val linux = NativePlatforms.nativePlatformBySingleTarget(KonanTarget.LINUX_X64) + val macos = NativePlatforms.nativePlatformBySingleTarget(KonanTarget.MACOS_X64) + + checkProjectStructure(exhaustiveModuleList = true, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) { + // root project + module("my-app") { + targetPlatform(jvm) + } + + module("my-app.commonMain") { targetPlatform(jvm, anyNative, js) } // :( should be (jvm, anyNative) + module("my-app.commonTest") { targetPlatform(jvm, anyNative, js) } // :( should be (jvm, anyNative) + + module("my-app.jvmAndLinuxMain") { targetPlatform(jvm, anyNative) } + module("my-app.jvmAndLinuxTest") { targetPlatform(jvm, anyNative) } + + module("my-app.jvmMain") { targetPlatform(jvm) } + module("my-app.jvmTest") { targetPlatform(jvm) } + + module("my-app.linuxX64Main") { targetPlatform(linux) } + module("my-app.linuxX64Test") { targetPlatform(linux) } + + module("my-app.macosX64Main") { targetPlatform(macos) } + module("my-app.macosX64Test") { targetPlatform(macos) } + + + // submodule + module("my-app.submodule") { targetPlatform(jvm) } + + module("my-app.submodule.commonMain") { targetPlatform(js, jvm, anyNative) } // :( should be (js, jvm) + module("my-app.submodule.commonTest") { targetPlatform(js, jvm, anyNative) } // :( should be (js, jvm) + + module("my-app.submodule.jvmMain") { targetPlatform(jvm) } + module("my-app.submodule.jvmTest") { targetPlatform(jvm) } + + module("my-app.submodule.jsMain") { targetPlatform(js) } + module("my-app.submodule.jsTest") { targetPlatform(js) } + } + } private fun checkProjectStructure( exhaustiveModuleList: Boolean = true, exhaustiveSourceSourceRootList: Boolean = true, diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/build.gradle.kts b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/build.gradle.kts new file mode 100644 index 00000000000..02d7e599cad --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/build.gradle.kts @@ -0,0 +1,71 @@ +/** + * commonMain---- + * / \ + * jvmAndLinuxMain \ + * / \ \ + * jvm linuxX64 macosX64 + * + * (the tests structure is the same) + */ + +buildscript { + repositories { + {{kts_kotlin_plugin_repositories}} + } +} + +repositories { + {{kts_kotlin_plugin_repositories}} +} + +plugins { + kotlin("multiplatform").version("{{kotlin_plugin_version}}") +} + +group = "project" +version = "1.0" + +kotlin { + jvm() + linuxX64() + macosX64() + + sourceSets { + val commonMain by getting { + } + + val commonTest by getting { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + val jvmAndLinuxMain by creating { + dependsOn(commonMain) + } + + val jvmAndLinuxTest by creating { + dependsOn(commonTest) + } + + val jvmMain by getting { + dependsOn(jvmAndLinuxMain) + } + + val jvmTest by getting { + dependsOn(jvmAndLinuxTest) + dependencies { + implementation(kotlin("test-junit")) + } + } + + val linuxX64Main by getting { + dependsOn(jvmAndLinuxMain) + } + + val linuxX64Test by getting { + dependsOn(jvmAndLinuxTest) + } + } +} \ No newline at end of file diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/gradle.properties b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/gradle.properties new file mode 100644 index 00000000000..5947cb440c4 --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/gradle.properties @@ -0,0 +1 @@ +kotlin.mpp.enableGranularSourceSetsMetadata=true diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/settings.gradle.kts b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/settings.gradle.kts new file mode 100644 index 00000000000..176c45caae2 --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsHmpp/settings.gradle.kts @@ -0,0 +1,9 @@ +pluginManagement { + repositories { + {{kts_kotlin_plugin_repositories}} + } +} + +rootProject.name = "my-app" + +enableFeaturePreview("GRADLE_METADATA") \ No newline at end of file diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/build.gradle.kts b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/build.gradle.kts new file mode 100644 index 00000000000..02d7e599cad --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/build.gradle.kts @@ -0,0 +1,71 @@ +/** + * commonMain---- + * / \ + * jvmAndLinuxMain \ + * / \ \ + * jvm linuxX64 macosX64 + * + * (the tests structure is the same) + */ + +buildscript { + repositories { + {{kts_kotlin_plugin_repositories}} + } +} + +repositories { + {{kts_kotlin_plugin_repositories}} +} + +plugins { + kotlin("multiplatform").version("{{kotlin_plugin_version}}") +} + +group = "project" +version = "1.0" + +kotlin { + jvm() + linuxX64() + macosX64() + + sourceSets { + val commonMain by getting { + } + + val commonTest by getting { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + val jvmAndLinuxMain by creating { + dependsOn(commonMain) + } + + val jvmAndLinuxTest by creating { + dependsOn(commonTest) + } + + val jvmMain by getting { + dependsOn(jvmAndLinuxMain) + } + + val jvmTest by getting { + dependsOn(jvmAndLinuxTest) + dependencies { + implementation(kotlin("test-junit")) + } + } + + val linuxX64Main by getting { + dependsOn(jvmAndLinuxMain) + } + + val linuxX64Test by getting { + dependsOn(jvmAndLinuxTest) + } + } +} \ No newline at end of file diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/gradle.properties b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/gradle.properties new file mode 100644 index 00000000000..5947cb440c4 --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/gradle.properties @@ -0,0 +1 @@ +kotlin.mpp.enableGranularSourceSetsMetadata=true diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/settings.gradle.kts b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/settings.gradle.kts new file mode 100644 index 00000000000..4b74ba26c9f --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/settings.gradle.kts @@ -0,0 +1,11 @@ +pluginManagement { + repositories { + {{kts_kotlin_plugin_repositories}} + } +} + +rootProject.name = "my-app" + +enableFeaturePreview("GRADLE_METADATA") + +include(":submodule") \ No newline at end of file diff --git a/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/submodule/build.gradle.kts b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/submodule/build.gradle.kts new file mode 100644 index 00000000000..d828b0d967c --- /dev/null +++ b/idea/testData/gradle/hierarchicalMultiplatformImport/precisePlatformsWithUnrelatedModuleHmpp/submodule/build.gradle.kts @@ -0,0 +1,18 @@ +buildscript { + repositories { + {{kts_kotlin_plugin_repositories}} + } +} + +repositories { + {{kts_kotlin_plugin_repositories}} +} + +plugins { + kotlin("multiplatform") +} + +kotlin { + js() + jvm() +} \ No newline at end of file