kant111
(kant)
December 5, 2019, 5:50pm
1
Unable to figure out how a transitive dependency of a particular version is ending up in my jar?
In my dependency section, I list guava 26.0-jre
and I have jar task in my build.gradle so when I do gradle clean build
and untar the jar and look at the guava version I see it is 19.0
instead of 26.0-jre
I did the following under myproject
gradle dependencies | grep guava
gradle dependencyInsight --configuration compile --dependency guava
none of them show 19.0 anywhere I only see 26.0-jre
from these commands
but when I untar the jar and go to META_INF/maven. I can see the version of com.google.guava in pom.properties as 19.0 and because of this, I am getting NoSuchMethodError
Exception at runtime.
How guava 19.0
ending up in my jar I have no idea. any thoughts?
ZillaG
(Chris F)
December 5, 2019, 6:14pm
2
Can you post your build.gradle
file?
ZillaG
(Chris F)
December 5, 2019, 6:28pm
4
Where is this in your dependency list?
ZillaG
(Chris F)
December 5, 2019, 6:49pm
6
Can you try
"guava": [
...
"com.google.guava:guava:${myVersions["guava"]}" {force = true}
...
]
My guess is Gradle deems version 19.0
is later than 26.0-jre
. When you do your dependencies
and depndencyInsight
do you see something like for the guava
artifact?
26.0-jre -> 19.0
kant111
(kant)
December 5, 2019, 6:58pm
7
That syntax quite doesnt work. I am using gradle 5.5
I get the following error
A problem occurred evaluating root project
> Could not find method com.google.guava:guava:26.0-jre() for arguments [build_3uufvsp9qkamwyz35i3jqhl9r$_run_closure1$_closure4@3f141f92] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.
kant111
(kant)
December 5, 2019, 7:02pm
8
And no I don’t see any 19.0
in fact here is the output. gradle dependencyInsight --configuration compile --dependency guava
Configuration on demand is an incubating feature.
com.google.guava:failureaccess:1.0.1
variant "runtime" [
org.gradle.status = release (not requested)
org.gradle.usage = java-runtime (not requested)
org.gradle.category = library (not requested)
]
com.google.guava:failureaccess:1.0.1
+--- compile
\--- com.google.guava:guava:28.0-android
+--- compile (requested com.google.guava:guava:26.0-jre)
+--- io.grpc:grpc-protobuf:1.23.0 (requested com.google.guava:guava:26.0-android)
| +--- compile
| +--- io.grpc:grpc-all:1.23.0
| | \--- compile
| +--- io.grpc:grpc-grpclb:1.23.0
| | \--- compile
| \--- io.grpc:grpc-services:1.23.0
| \--- compile
+--- io.grpc:grpc-protobuf-lite:1.23.0 (requested com.google.guava:guava:26.0-android)
| +--- compile
| \--- io.grpc:grpc-protobuf:1.23.0 (*)
+--- io.grpc:grpc-api:1.23.0 (requested com.google.guava:guava:26.0-android)
| +--- compile
| +--- io.grpc:grpc-all:1.23.0 (requested io.grpc:grpc-api:[1.23.0]) (*)
| +--- io.grpc:grpc-auth:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | +--- compile
| | \--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-core:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | +--- compile
| | +--- io.grpc:grpc-all:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-grpclb:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-netty-shaded:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- compile
| | +--- io.grpc:grpc-okhttp:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | +--- compile
| | | \--- io.grpc:grpc-all:1.23.0 (*)
| | +--- io.grpc:grpc-services:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-netty:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- io.grpc:grpc-all:1.23.0 (*)
| | \--- io.grpc:grpc-testing:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | \--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-protobuf:1.23.0 (*)
| +--- io.grpc:grpc-protobuf-lite:1.23.0 (*)
| \--- io.grpc:grpc-stub:1.23.0
| +--- compile
| +--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-grpclb:1.23.0 (*)
| +--- io.grpc:grpc-services:1.23.0 (*)
| \--- io.grpc:grpc-testing:1.23.0 (*)
+--- com.atlassian.jira:jira-rest-java-client-api:5.1.6 (requested com.google.guava:guava:26.0-jre)
| +--- compile
| \--- com.atlassian.jira:jira-rest-java-client-core:5.1.6
| +--- compile
| \--- project :pipes (requested com.atlassian.jira:jira-rest-java-client-core:5.1.2-2bd0a62e)
| \--- compile
\--- com.google.protobuf:protobuf-java-util:3.10.0
+--- compile
+--- io.grpc:grpc-grpclb:1.23.0 (requested com.google.protobuf:protobuf-java-util:3.9.0) (*)
\--- io.grpc:grpc-services:1.23.0 (requested com.google.protobuf:protobuf-java-util:3.9.0) (*)
com.google.guava:guava:28.0-android
variant "runtime" [
org.gradle.status = release (not requested)
org.gradle.usage = java-runtime (not requested)
org.gradle.category = library (not requested)
]
Selection reasons:
- By conflict resolution : between versions 28.0-android, 26.0-jre and 26.0-android
com.google.guava:guava:28.0-android
\--- com.google.protobuf:protobuf-java-util:3.10.0
+--- compile
+--- io.grpc:grpc-grpclb:1.23.0 (requested com.google.protobuf:protobuf-java-util:3.9.0)
| \--- compile
\--- io.grpc:grpc-services:1.23.0 (requested com.google.protobuf:protobuf-java-util:3.9.0)
\--- compile
com.google.guava:guava:26.0-android -> 28.0-android
+--- io.grpc:grpc-api:1.23.0
| +--- compile
| +--- io.grpc:grpc-all:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | \--- compile
| +--- io.grpc:grpc-auth:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | +--- compile
| | \--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-core:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | +--- compile
| | +--- io.grpc:grpc-all:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-grpclb:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- compile
| | +--- io.grpc:grpc-netty-shaded:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- compile
| | +--- io.grpc:grpc-okhttp:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | +--- compile
| | | \--- io.grpc:grpc-all:1.23.0 (*)
| | +--- io.grpc:grpc-services:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- compile
| | +--- io.grpc:grpc-netty:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- io.grpc:grpc-all:1.23.0 (*)
| | \--- io.grpc:grpc-testing:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | \--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-protobuf:1.23.0
| | +--- compile
| | +--- io.grpc:grpc-all:1.23.0 (*)
| | +--- io.grpc:grpc-grpclb:1.23.0 (*)
| | \--- io.grpc:grpc-services:1.23.0 (*)
| +--- io.grpc:grpc-protobuf-lite:1.23.0
| | +--- compile
| | \--- io.grpc:grpc-protobuf:1.23.0 (*)
| \--- io.grpc:grpc-stub:1.23.0
| +--- compile
| +--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-grpclb:1.23.0 (*)
| +--- io.grpc:grpc-services:1.23.0 (*)
| \--- io.grpc:grpc-testing:1.23.0 (*)
+--- io.grpc:grpc-protobuf:1.23.0 (*)
\--- io.grpc:grpc-protobuf-lite:1.23.0 (*)
com.google.guava:guava:26.0-jre -> 28.0-android
+--- compile
\--- com.atlassian.jira:jira-rest-java-client-api:5.1.6
+--- compile
\--- com.atlassian.jira:jira-rest-java-client-core:5.1.6
+--- compile
\--- project :pipes (requested com.atlassian.jira:jira-rest-java-client-core:5.1.2-2bd0a62e)
\--- compile
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
variant "runtime" [
org.gradle.status = release (not requested)
org.gradle.usage = java-runtime (not requested)
org.gradle.category = library (not requested)
]
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
+--- compile
\--- com.google.guava:guava:28.0-android
+--- compile (requested com.google.guava:guava:26.0-jre)
+--- io.grpc:grpc-protobuf:1.23.0 (requested com.google.guava:guava:26.0-android)
| +--- compile
| +--- io.grpc:grpc-all:1.23.0
| | \--- compile
| +--- io.grpc:grpc-grpclb:1.23.0
| | \--- compile
| \--- io.grpc:grpc-services:1.23.0
| \--- compile
+--- io.grpc:grpc-protobuf-lite:1.23.0 (requested com.google.guava:guava:26.0-android)
| +--- compile
| \--- io.grpc:grpc-protobuf:1.23.0 (*)
+--- io.grpc:grpc-api:1.23.0 (requested com.google.guava:guava:26.0-android)
| +--- compile
| +--- io.grpc:grpc-all:1.23.0 (requested io.grpc:grpc-api:[1.23.0]) (*)
| +--- io.grpc:grpc-auth:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | +--- compile
| | \--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-core:1.23.0 (requested io.grpc:grpc-api:[1.23.0])
| | +--- compile
| | +--- io.grpc:grpc-all:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-grpclb:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-netty-shaded:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- compile
| | +--- io.grpc:grpc-okhttp:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | +--- compile
| | | \--- io.grpc:grpc-all:1.23.0 (*)
| | +--- io.grpc:grpc-services:1.23.0 (requested io.grpc:grpc-core:[1.23.0]) (*)
| | +--- io.grpc:grpc-netty:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | | \--- io.grpc:grpc-all:1.23.0 (*)
| | \--- io.grpc:grpc-testing:1.23.0 (requested io.grpc:grpc-core:[1.23.0])
| | \--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-protobuf:1.23.0 (*)
| +--- io.grpc:grpc-protobuf-lite:1.23.0 (*)
| \--- io.grpc:grpc-stub:1.23.0
| +--- compile
| +--- io.grpc:grpc-all:1.23.0 (*)
| +--- io.grpc:grpc-grpclb:1.23.0 (*)
| +--- io.grpc:grpc-services:1.23.0 (*)
| \--- io.grpc:grpc-testing:1.23.0 (*)
+--- com.atlassian.jira:jira-rest-java-client-api:5.1.6 (requested com.google.guava:guava:26.0-jre)
| +--- compile
| \--- com.atlassian.jira:jira-rest-java-client-core:5.1.6
| +--- compile
| \--- project :pipes (requested com.atlassian.jira:jira-rest-java-client-core:5.1.2-2bd0a62e)
| \--- compile
\--- com.google.protobuf:protobuf-java-util:3.10.0
+--- compile
+--- io.grpc:grpc-grpclb:1.23.0 (requested com.google.protobuf:protobuf-java-util:3.9.0) (*)
\--- io.grpc:grpc-services:1.23.0 (requested com.google.protobuf:protobuf-java-util:3.9.0) (*)
(*) - dependencies omitted (listed previously)
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed
ZillaG
(Chris F)
December 5, 2019, 7:05pm
9
You somehow need to make the equivalent of this work in your fancy build.gradle
files.
dependencies {
...
compile ("com.google.guava:guava:26.0-jre") {force = true}
...
}
Maybe this in your sub-project?
dependencies {
...
compile myModules['guava'] {force = true }
...
}
ZillaG
(Chris F)
December 5, 2019, 7:30pm
10
I see above though. The ->
denotes that you’re no longer have what you wanted in your dependency tree.
kant111
(kant)
December 5, 2019, 7:38pm
11
I tried excluding 28.0-android
and I still get the same result.
Also, I tried changing guava version to 20.0
since you said -jre
can be an issue.
I both cases I see guava 19.0
in my myproject.jar
ZillaG
(Chris F)
December 5, 2019, 7:42pm
12
Did you try the second suggestions for {force = true}
syntax?
kant111
(kant)
December 5, 2019, 7:53pm
13
Yes I got the same syntax problem so I tried this
configurations.all {
resolutionStrategy {
force "com.google.guava:guava:26.0-jre"
}
}
Still the same result I see guava 19.0
#Generated by org.apache.felix.bundleplugin
#Wed Dec 09 15:58:23 EST 2015
version=19.0
groupId=com.google.guava
artifactId=guava
What version of Gradle are you using? You shouldn’t use compile
, that’s not what Gradle uses when it resolves configurations. Use compileClasspath
or, in your case, runtimeClasspath
, this should tell you where the dependency comes from. And if you can’t figure it out again, use a build scan which will list all dependendencies from all configurations.
Then look at the docs , they explain what you can do in such situations.