Gradle version catalogs for plugins with group

Viewed 1103

I am trying to figure out whether it is possible to declare plugin in version catalogs if it has a group also.

If i try to declare it like this

libs.versions.toml

[plugins]
google-services = { id = "com.google.gms:google-services", version = "4.3.10" }

build.gradle
plugins {
    alias(libs.plugins.google.services)
}

I receive the next error

> plugin id 'com.google.gms:google-services' is invalid: Plugin id contains invalid char ':' (only ASCII alphanumeric characters, '.', '_' and '-' characters are valid)

Any suggestions how to use it properly for plugins?

1 Answers

With the help of the gradle community in telegram i've found the solution

In the settings.gradle.kts need to declare such section

pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id.startsWith("com.google.gms.google-services")) {
                useModule("com.google.gms:google-services:${requested.version}")
            }
        }
    }
}

In the libs.version.toml file declare it like this

[plugins]
google-services = { id = "com.google.gms.google-services", version = "4.3.10" }

In the build.gradle apply it like this

plugins {
    alias(libs.plugins.google.services)
}
Related