我试图在我的Java项目中使用OpenRewrite插件,它需要Guava。Gradle无法在两个变体之间进行选择,因为该插件不检查属性org.gradle.jvm.environment。这两个变体是androidRuntimeElements和jreRuntimeElements。
我如何从我的项目中排除android运行时变体,或者让Gradle选择jre运行时变体?
Execution failed for task ':rewriteResolveDependencies'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
> Could not resolve com.google.guava:guava:31.1-jre.
Required by:
project : > org.openrewrite:rewrite-python:1.0.7
> The consumer was configured to find attribute 'org.gradle.category' with value 'library', attribute 'org.gradle.usage' with value 'java-runtime', attribute 'org.gradle.libraryelements' with value 'jar', 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:
- 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 attribute 'org.gradle.category' with value 'library', attribute 'org.gradle.dependency.bundling' with value 'external', attribute 'org.gradle.libraryelements' with value 'jar', attribute 'org.gradle.usage' with value 'java-runtime':
- Unmatched attributes:
- 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.status 'release' 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 declares attribute 'org.gradle.category' with value 'library', attribute 'org.gradle.dependency.bundling' with value 'external', attribute 'org.gradle.libraryelements' with value 'jar', attribute 'org.gradle.usage' with value 'java-runtime':
- Unmatched attributes:
- 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.status 'release' but the consumer didn't ask for it
The following variants were also considered but didn't match the requested attributes:
- Variant 'androidApiElements' 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.category' with value 'library', attribute 'org.gradle.dependency.bundling' with value 'external', attribute 'org.gradle.libraryelements' with value 'jar':
- Incompatible because this component declares attribute 'org.gradle.usage' with value 'java-api' and the consumer needed attribute 'org.gradle.usage' with value 'java-runtime'
- Variant 'jreApiElements' 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.category' with value 'library', attribute 'org.gradle.dependency.bundling' with value 'external', attribute 'org.gradle.libraryelements' with value 'jar':
- Incompatible because this component declares attribute 'org.gradle.usage' with value 'java-api' and the consumer needed attribute 'org.gradle.usage' with value 'java-runtime'
我试着在谷歌上搜索这个问题,但没有找到任何答案。我还尝试从我的build.gradle配置块中排除guava,但我无法仅排除android运行时变体。
1条答案
按热度按时间dohp0rv51#
虽然我看不到你的OpenRewrite配置,但我可以看到rewrite-python至少已经过时了。有一个新的1.0.8版本,以及其他一些OpenRewrite插件和模块,特别是解决一些最近的Guava版本问题。请务必使用最新版本,通常可以在GitHub上通过以下链接看到: