Move plugin version management to buildSrc/build.gradle.kts #1321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While researching a similar issue, I recently came across gradle/gradle#11090 (comment) (cc @sellmair ) about how the
pluginManagement{}
block insettings.gradle.kts
can't access logic defined inbuildSrc
.So I thought I'd share how I'm trying to solve that problem in some of my projects. Just in case this could be useful for this project, too.
There are two parts to this solution:
There is a second
buildSrc
project inside the existingbuildSrc
project. It only contains a shortbuild.gradle.kts
script and just compiles the sources of the firstbuildSrc
project one additional time, so those classes are on the classpath ofbuildSrc/build.gradle.kts
.At the moment this is not utilized in this pull request, but you could then add build logic to
buildSrc/src/main/kotlin
that can be reused in the buildscript ofbuildSrc
for e.g. plugin version management.This may sound like a hack, but in my experience this works pretty reliably.
The plugin versions are defined in
buildSrc/build.gradle.kts
asdependencies.implementation("‹…›")
instead of using thepluginManagement{}
block insettings.gradle.kts
.This gets rid of version inconsistencies like
dokka/settings.gradle.kts
Line 31 in b19ce3c
dokka/buildSrc/build.gradle.kts
Line 11 in b19ce3c
Also subprojects can then no longer declare conflicting plugin versions like
dokka/settings.gradle.kts
Line 32 in b19ce3c
dokka/runners/gradle-plugin/build.gradle.kts
Line 6 in b19ce3c
Plugin request for plugin already on the classpath must not include a version
.