It appears that kotlin-dsl, in combination with `f...
# dependency-management
j
It appears that kotlin-dsl, in combination with
failOnVersionConflict
resolution strategy, and dependency locking
lockAllConfigurations
turned on, ends up requiring also the exact same version of Gradle to reproduce the same build. This appears to be because the kotlin-dsl plugin aggressively writes the stdlib and other dependencies into the graph:
Copy code
* What went wrong:
Execution failed for task ':dependencies'.
> Could not resolve all dependencies for configuration ':compileClasspath'.
   > Conflicts found for the following modules:
       - org.jetbrains.kotlin:kotlin-stdlib between versions 1.9.24 and 1.9.22
       - org.jetbrains.kotlin:kotlin-reflect between versions 1.9.24 and 1.9.22
In order to correctly reproduce a Gradle build that uses Kotlin, is it also required that I use the exact same version of Gradle to invoke the exact same Kotlin compiler as well? Or is it possible to ask Kotlin to use different dependencies in my project?
a
what plugins do you have applied in the build script?
j
Copy code
plugins {
  `kotlin-dsl`
  `java-gradle-plugin`
}
It appears java-gradle-plugin is redundant, so really it's just
Copy code
plugins {
  `kotlin-dsl`
}
Is it valid to do the following instead?
Copy code
plugins {
  `java-gradle-plugin`
  kotlin("jvm") version "1.9.22"
}
Hmmm. It appears
kotlin-dsl
does quite a bit of work I'd be missing. So it appears this plugin is not supported in combination with a the reproducible build features?
a
ah okay, if you're just using the
kotlin-dsl
plugin then I would expect that it should work. I guessed you were applying conflicting plugins.
have you seen the guide here https://cookbook.gradle.org/plugin-development/kotlin-plugins/? It doesn't answer your question about
failOnVersionConflict
, but it is useful
j
Perhaps with some combination of
coreLibrariesVersion
and other flags, I can stop the stdlib version from shifting around.
None of this is viable as the
kotlin-dsl
plugin does most of the work needed to make Kotlin a drop-in replacement for the Groovy syntax, and it is extremely rigid about versions: https://github.com/gradle/gradle/blob/master/platforms/core-configuration/kotlin-d[…]otlin/org/gradle/kotlin/dsl/plugins/base/KotlinDslBasePlugin.kt
I've gathered enough data to file a bug: https://github.com/gradle/gradle/issues/32130