Initial support for enforcedPlatform in Gradle MPP config

This commit is contained in:
Sebastian Aigner
2022-06-30 16:31:59 +02:00
committed by Space
parent ef482bb126
commit 39844af876
2 changed files with 44 additions and 0 deletions
@@ -56,6 +56,12 @@ interface KotlinDependencyHandler {
fun project(notation: Map<String, Any?>): ProjectDependency
fun enforcedPlatform(notation: Any): Dependency =
project.dependencies.enforcedPlatform(notation)
fun enforcedPlatform(notation: Any, configureAction: Action<in Dependency>): Dependency =
project.dependencies.enforcedPlatform(notation, configureAction)
@Deprecated("Declaring NPM dependency without version is forbidden")
fun npm(name: String): Dependency
@@ -0,0 +1,38 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.mpp.buildProjectWithMPP
import org.jetbrains.kotlin.gradle.mpp.kotlin
import kotlin.test.Test
import kotlin.test.assertTrue
class EnforcedPlatformTest : MultiplatformExtensionTest() {
@Test
fun `using enforcedPlatform adds BOM dependency correctly`() {
val project = buildProjectWithMPP {
kotlin {
js("browser") {
browser {
binaries.executable()
}
}
sourceSets.getByName("browserMain").apply {
dependencies {
implementation(enforcedPlatform("test:enforced-platform-dependency"))
}
}
}
}
with(project.evaluate()) {
val hasEnforcedPlatformDependency = configurations.getByName("browserMainImplementation").allDependencies.any {
it.group == "test" && it.name == "enforced-platform-dependency" && it.version == null
}
assertTrue(hasEnforcedPlatformDependency, "Could not find enforced platform dependency")
}
}
}