Gradle Metadata of 32.1.0 has a SNAPSHOT version number
I am very sorry @cpovirk but the Gradle Metadata just published is broken. If you look at these two files:
- https://repo1.maven.org/maven2/com/google/guava/guava/32.1.0-jre/guava-32.1.0-jre.module
- https://repo1.maven.org/maven2/com/google/guava/guava/32.1.0-android/guava-32.1.0-android.module
You see several versions like HEAD-android-SNAPSHOT in them.
I believe this is because the util/set_version.sh script was not used to set the version here.
My assumption was that this is somehow automatically used before each release. So I did not think about that further. I guess I was wrong and that's not the case. 😞
These lines need to be executed on a version change: https://github.com/google/guava/blob/master/util/set_version.sh#L18-L21
I am afraid this requires patching, as in certain situations the metadata now points at files not available on Maven Central.
Ouch, thank you for catching that.
I suspect that what happened is that, when we reworked our release process a couple years back, we copied the set_version logic into the new scripts and then never deleted the old script. I, too, had assumed that it would be run, but I had enough information that I could have thought to question that.
I'll update the release notes, delete the old script, update the new script, and publish a new release.
OK, 32.1.1 is published, and I ran a couple tests beforehand that suggest this problem should be fixed:
grep SNAPSHOT ~/.m2/repository/com/google/guava/guava/32.1.1-*/guava-32.1.1-*.module# no results; has results for 32.1.0util/gradle_integration_tests.sh# passes; failed at v32.1.0
Thanks for following up so quick! The 32.1.1 module files look correct to me.
I am seeing an issue with a Spring Boot project when doing Gradle Reload. The issue is related to the Guava module, and it seems to be trying to use that new version 32.1.1?
Any advice please as I think it might be related to this recent issue?
`
Could not resolve all artifacts for configuration ':classpath'. Could not resolve com.google.guava:guava:30.1-jre. Required by: project : > com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.8.0 > gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:2.8.0 > The consumer was configured to find a runtime of a library compatible with Java 15, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of com.google.guava:guava:32.1.1-jre: - androidRuntimeElements - jreRuntimeElements All of them match the consumer attributes: - Variant 'androidRuntimeElements' capabilities com.google.collections:google-collections:32.1.1-jre and com.google.guava:guava:32.1.1-jre and com.google.guava:listenablefuture:1.0 declares a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally:
`
Thanks. I'll leave another warning in the release notes :(
I wonder if the Selecting the appropriate flavor code snippet would be of help here, except with "STANDARD_JVM" instead of "ANDROID"? But @jjohannes is more likely to be of help.
@bjwyse are you running Gradle 6.x? You need to add something like this to a place where you configure the Java plugins:
sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
configurations.getByName(compileClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
}
Starting with Gradle 7.0, Gradle automatically supports the org.gradle.jvm.environment attribute.
@cpovirk maybe that's something to add to the release notes. I also didn't hink of that before. It only concerns 6.x users. Older versions won't pick up the metadata and starting with 7.x it is automatically supported.
Thanks, @jjohannes. I've updated the release notes to mention this.
Hi @cpovirk, Iver read the release notes for https://github.com/google/guava/releases/tag/v32.1.0.
Our library depends on MapDB 3.0.8 which has a dependency on guava library:
This is the error I am seeing now, is there any way I could resolve it, since we are having a secondary dependency on guava.
Thank you for your help in advance!
Hi, I am facing issue A problem occurred configuring root project 'platform'.
Could not resolve all artifacts for configuration ':classpath'. Could not resolve com.google.guava:guava:[14,). Required by: project : > com.smokejumperit.gradle.license:Gradle-License-Report:0.0.2 > The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of com.google.guava:guava:32.1.1-jre: - androidRuntimeElements - jreRuntimeElements
Hi @ashwinibairyruge - a fundamental flaw in this setup is that the com.smokejumperit.gradle.license:Gradle-License-Report plugin is declaring a dependency with com.google.guava:guava:[14,) (open version range). This means the build will regularly check for new Guava versions and may suddenly break. The plugin should declare a fixed version. The plugin looks unmaintained. Maybe you should replace it if you can. Or, independent of this issue, I would recommend to pin the dynamic versions yourself by adding constraints:
buildscript {
dependencies.constraints {
classpath("com.google.guava:guava:<some-fixed-guava-version>")
}
}
To get it working with the new Guava version, the best solution is to upgrade to Gradle 7.x or Gradle 8.x.
If that is not possible, for Gradle 6.x you need to set the above mentioned attribute for Gradle's own classpath:
buildscript {
configurations.classpath {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
}
@tanmaymanolkar1 your issue is similar. MapDB should not publish dynamic version dependencies. For example, they should use 15.0 instead of [15.0,) for Guava (maybe you want to open an issue there?).
To fix the problem with the new Guava version, update to Gradle 7.x or Gradle 8.x.
Or follow the advice here for 6.x: https://github.com/google/guava/issues/6612#issuecomment-1614992368
I am using 7.x version of gradle but receiving the https://github.com/google/guava/issues/6612#issuecomment-1614992368:~:text=for%206.x%3A-,%236612%20(comment),-Write
Gradle version: 7.6.1
[2023-07-06T11:05:57.418Z] * What went wrong:
[2023-07-06T11:05:57.418Z] Execution failed for task
@jjohannes
@rochish-suresh that is unexpected. The error trace you posted looks incomplete, but from "Provides org.gradle.category 'library' but the consumer didn't ask for it" I assume this is some custom dependency resolution. Meaning, it is not about the normal compileClasspath or runtimeClasspath.
When the org.gradle.jvm.environment attribute was introduced in 7.0, it was done in a way that should make it default to standard-jvm in such custom dependency resolution scenarios.
Without more context, I can't tell why it is not sufficient in your case.
Are you able to share a reproducer, or a build scan and/or the output of the dependencies task?
We're seeing the same issue - is there an ETA on a fix?
We're also facing the same issue @jjohannes ... I can't provide a reproducer, but we included the JRE dependendency (32.1.1-jre) and specified
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
// and/or
resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:listenablefuture") {
select("com.google.guava:guava:0")
}
}
org.gradle.internal.component.AmbiguousConfigurationSelectionException: Cannot choose between the following variants of com.google.guava:guava:32.1.1-jre:
- androidRuntimeElements
- jreRuntimeElements
All of them match the consumer attributes:
- Variant 'androidRuntimeElements' capabilities com.google.collections:google-collections:32.1.1-jre and com.google.guava:guava:32.1.1-jre and com.google.guava:listenablefuture:1.0:
- 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:32.1.1-jre and com.google.guava:guava:32.1.1-jre and com.google.guava:listenablefuture:1.0:
- 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
@johannesup and others: can you please share the complete error message. The last part is always the same. But the interesting bit is which classpath (aka Configuration) Gradle is attempting to use/resolve.
Also:
- If you are on Gradle 6 update to 7 or 8 or follow the suggestions stated above - https://github.com/google/guava/issues/6612#issuecomment-1614992368 - and in the release notes. This is expected to be an issue with Gradle 6 that requires additional configuration on the user side.
- If you have such an issue with Gradle 7 or 8, share the complete error message. Or better a reproducer and/or a Build Scan if you can.
Assuming you are on Gradle 6 @johannesup, did you add https://github.com/google/guava/issues/6612#issuecomment-1614992368?
@deepamalik18 This part of the message...
https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings
tells you that your run Gradle 6.7.1. Maybe your CI configuration picks a different version than it is supposed to.
@jjohannes I have sent an email with the complete stack trace from jenkins and Gradle ent console log. Appreciate your help on identifying the cause of the build error My Email- [email protected]
@rochish-suresh thanks for sharing additional information. In your error logs it says at some point:
> Could not resolve all files for configuration ':deployment:promisLib'.
And afterwards
The consumer was configured to find attribute 'org.gradle.dependency.bundling' with value 'external'.
I think this means that you define a Configuration called promisLib somewhere. And then for this configuration you set only the org.gradle.dependency.bundling attribute. While it should still work, I think the matching mechanism is not sure in this setup what to pick, because you define one thing, but keep everything else open. I would suggest to
- Define no attribute at all (legacy mode)
- If you have the
org.gradle.dependency.bundlingfor a good reason, also add at leastorg.gradle.usage=java-runtime. I think that might fix it already (you should always specify at least org.gradle.usage). But you could also addorg.gradle.jvm.environment=standard-jvm.
I can't be more precise without seeing the custom build logic of your project.