Dependency constraints in Gradle Kotlin Multiplatform plugin

Is it possible to use Gradle dependency constraints (https://docs.gradle.org/current/userguide/dependency_constraints.html) with the Gradle Kotlin Multiplatform plugin? I would like to be able to specify the version to use for a dependency in the parent project and have it automatically applied in the child project as shown in the example below.

This script fails to compile as definition for the constraints block cannot be found.

Thanks in advance.

settings.gradle

rootProject.name = 'parent'
include(':child')

build.gradle.kts (Parent project)

plugins {
    kotlin("multiplatform") version "1.3.72"
}

...

subprojects {
    kotlin {
        sourceSets {
            jvm().compilations["main"].defaultSourceSet {
                dependencies {
                    constraints { // <= Compilation error: Unresolved reference: constraints
                        implementation("org.hibernate:hibernate-core:5.4.3.Final")
                    }
                }
            }
        }
    }
}

child/build.gradle.kts (Child project)

plugins {
    kotlin("multiplatform")
}

kotlin {
    jvm {
        ...
    }

    sourceSets {
        jvm().compilations["main"].defaultSourceSet {
            dependencies {
                implementation("org.hibernate:hibernate-core")
            }
        }
    }
}
1 Like

Iā€™m struggling with the exact same issue, anybody?