Initial support for enforcedPlatform in Gradle MPP config
This commit is contained in:
+6
@@ -56,6 +56,12 @@ interface KotlinDependencyHandler {
|
|||||||
|
|
||||||
fun project(notation: Map<String, Any?>): ProjectDependency
|
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")
|
@Deprecated("Declaring NPM dependency without version is forbidden")
|
||||||
fun npm(name: String): Dependency
|
fun npm(name: String): Dependency
|
||||||
|
|
||||||
|
|||||||
+38
@@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user