melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jmhJar task is not compatible with Gradle configuration cache

shoaniki opened this issue · comments

Describe the bug
The plugin causes an error if the experimental Gradle configuration cache is enabled.

To Reproduce
Run gradle jmh --configuration-cache in a project that uses this plugin.

The output will include an error along the lines of:

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:project:jmhJar` of type `org.gradle.api.tasks.bundling.Jar`: cannot serialize object of type 
'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not
supported with the configuration cache.
  See https://docs.gradle.org/7.6-rc-3/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

This appears to happen for both shadow and non-shadow forms of the jar task.

There's an easy and obvious workaround, of course -- "don't do that" -- but it becomes a chore if the configuration cache is turned on in gradle.properties.

Gradle configuration cache is a rushed, ill-designed and half-baked feature that is incompatible with many of Gradle's own existing APIs. See gradle/gradle#18520

Can you provide a reproducer? Which version of the plugin are you using? I pushed a test which passes.