Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle 6.x isn't able to pick right Guava variant #7059

Closed
1 task done
GeertZijlmans1 opened this issue Feb 29, 2024 · 3 comments
Closed
1 task done

Gradle 6.x isn't able to pick right Guava variant #7059

GeertZijlmans1 opened this issue Feb 29, 2024 · 3 comments
Assignees
Labels
P3 type=defect Bug, not working as expected

Comments

@GeertZijlmans1
Copy link

GeertZijlmans1 commented Feb 29, 2024

Description

I have a Java application which is build using Gradle 6.8.3 and uses Microsoft's Graph SDK v6.3.0. The Graph SDK has a transitive dependency on (and requires) guava 33.0.0-jre.

Gradle 6.8.3 is a hard requirement and we cannot upgrade to a newer version of Gradle soon.

Example

* Install Gradle 6.x (e.g. 6.8.3) 
* Create a Java application which uses Gradle to build jar for it and add the Graph SDK v6.3.0 as a dependency.

Note that I also tried with the suggestions made about setting attributes (e.g. setting org.gradle.jvm.environment to 'standard-jvm'), but that still did not help my cause.

Maybe a good example how to configure your Gradle build file for version 6.x would be nice (as Gradle 7 and later don't have this problem according to the Internet)

Expected Behavior

Application builds without problems

Actual Behavior

Building the application with the dependency throws the following failure:

Could not resolve com.google.guava:guava:33.0.0-jre.
Required by:
project :ourapp > com.microsoft.graph:microsoft-graph:6.3.0

Also it mentions that no selection could be made to determine the right variant:

Failed to build and package the app, because:
AmbiguousConfigurationSelectionException: Cannot choose between the following variants of com.google.guava:guava:33.0.0-jre:

  • androidRuntimeElements
  • jreRuntimeElements
    All of them match the consumer attributes:
  • Variant 'androidRuntimeElements' capabilities com.google.collections:google-collections:33.0.0-jre and com.google.guava:guava:33.0.0-jre:
    • Unmatched attributes:
      • Provides org.gradle.category 'library' but the consumer didn't ask for it
      • Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
      • Provides org.gradle.jvm.environment 'android' but the consumer didn't ask for it
      • Provides org.gradle.jvm.version '8' but the consumer didn't ask for it
      • Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
      • Provides org.gradle.status 'release' but the consumer didn't ask for it
      • Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
  • Variant 'jreRuntimeElements' capabilities com.google.collections:google-collections:33.0.0-jre and com.google.guava:guava:33.0.0-jre:
    • Unmatched attributes:
      • Provides org.gradle.category 'library' but the consumer didn't ask for it
      • Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
      • Provides org.gradle.jvm.environment 'standard-jvm' but the consumer didn't ask for it
      • Provides org.gradle.jvm.version '8' but the consumer didn't ask for it
      • Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
      • Provides org.gradle.status 'release' but the consumer didn't ask for it
      • Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it

Packages

No response

Platforms

No response

Checklist

@GeertZijlmans1 GeertZijlmans1 added the type=defect Bug, not working as expected label Feb 29, 2024
@cpovirk
Copy link
Member

cpovirk commented Feb 29, 2024

Sorry for the trouble :( It sounds like you've already found https://github.com/google/guava/releases/tag/v32.1.0 and perhaps some other discussions. Those other discussions include #6801 (comment) and posts throughout #6612.

If you're able to share a sample project, that may improve the chances that someone could help. You may end up with better luck on Stack Overflow, since my understanding is that most such errors need to be fixed by changes to a plugin or elsewhere in the build configuration :(

@ben-manes
Copy link
Contributor

This may be a bit of a naive, but a simple solution should be to disable the module metadata for the dependency (docs) because in most cases the maven pom is satisfactory.

repositories {
  mavenCentral()
  exclusiveContent {
    forRepository {
      maven {
        url 'https://repo.maven.apache.org/maven2/'
        metadataSources {
          mavenPom()
          artifact()
        }
      }
    }
    filter {
      includeModule 'com.google.guava', 'guava'
    }
  }
}

@GeertZijlmans1
Copy link
Author

@cpovirk It seems no longer to be necessary as the Microsoft Graph SDK falsely still had a dependency on the Google Guava library. Just finished removing that dependency for the Graph SDK. So I'll expect it to be no problem for my case anymore. But I could imagine that other developers might run into a similar problem (though I think we need to upgrade our Gradle version first).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 type=defect Bug, not working as expected
Projects
None yet
Development

No branches or pull requests

4 participants