In a gradle project I have a build that uses some Java tooling as part of its build machinery, but is not, itself, a Java project. One of the toolings dependencies (javaparser) has a dependency on Guava.
For historical reasons that project's build.gradle.kts applied the
java-library plugin. When I removed it because its default tasks were causing
problems with other tasks and, as noted, no Java artifacts were being produced,
the build failed with an error:
Variant Selection Exception:
org.gradle.internal.component.resolution.failure.exception.VariantSelectionByAttributesException
caused by Resolution Failure:
org.gradle.internal.component.resolution.failure.type.NoCompatibleVariantsFailure
Gradle can no longer resolve a Guava variant that it can use.
This project is a minimal repro. It contains two sub-projects, java_lib and
non_java whose build.gradle.kts differ only in the plugin they apply.
non_java applies the base plugin, and java_lib applies the java-library
plugin. They both contain a simple configuration which declares a dependency on
Guava.
Running ./gradlew java_lib:dependencies shows that Guava resolves fine, and
./gradlew non_java:depdendencies shows the failure.
This is defintely unexpected behvaiour, and seems like buggy behaviour, though I am really not sure if this is a Gradle problem or a Guava Gradle metadata problem.