Gradle "plugin already on the classpath must not include a version" in CI
Gradle loads a plugin once for the build classpath. When a subproject requests that same plugin with an explicit version while the root project already put it on the classpath, the request is invalid and the build fails before configuration completes.
What this error means
The build fails with "Error resolving plugin [id: 'X', version: 'Y']" and "The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so the request must not include a version number."
> Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.9.22']
> The request for this plugin could not be satisfied because the plugin is
already on the classpath with an unknown version, so the request must not
include a version number.Common causes
A subproject repeats the version of a root-applied plugin
The root build (or a convention plugin) already applied the plugin, so a subproject plugins {} block must apply it without a version.
The plugin sits on the buildscript classpath
The plugin was added via buildscript { dependencies }, giving it an unknown version on the classpath, which forbids a versioned request.
How to fix it
Apply the plugin without a version in subprojects
- Declare the version once, at the root or in
plugins {}withapply false. - In each subproject, request the plugin id with no version.
- Re-run the build so the single classpath version is reused.
// settings.gradle.kts or root build.gradle.kts
plugins { id("org.jetbrains.kotlin.jvm") version "1.9.22" apply false }
// subproject build.gradle.kts
plugins { id("org.jetbrains.kotlin.jvm") }Centralize plugin versions
Define plugin versions in one place (the root or a version catalog) so subprojects never restate them.
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.22" }How to prevent it
- Declare plugin versions once and apply them without a version downstream.
- Use
apply falseat the root for plugins applied in subprojects. - Prefer a version catalog so plugin versions are not duplicated.