Skip to content

guava:32.1.2-jre make checkstyle fail #6825

Open
@LiYing2010

Description

@LiYing2010

Description

We are using checkstyle plugin in a gradle (v8.3) project
checkstyle is the latest version 10.12.4, and our project also use com.google.guava:guava:31.1-jre
and everything works fine

but when I upgrade guava to 32.1.2-jre, it make checkstyle failed with following error:

Execution failed for task ':myproject:checkstyleMain'.
> Could not resolve all files for configuration ':myproject:checkstyle'.
   > Could not resolve com.google.guava:guava:32.0.1-jre.
     Required by:
         project :myproject > com.puppycrawl.tools:checkstyle:10.12.4
      > Module 'com.google.guava:guava' has been rejected:
           Cannot select module with conflict on capability 'com.google.collections:google-collections:32.1.2-jre' also provided by [com.google.collections:google-collections:1.0(runtime)]
   > Could not resolve com.google.collections:google-collections:1.0.
     Required by:
         project :myproject > com.puppycrawl.tools:checkstyle:10.12.4 > org.apache.maven.doxia:doxia-core:1.12.0 > org.codehaus.plexus:plexus-container-default:2.1.0
      > Module 'com.google.collections:google-collections' has been rejected:
           Cannot select module with conflict on capability 'com.google.collections:google-collections:1.0' also provided by [com.google.guava:guava:32.1.2-jre(jreRuntimeElements)]

some investigation:

I checked the dependency list of checkstyle : https://checkstyle.sourceforge.io/dependencies.html
looks like it depends on com.google.guava:guava:32.0.1-jre
and there is a transitive dependency com.google.collections:google-collections:1.0 too

which means, guava:32.0.1-jre + google-collections:1.0 + checkstyle 10.12.4 should work

so I changed my dependency to guava:32.0.1-jre, and it worked!

I tested some versions of guava:
32.1.0-jre ---> failed with same error
32.1.1-jre ---> failed with same error
32.1.2-jre ---> failed with same error
32.1.3-jre ---> failed with same error

32.0.0-jre ---> works fine
32.0.1-jre ---> works fine
31.1-jre ---> works fine

looks like this error only occurs in 32.1.x version

and I check the maven repo: https://repo1.maven.org/maven2/com/google/guava/guava/
the only strange thing I found is:
all the 32.1.x version has a file guava-32.1.x-jre.module, with following content:

      "capabilities": [
        {
          "group": "com.google.collections",
          "name": "google-collections",
          "version": "32.1.x-jre"
        },
      ]
    },

I am not sure, but I guess this is why gradle cannot resolve com.google.collections:google-collections:1.0 ?

Example

......

    apply plugin: 'checkstyle'

    ......

    checkstyle {
        toolVersion = '10.12.4'
        configFile = file("${rootProject.rootDir}/config/checkstyle/checkstyle.xml")
        ignoreFailures true
        sourceSets = [project.sourceSets.main] // ignore test code checkstyle
    }

    dependencyManagement {
        dependencies {
            ......

            dependency 'com.google.guava:guava:31.1-jre'

            ......
        }
    }


### Expected Behavior

`checkstyle` should run without error

### Actual Behavior

`checkstyle` fails

### Packages

_No response_

### Platforms

_No response_

### Checklist

- [X] I agree to follow the [code of conduct](https://github.com/google/.github/blob/master/CODE_OF_CONDUCT.md).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions