I’d like to write a plugin to enforce a rule within our project that any dependency that is available in our Gradle version catalog must be declared using the version catalog.
For example, it should throw an error on this:
dependencies {
implementation 'com.google.guava:guava:32.1.2-jre'
}
And then we want to allow:
dependencies {
implementation libs.guava.core
}
The main difficulty that I’m hitting is that when I look at the ModuleDependency
objects in DependencySet
, I do not see any way to detect if the dependency comes from the version catalog or not. I get normal name
and group
values.
How can I tell if a dependency is declared using the version catalog or the standard notation?