I’m trying to migrate from gradle `buildscript` , ...
# gradle
p
I’m trying to migrate from gradle
buildscript
,
classpath
,
allProjects
etc. to
pluginManagement
,
plugins
,
dependencyResolutionManagement
etc. However errors like this happen on sync:
Copy code
Error resolving plugin [id: 'org.jetbrains.kotlin.multiplatform', version: '1.8.10', apply: false]
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
I suspect that this might be connected to the fact that I’m also using convention-plugins in
buildSrc
and therefore add several gradle plugins as dependencies in
build.gradle.kts
of
buildSrc
like this (but I’m not sure how to rewrite it):
Copy code
plugins {
    `kotlin-dsl`
}

repositories {
    google()
    mavenCentral()
    mavenLocal()
    maven(url = "<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
}

dependencies {
    implementation(Deps.Kotlin.gradlePlugin)
    // ...
}
How can this be fixed?
v
Where do you actually have
id("org.jetbrains.kotlin.multiplatform") version "1.8.10" apply false
?
p
In root
build.gradle.kts
plugins
block
a
here’s what I like to do: in
buildSrc/build.gradle.kts
add all Gradle plugins in the
dependencies {}
block (using the Maven GAV coordinates, not the plugin ID). Then I don’t need to add the plugin versions anywhere else, they’re defined in a single place. This looks like what you’ve done too, so you probably just need to remove the versions:
Copy code
plugins {
  kotlin("multiplatform") // no version needed - it's in buildSrc/build.gradle.kts
}
v
Well, just remove it if you have it as
implementation
dependency in
buildSrc
anyway. That already serves the same purpose.
so you probably just need to remove the versions
No, the whole line 😉
246 Views