https://kotlinlang.org logo
Title
m

Marc Knaup

01/17/2019, 5:30 PM
Is there an easier way to force Gradle to use the same module version for all Kotlin modules?
configurations {
		all {
			resolutionStrategy.eachDependency {
				if (requested.group == "org.jetbrains.kotlin") {
					useVersion(embeddedKotlinVersion)
					because("All Kotlin modules must have the same version.")
				}
			}
		}
	}
Something like that being part of the Kotlin Gradle Plugin would be great, but with configurable version of course.
c

Czar

01/17/2019, 5:33 PM
isn't it working like that already if you apply kotlin plugin? My understanding was that plugin's version is used for all relevant dependencies.
m

Marc Knaup

01/17/2019, 5:39 PM
There was a transitive dependency in my project which caused Gradle to downgrade
kotlin-reflect
from Kotlin 1.3 to 1.2 in some configurations even though I had
testImplementation(kotlin("reflect"))
in my project.
c

Czar

01/17/2019, 6:12 PM
in that case what you wrote is your best bet.
n

Nikky

01/17/2019, 6:45 PM
you can also do
testImplementation(kotlin("reflect", embeddedKotlinVersion))
i think
m

magnusj

01/18/2019, 3:29 AM
I haven’t used it, but shouldn’t dependency constraints help here?
n

Nikky

01/18/2019, 8:34 AM
this? https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:dependency_constraints looks like this could be done in a init script or on the rootproject via
allProjects { dependencies { contraints { .. } } }
👍 1
i will alos have to play with that new feature