Guava in Gradle's classpath


I am working on a plugin that uses Guava via transitive dependencies. Unfortunately, I have found that Gradle already includes Guava (v. 17.0):

I noticed that Gradle also includes re-packaged Guava under package but as stated by the exception from the linked issue, the original Guava classes are used by gradle-base-services module.

What is the policy for Guava dependency in Gradle distribution? Should the modules use the re-packaged version so the plugins can add their own version? If not, is there any isolation mechanism that could allow a plugin to use a different Guava version?

Best regards,

You can use any version of Guava you want, Gradle does not leak its own version into your plugin.

Thank you for your reply.

As you can see in the linked issue, when I don’t specify Guava dependency in my plugin, version 17 is added by Gradle to satisfy gradle-base-services module requirements and is loaded (in my example) from the following path:


and this path is part of the Gradle distribution. guava-jdk5-17.0.jar archive contains Guava classes in their original packages - they are not repackaged under internal Gradle package.

Am I misunderstanding something here?

Guava is not part of Gradle’s API, so it will not be exposed to your plugin. We have filtering classloaders that make sure that your plugin cannot see it. Can you provide a reproducible example where you had this problem?

I don’t have minimal example but I will try to prepare one this week when I have more time.

We are using WorkerExecutor with isolation mode set to PROCESS. I guess it might be the issue of classpath of the worker, not the main Gradle process.

FWIW I just built a project which doesn’t have any guava dependency and i can see guava being downloaded

e[4Ae[1m<-------------> 0% INITIALIZING [22s]e[me[37De[1Be[1m> root project > Resolve dependencies :example-transform:classpathe[me[66De[1B> IDLEe[6De[1Be[1m> plexus-component-annotations-1.7.1.pome[me[40De[1Be[4A
Download Download

Build log here source here

Hello @Lance,

Guava dependency is not downloaded as part of dependencies, it is included on classpath from Gradle wrapper downloaded distribution’s lib directory.

That’s a transitive dependency of the plugin-publish plugin and it’s in the buildscript.classpath. It’s expected that that would be visible until we have some isolation between external plugins.

But Piotrek was saying that he gets the Guava library from the Gradle distribution, which should never happen.

@Gary_Hale do we have some tests for worker executors not leaking Guava and other dependencies?

Ah… yeah… I always forget that’s an external plugin. It feels like core behaviour

Stefan, I created a minimal reproducible example of Guava being visible in a worker.

I think this is causing a number of problems in our Clojure plugin.

Thanks Andrew, that’s super helpful. I can reproduce the issue and opened for this.

1 Like