guava icon indicating copy to clipboard operation
guava copied to clipboard

Gradle Metadata of 32.1.0 has a SNAPSHOT version number

Open jjohannes opened this issue 3 years ago • 35 comments

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.

jjohannes avatar Jun 30 '23 12:06 jjohannes

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.

cpovirk avatar Jun 30 '23 12:06 cpovirk

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.0
  • util/gradle_integration_tests.sh # passes; failed at v32.1.0

cpovirk avatar Jun 30 '23 15:06 cpovirk

Thanks for following up so quick! The 32.1.1 module files look correct to me.

jjohannes avatar Jun 30 '23 15:06 jjohannes

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:

`

bjwyse avatar Jun 30 '23 16:06 bjwyse

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.

cpovirk avatar Jun 30 '23 16:06 cpovirk

@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.

jjohannes avatar Jun 30 '23 17:06 jjohannes

Thanks, @jjohannes. I've updated the release notes to mention this.

cpovirk avatar Jun 30 '23 20:06 cpovirk

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: image

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. image

Thank you for your help in advance!

tanmaymanolkar1 avatar Jun 30 '23 20:06 tanmaymanolkar1

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

ashwinibairyruge avatar Jul 03 '23 12:07 ashwinibairyruge

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")
    }
}

jjohannes avatar Jul 03 '23 12:07 jjohannes

@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

jjohannes avatar Jul 03 '23 12:07 jjohannes

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 [2023-07-06T11:05:57.418Z] > Could not resolve all files for configuration [2023-07-06T11:05:57.418Z] > Could not resolve com.google.guava:guava:32.1.1-jre. [2023-07-06T11:05:57.418Z] Required by: [2023-07-06T11:05:57.418Z] project :deployment > project The consumer was configured to find attribute 'org.gradle.dependency.bundling' with value 'external'. However we cannot choose between the following variants of com.google.guava:guava:32.1.1-jre: [2023-07-06T11:05:57.419Z] - androidRuntimeElements [2023-07-06T11:05:57.419Z] - jreRuntimeElements [2023-07-06T11:05:57.419Z] All of them match the consumer attributes: [2023-07-06T11:05:57.419Z] - 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 attribute 'org.gradle.dependency.bundling' with value 'external': [2023-07-06T11:05:57.419Z] - Unmatched attributes: [2023-07-06T11:05:57.419Z] - Provides org.gradle.category 'library' but the consumer didn't ask for it

@jjohannes

rochish-suresh avatar Jul 06 '23 11:07 rochish-suresh

@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?

jjohannes avatar Jul 06 '23 12:07 jjohannes

We're seeing the same issue - is there an ETA on a fix?

JackRyanTR avatar Jul 06 '23 16:07 JackRyanTR

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 avatar Jul 12 '23 13:07 johannesup

@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.

jjohannes avatar Jul 12 '23 15:07 jjohannes

Assuming you are on Gradle 6 @johannesup, did you add https://github.com/google/guava/issues/6612#issuecomment-1614992368?

jjohannes avatar Jul 12 '23 16:07 jjohannes

@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 avatar Jul 17 '23 17:07 jjohannes

@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 avatar Aug 02 '23 10:08 rochish-suresh

@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

  1. Define no attribute at all (legacy mode)
  2. If you have the org.gradle.dependency.bundling for a good reason, also add at least org.gradle.usage=java-runtime. I think that might fix it already (you should always specify at least org.gradle.usage). But you could also add org.gradle.jvm.environment=standard-jvm.

I can't be more precise without seeing the custom build logic of your project.

jjohannes avatar Aug 02 '23 14:08 jjohannes