Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Gradle plugin not to break the clean task when Gradle's configuration cache is enabled #797

Merged
merged 3 commits into from
Feb 11, 2021

Conversation

eskatos
Copy link
Contributor

@eskatos eskatos commented Feb 11, 2021

Using the project at execution time is not allowed when Gradle's configuration cache is enabled.
https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

Before this commit, the spotless plugin registered a doLast task action on the clean task that accessed the projet at execution time. The effect of this is to break using the clean task on all builds that have the Spotless plugin applied when the configuration cache is enabled.

This manifests the following way:

user@host $ ./gradlew --configuration-cache clean
Configuration cache is an incubating feature.

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 `:clean` of type `org.gradle.api.tasks.Delete`: 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.0-20210211110842+0000/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

See the complete report at file:///..../configuration-cache-report.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

Here is a ZIP of the HTML configuration cache report for your curiosity: configuration-cache-report.zip

This PR changes the way the Spotless plugin configures the clean task to not access a project in the added doLast task action by computing the Spotless cache key upfront at configuration time. The effect is that builds with the Spotless plugin applied can now run the clean task with the configuration cache enabled.

This is a fix for #796

Using the project at execution time is not allowed when Gradle's
configuration cache is enabled.

Before this commit, the spotless plugin registered a doLast task action
on the clean task that accessed the projet at execution time. The effect
of this is to break using the clean task on all builds that have the
spotless plugin applied when the configuration cache is enabled.

This commits change the way the spotless plugin configures the clean
task to not access a project in the added doLast task action by
computing the spotless cache key upfront at configuration time. The
effect is that builds with the spotless plugin applied can now run the
clean task with the configuration cache enabled.
@eskatos eskatos changed the title Eskatos/fix clean configuration cache Fix the Gradle plugin not to break the clean task when Gradle's configuration cache is enabled Feb 11, 2021
@nedtwigg
Copy link
Member

Thanks very much!

@nedtwigg nedtwigg merged commit a5c44dd into diffplug:main Feb 11, 2021
@nedtwigg
Copy link
Member

Published in 5.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants