is there some way to do something like `plugins{ k...
# gradle
k
is there some way to do something like
plugins{ kotlin("jvm") version extra["kotlinVersion"] }
in kotlin-dsl? (to keep nested projects using the same version of kotlin) The above complains that extra isnt visible from the plugins block
m
k
it is, thanks for the link. i suppose using gradle properties is a workaround...
c
Yes, frustrating, isn't it? I work around it by omitting version in
plugins
block and setting it in `settings.gradle.kts`:
Copy code
pluginManagement {
	repositories {
		gradlePluginPortal()
	}
	resolutionStrategy {
		eachPlugin {
			val kotlinVersion = gradle.rootProject.extra["kotlinVersion"] as String
			if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
				println("Using Kotlin version: $kotlinVersion for ${requested.id.id}")
				useVersion(kotlinVersion)
			}
		}
	}
}
2
m
ive done the same thing, sometimes defining the version in a file like
gradle/kotlin-version.txt
c
@mkobit I'm just curious why in custom file instead of
gradle.properties
?
m
i did it before if i wanted to use the same version in
buildSrc
then i could read it out of the file, but that may not be entirely necessary anymore
c
I see