[Gradle] IdeResolveSourceDependenciesTest: Implement jvmAndAndroid test
KT-55112
This commit is contained in:
committed by
Space Team
parent
d935e41862
commit
38446dc3e8
+59
-13
@@ -3,20 +3,20 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("FunctionName")
|
||||
@file:Suppress("FunctionName", "DuplicatedCode")
|
||||
|
||||
package org.jetbrains.kotlin.gradle.ide
|
||||
|
||||
import org.jetbrains.kotlin.gradle.applyMultiplatformPlugin
|
||||
import org.jetbrains.kotlin.gradle.buildProject
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.enableDefaultStdlibDependency
|
||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinSourceDependency
|
||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.assertMatches
|
||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.dependsOnDependency
|
||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.friendSourceDependency
|
||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.regularSourceDependency
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.kotlinIdeMultiplatformImport
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
class IdeResolveSourceDependenciesTest {
|
||||
@@ -56,22 +56,18 @@ class IdeResolveSourceDependenciesTest {
|
||||
producer.evaluate()
|
||||
consumer.evaluate()
|
||||
|
||||
fun resolveConsumerSourceSet(sourceSetName: String) = consumer.kotlinIdeMultiplatformImport
|
||||
.resolveDependencies(consumer.multiplatformExtension.sourceSets.getByName(sourceSetName))
|
||||
.filterIsInstance<IdeaKotlinSourceDependency>()
|
||||
|
||||
resolveConsumerSourceSet("commonMain").assertMatches(
|
||||
consumer.resolveSourceDependencies("commonMain").assertMatches(
|
||||
regularSourceDependency(":producer:commonMain")
|
||||
)
|
||||
|
||||
resolveConsumerSourceSet("nativeMain").assertMatches(
|
||||
consumer.resolveSourceDependencies("nativeMain").assertMatches(
|
||||
regularSourceDependency(":producer:commonMain"),
|
||||
regularSourceDependency(":producer:nativeMain"),
|
||||
regularSourceDependency(":producer:linuxMain"),
|
||||
dependsOnDependency(":consumer:commonMain"),
|
||||
)
|
||||
|
||||
resolveConsumerSourceSet("nativeTest").assertMatches(
|
||||
consumer.resolveSourceDependencies("nativeTest").assertMatches(
|
||||
regularSourceDependency(":producer:commonMain"),
|
||||
regularSourceDependency(":producer:nativeMain"),
|
||||
regularSourceDependency(":producer:linuxMain"),
|
||||
@@ -81,7 +77,7 @@ class IdeResolveSourceDependenciesTest {
|
||||
dependsOnDependency(":consumer:commonTest"),
|
||||
)
|
||||
|
||||
resolveConsumerSourceSet("linuxMain").assertMatches(
|
||||
consumer.resolveSourceDependencies("linuxMain").assertMatches(
|
||||
regularSourceDependency(":producer:commonMain"),
|
||||
regularSourceDependency(":producer:nativeMain"),
|
||||
regularSourceDependency(":producer:linuxMain"),
|
||||
@@ -89,7 +85,7 @@ class IdeResolveSourceDependenciesTest {
|
||||
dependsOnDependency(":consumer:nativeMain"),
|
||||
)
|
||||
|
||||
resolveConsumerSourceSet("linuxTest").assertMatches(
|
||||
consumer.resolveSourceDependencies("linuxTest").assertMatches(
|
||||
regularSourceDependency(":producer:commonMain"),
|
||||
regularSourceDependency(":producer:nativeMain"),
|
||||
regularSourceDependency(":producer:linuxMain"),
|
||||
@@ -100,4 +96,54 @@ class IdeResolveSourceDependenciesTest {
|
||||
dependsOnDependency(":consumer:nativeTest"),
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("No solution yet")
|
||||
@Test
|
||||
fun `test - multiplatform to multiplatform - sample 1 - jvmAndAndroid`() {
|
||||
assumeAndroidSdkAvailable()
|
||||
val root = buildProject()
|
||||
|
||||
fun Project.setup() {
|
||||
enableDefaultStdlibDependency(false)
|
||||
applyMultiplatformPlugin()
|
||||
androidLibrary { compileSdk = 33 }
|
||||
|
||||
multiplatformExtension.apply {
|
||||
targetHierarchy.default {
|
||||
common {
|
||||
group("jvmAndAndroid") {
|
||||
jvm()
|
||||
android()
|
||||
}
|
||||
}
|
||||
}
|
||||
linuxX64()
|
||||
linuxArm64()
|
||||
jvm()
|
||||
android()
|
||||
}
|
||||
}
|
||||
|
||||
val producer = buildProject({ withParent(root).withName("producer") }, Project::setup)
|
||||
val consumer = buildProject({ withParent(root).withName("consumer") }, Project::setup)
|
||||
consumer.multiplatformExtension.sourceSets.getByName("commonMain").dependencies {
|
||||
implementation(project(":producer"))
|
||||
}
|
||||
|
||||
root.evaluate()
|
||||
producer.evaluate()
|
||||
consumer.evaluate()
|
||||
|
||||
consumer.resolveSourceDependencies("jvmAndAndroidMain").assertMatches(
|
||||
regularSourceDependency(":producer:commonMain"),
|
||||
regularSourceDependency(":producer:jvmAndAndroidMain"),
|
||||
dependsOnDependency(":consumer:commonMain")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.resolveSourceDependencies(sourceSetName: String): List<IdeaKotlinSourceDependency> {
|
||||
return kotlinIdeMultiplatformImport
|
||||
.resolveDependencies(multiplatformExtension.sourceSets.getByName(sourceSetName))
|
||||
.filterIsInstance<IdeaKotlinSourceDependency>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user