Getting conflicting module versions for groovy-all after migrating a custom plugin to the worker API


(Oliver Becker) #1

I have written a gradle plugin that works without problems side-by-side with other plugins.

Now I updated the plugin to use the new worker API (mainly for separating the classpath that is used by the plugin). This worked well in general, however in one the projects that uses the updated plugin I get the following exception:

Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing de.obqo.gradle.degraph.DegraphWorker
14:56:11.807 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.DefaultWorkerExecutor$
14:56:11.808 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.DefaultWorkerExecutor$
14:56:11.808 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] … 3 more
14:56:11.810 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.ExceptionInInitializerError
14:56:11.810 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.classloading.GroovySystemLoaderFactory.forClassLoader(
14:56:11.810 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.executeInWorkerClassLoader(
14:56:11.810 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.access$200(
14:56:11.810 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.DefaultWorkerExecutor$
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] … 4 more
14:56:11.811 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.4.4 and you are trying to load version 2.4.12

Apparently groovy-all:2.4.4 is a dependecy from another plugin (built with on older gradle version). When I run the build with --debug and the previous version of my plugin then I see that the other plugin pulls groovy-all:2.4.4, and my plugin pulls groovy-all:2.4.12. However, this conflict is apparently resolved by gradle, since there is no exception and both plugins work as expected.

The conflict only shows after I started to use the worker API in my plugin.

According to Controlling conflicting versions of Groovy for a plugin this can be solved by adding

configurations.all { exclude module: “groovy-all” }

to the buildScript closure of the project.

I wonder if this is a bug in gradle (no problem without worker API, but conflict with worker API).
Moreover, can I as the author of the plugin add something to the plugin code, so that the conflict doesn’t show up? It is a bit unfortunate that the users of the plugins need to add extra configuration to their projects to solve this conflict.

For your info - this is the code of the plugin:

Update 2018-04-02:
As a workaround I decided to add an explicit compile dependency for org.codehaus.groovy:groovy-all:2.4.12 in the plugin, so gradle is able to do the correct dependency resolution when resolving the plugins. Apparently version conflict resolution doesn’t work between different class loaders. See also the following issues: and