Add a bunch of tests on corner-cases in Gradle MPP Import
For most of those the behaviour isn't set in stone, though at the moment of making that commit we're more or less sure that it's reasonable. Behaviour in some cases might be more strictly enforces (as much as you can enforce something in esoteric cases with misconfigured project sturcture). Those are marked with comments with '!'.
This commit is contained in:
+147
@@ -420,6 +420,153 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
||||
module("my-app.submodule.jsTest") { targetPlatform(js) }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster)
|
||||
fun testOrphanSourceSet() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val jvm = JvmPlatforms.defaultJvmPlatform
|
||||
val js = JsPlatforms.defaultJsPlatform
|
||||
val native = NativePlatforms.unspecifiedNativePlatform
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
module("my-app.commonMain") {
|
||||
// must not be (jvm, js, native)
|
||||
targetPlatform(jvm, js)
|
||||
}
|
||||
|
||||
module("my-app.orphan") {
|
||||
targetPlatform(jvm, js)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster)
|
||||
fun testSourceSetIncludedIntoCompilationDirectly() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val jvm = JvmPlatforms.defaultJvmPlatform
|
||||
val js = JsPlatforms.defaultJsPlatform
|
||||
val native = NativePlatforms.unspecifiedNativePlatform
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
module("my-app.commonMain") {
|
||||
targetPlatform(jvm, js) // must not be (jvm, js, native)
|
||||
}
|
||||
|
||||
module("my-app.includedIntoJvm") {
|
||||
targetPlatform(jvm) // !
|
||||
}
|
||||
|
||||
module("my-app.includedIntoJvmAndJs") {
|
||||
targetPlatform(jvm, js) // !
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster)
|
||||
fun testDefaultSourceSetDependsOnDefaultSourceSet() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val jvm = JvmPlatforms.defaultJvmPlatform
|
||||
val js = JsPlatforms.defaultJsPlatform
|
||||
val native = NativePlatforms.unspecifiedNativePlatform
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
module("my-app.commonMain") {
|
||||
targetPlatform(jvm, js) // must not be (jvm, js, native)
|
||||
}
|
||||
|
||||
module("my-app.intermediateBetweenJsAndCommon") {
|
||||
targetPlatform(jvm, js) // must not be (jvm, js, native)
|
||||
}
|
||||
|
||||
module("my-app.jsMain") {
|
||||
targetPlatform(js) // must not be (jvm, js)
|
||||
}
|
||||
|
||||
module("my-app.jvmMain") {
|
||||
targetPlatform(jvm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster)
|
||||
fun testDefaultSourceSetIncludedIntoAnotherCompilationDirectly() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val jvm = JvmPlatforms.defaultJvmPlatform
|
||||
val js = JsPlatforms.defaultJsPlatform
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
module("my-app.jvmMain") {
|
||||
targetPlatform(jvm) // must not be (jvm, js)
|
||||
}
|
||||
|
||||
module("my-app.jsMain") {
|
||||
targetPlatform(js)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster)
|
||||
fun testSourceSetsWithDependsOnButNotIncludedIntoCompilation() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val jvm = JvmPlatforms.defaultJvmPlatform
|
||||
val js = JsPlatforms.defaultJsPlatform
|
||||
val native = NativePlatforms.unspecifiedNativePlatform
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
|
||||
// (jvm, js, native) is highly undesirable
|
||||
module("my-app.danglingOnJvm") {
|
||||
targetPlatform(jvm, js)
|
||||
}
|
||||
|
||||
module("my-app.commonMain") {
|
||||
targetPlatform(jvm, js)
|
||||
}
|
||||
|
||||
module("my-app.danglingOnCommon") {
|
||||
targetPlatform(jvm, js)
|
||||
}
|
||||
|
||||
module("my-app.danglingOnJvmAndJs") {
|
||||
targetPlatform(jvm, js)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster)
|
||||
fun testCustomAddToCompilationPlusDependsOn() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val jvm = JvmPlatforms.defaultJvmPlatform
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
module("my-app.includedIntoJvm") {
|
||||
targetPlatform(jvm) // !
|
||||
}
|
||||
|
||||
module("my-app.pseudoOrphan") {
|
||||
targetPlatform(jvm) // !
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkProjectStructure(
|
||||
exhaustiveModuleList: Boolean = true,
|
||||
exhaustiveSourceSourceRootList: Boolean = true,
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
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()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val pseudoOrphan by creating {
|
||||
}
|
||||
|
||||
val includedIntoJvm by creating {
|
||||
dependsOn(pseudoOrphan)
|
||||
}
|
||||
|
||||
jvm().compilations["main"].source(includedIntoJvm)
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
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()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {}
|
||||
|
||||
val intermediateBetweenJsAndCommon by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val jsMain by getting {
|
||||
dependsOn(intermediateBetweenJsAndCommon)
|
||||
}
|
||||
|
||||
val jvmMain by getting {
|
||||
dependsOn(jsMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
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()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val jvmMain by getting { }
|
||||
|
||||
js().compilations["main"].source(jvmMain)
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
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()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val orphan by creating { }
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
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()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val includedIntoJvm by creating { }
|
||||
val includedIntoJvmAndJs by creating { }
|
||||
|
||||
jvm().compilations["main"].source(includedIntoJvm)
|
||||
|
||||
jvm().compilations["main"].source(includedIntoJvmAndJs)
|
||||
js().compilations["main"].source(includedIntoJvmAndJs)
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
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()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting { }
|
||||
val jvmMain by getting { }
|
||||
val jsMain by getting { }
|
||||
|
||||
val danglingOnJvm by creating {
|
||||
dependsOn(jvmMain)
|
||||
}
|
||||
|
||||
val danglingOnCommon by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val danglingOnJvmAndJs by creating {
|
||||
dependsOn(jvmMain)
|
||||
dependsOn(jsMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
Reference in New Issue
Block a user