Rob Elliot
03/14/2025, 12:31 PM2.1.10 in my project. Transitive dependencies are bringing in org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21 and org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.21.
Is it appropriate to force them up to the same version as so:
configurations.all {
resolutionStrategy {
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.10")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10")
}
}tapchicoma
03/14/2025, 12:45 PMresolutionStrategy.dependencySubstitution {
if (kotlinStdlibDependency.name != KOTLIN_STDLIB_JDK7_MODULE_NAME) {
it.substitute(it.module("org.jetbrains.kotlin:kotlin-stdlib-jdk7"))
.using(it.module("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlinStdlibDependency.version}"))
.because("kotlin-stdlib-jdk7 is now part of kotlin-stdlib")
}
it.substitute(it.module("org.jetbrains.kotlin:kotlin-stdlib-jdk8"))
.using(it.module("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinStdlibDependency.version}"))
.because("kotlin-stdlib-jdk8 is now part of kotlin-stdlib")
}
I am curious why it does not work in your case 🤔tapchicoma
03/14/2025, 12:48 PMVampire
03/14/2025, 12:49 PMkotlin-stdlib artifact also provide the capabilities of the jdk7 and jkd8 artifacts.Vampire
03/14/2025, 12:50 PMdependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.10")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10")
}
}tapchicoma
03/14/2025, 12:50 PMbut to substitute one dependency by a completely different one.Not entiirely true as all the code was merged into
kotlin-stdlibVampire
03/14/2025, 12:50 PMRob Elliot
03/14/2025, 12:51 PMimplementation there - is that not an issue?Vampire
03/14/2025, 12:51 PMNot entiirely true as all the code was merged intoBut your rule does not substitutekotlin-stdlib
kotlin-stdlib-jdk7 by kotlin-stdlib which it then probably should do 😉tapchicoma
03/14/2025, 12:53 PMtapchicoma
03/14/2025, 12:53 PM-jdk8 and -jdk7 are empty artifactstapchicoma
03/14/2025, 12:54 PMVampire
03/14/2025, 12:56 PMIt's always bothered me that I was specifying a specific configurationMost probably not. Maybe if you have that problem in anthere - is that not an issue?implementation
api dependency and resolve the apiElements configuration where implementation is not evolved or similar, but I would neglect that or just add a second configuration then.
That force is really a very heavy hammer that should be avoided if possible.
Iirc e.g. the "lovely" Spring Dependencymanagement Plugin uses it or something on the same level.
And it very often was a source of "why the hell does this strict version not work" or "where the hell is this version constraint coming from" and so on, as that is a very low-level thing that is also not properly represented in build scans or dependencies output or dependencyInsight output.
And if you would use a capability conflict like I suggested for this case, you would btw. also not have the problem with the configuration as that would again be for all, but working cleanly.Vampire
03/14/2025, 12:58 PMsince Kotlin 1.8.0Oh, I see, and thus also not the capability conflict, that's bad. I wonder that the artifacts are not version-aligned automatically. I was under the impression that Kotlin uses proper version aligning to ensure the artifacts are of the same version, but obviously it does not, maybe that is the bug then.and-jdk8are empty artifacts-jdk7
Vampire
03/14/2025, 12:59 PMdependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom:2.1.10"))
}Rob Elliot
03/14/2025, 12:59 PMtapchicoma
03/14/2025, 1:02 PMI wonder that the artifacts are not version-aligned automatically.That is because
kotlin-stdlib is a transitive dependency to -jdk7 which a transitive dependency for -jdk8Vampire
03/14/2025, 1:02 PMVampire
03/14/2025, 1:03 PM> I wonder that the artifacts are not version-aligned automatically.
That is becauseHow is that a reason to not align the versions?is a transitive dependency tokotlin-stdlibwhich a transitive dependency for-jdk7-jdk8
Vampire
03/14/2025, 1:03 PMtapchicoma
03/14/2025, 1:03 PMtapchicoma
03/14/2025, 1:04 PMVampire
03/14/2025, 1:04 PMRob Elliot
03/14/2025, 1:17 PM> It's always bothered me that I was specifying a specific configuration implementation there - is that not an issue?
Most probably not.
Maybe if you have that problem in an api dependency and resolve the apiElements configuration where implementation is not evolved or similar, but I would neglect that or just add a second configuration then.I suppose
api, runtime, testRuntime and testImplementation all basically inherit from implementation, so I can stop worrying about it and just use that. Thanks.Vampire
03/14/2025, 1:22 PMruntime and testRuntime do not exist since years.
implementation extends from api
testImplementation extends from implementation
But neither of these you resolve.
implementation though lands in compileClasspath, runtimeClasspath, testCompileClasspath, and `testRuntimeClasspath`so a constraint or platform declared on it should work for all your needs usually unless you have additional things.Vampire
03/14/2025, 1:25 PMplease open an issue for improvementhttps://youtrack.jetbrains.com/issue/KT-76006