johnrengelman / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
http://imperceptiblethoughts.com/shadow/
Apache License 2.0
3.58k stars 386 forks source link

Incompatibility with gradle configuration cache #893

Closed Spikhalskiy closed 6 months ago

Spikhalskiy commented 7 months ago

When attempting to enable gradle configuration cache in a project with this plugin applied, the build fails with

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 `:shadowJar` of type `com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar`: cannot serialize Gradle script object references as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

Gradle Configuration Cache is an experimental feature that is turned off by default, but many major plugins at this moment already support it. It would be great to see Shadow plugin supporting it too. https://docs.gradle.org/current/userguide/configuration_cache.html

Shadow Version

8.1.1

Gradle Version

8.4

Spikhalskiy commented 6 months ago

This was caused by our own configuration that looked the following way:

tasks {
    shadowJar {
        onlyIf { gradle.taskGraph.hasTask("dockerBuild") }
    }
}