in a root `build.gradle.kts` you can set the versi...
# gradle
j
in a root
build.gradle.kts
you can set the version for all plugins:
Copy code
plugins {

	val kotlinVersion = "1.4.21"
	val shadowVersion = "6.0.0"

	kotlin("multiplatform").version(kotlinVersion).apply(false)
	kotlin("plugin.serialization").version(kotlinVersion).apply(false)
	id("com.github.johnrengelman.shadow").version(shadowVersion).apply(false)

}
is there a way to do it with dependencies as well? I've tried adding a dependency block with a
constraint{...}
, but the IDE doesn't allow me to add an
implementation(...)
inside such a constraint block
j
Note that you can set the versions of plugins that way, too: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_version_management
j
do i need a specific version of gradle to make use of dependency constraints ?
let me try upgrade my gradle, I'm on 6.5
j
You need to use it inside a specific project, where the java-platform plugin is applied. And then, in “regular” projects, you declare dependencies on this specific platform project to benefit from its declared versions.
i.e. in a “platform” subproject, you would have
Copy code
plugins {
    `java-platform`
}

repositories {
    mavenCentral()
}

dependencies {
    constraints {
        api("foo:bar:1.2.3")
    }
}
And in other subprojects, you would have
Copy code
dependencies {
    implementation(platform(project(":platform")))

    implementation("foo:bar")
}
g
Yep, platform is the way to go for now In 7.0 we will probably get versios catalog api and finally it would be concise, simple way for version declaration https://github.com/gradle/gradle/issues/15352
j
thank you, I'll take the platform(project( thing for a test drive tonight!