Slackbot
04/05/2023, 9:03 AMAdam
04/05/2023, 9:04 AMid("org.gradle.kotlin.kotlin-dsl") version "3.2.6"
with
`kotlin-dsl`
(including the backticks)Rohde Fischer
04/05/2023, 9:06 AMAdam
04/05/2023, 9:06 AMRohde Fischer
04/05/2023, 9:07 AMAdam
04/05/2023, 9:09 AMThe request for this plugin could not be satisfied because the plugin is already on the classpathThis is a long story…. but basically there’s probably 10 different ways to set the version of a Gradle plugin, and most of those can’t be used together - yes it’s confusing! Under the hood it’s related to classpaths and Gradle needs to have a consistent classpath… Anyway, because you’re using buildSrc and you’ve defined the Kotlin Gradle plugin version in there (which is the correct thing to do), then this will enforce the Kotlin Gradle plugin version for the whole project. So, if you apply the Kotlin Gradle plugin anywhere else, then remove the version
// ./subproject-foo/build.gradle.kts
plugins {
kotlin("jvm") // version "..."
}
and Gradle will pick up the version from buildSrc/build.gradle.kts
Thomas Broyer
04/05/2023, 9:10 AMThomas Broyer
04/05/2023, 9:12 AMRohde Fischer
04/05/2023, 9:13 AMRohde Fischer
04/05/2023, 9:14 AMAdam
04/05/2023, 9:18 AMkotlin-dsl
is a shortcut for applying the Kotlin DSL with a version that’s compatible with the current Gradle version. You don’t have to use the recommended version, but it’s wise. Maybe Ktor needed a newer version of Kotlin DSL, but couldn’t update Gradle?Rohde Fischer
04/05/2023, 9:20 AMAdam
04/05/2023, 9:21 AMkotlin-dsl
and it should take you to the source code, but it’s not working on my machine. I thought it was fixed… https://github.com/gradle/gradle/issues/20995Rohde Fischer
04/05/2023, 10:13 AMAdam
04/05/2023, 10:13 AMAdam
04/05/2023, 10:18 AMkotlin-dsl
(the newer IJ versions seems to skip auto-indexing the Gradle jars to improve startup)
So if you’re using Gradle 8 and manually applied Kotlin DSL version 3.2.6, then you’d be missing out :)Shaun Reich
04/05/2023, 2:03 PMincludeBuild
https://gradle-community.slack.com/archives/CAHSN3LDN/p1680685968225419?thread_ts=1680685390.572419&cid=CAHSN3LDNThomas Broyer
04/05/2023, 3:03 PMplugins { id("plugin.id") version "plugin.version" apply false }
in the root `build.gradle`/`build.gradle.kts`
• use pluginManagement { plugins { id("plugin.id") version "plugin.version" }
in the `settings.gradle`/`settings.gradle.kts`
• use dependencies in `buildSrc/build.gradle`/`buildSrc/build.gradle.kts` (or the `build.gradle`/`build.gradle.kts` of a build included with pluginManagement { includeBuild("build-logic") }
)
The last one is the only way to get the plugins available in your precompiled script plugins (in the buildSrc
or "build-logic"
build), so I tend to declare all my plugin dependencies there and not use the others at all.
Fwiw, I also use version catalogs, so I actually declare the versions in the version catalog's TOML file, and then use those to actually declare the dependencies. I never use the plugins { alias(…) }
(except actually in the buildSrc/build.gradle.kts
or build-logic/build.gradle.kts
)
Here's an example: https://github.com/tbroyer/gradle-incap-helper/blob/main/build-logic/build.gradle.kts (other relevant files: settings.gradle.kts
, build-logic/settings.gradle.kts
and of course gradle/libs.versions.toml
)
(also note that I actually use all those plugins from precompiled script plugins, but it doesn't really matter: the included build will be added to build's classpath, so any plugin in its dependencies is available to the build)
This other example uses a buildSrc
instead of an included build: https://github.com/tbroyer/auto-delegateShaun Reich
04/05/2023, 3:32 PMAdam
04/05/2023, 3:34 PMAdam
04/05/2023, 3:34 PMShaun Reich
04/05/2023, 3:38 PMAdam
04/05/2023, 3:40 PMThomas Broyer
04/05/2023, 3:47 PMShaun Reich
04/05/2023, 4:02 PMShaun Reich
04/05/2023, 4:02 PM