Title: formatDiff and the Spotless step fail with the configuration cache · Issue #193 · openjavaformat/open-java-format · GitHub
Open Graph Title: formatDiff and the Spotless step fail with the configuration cache · Issue #193 · openjavaformat/open-java-format
X Title: formatDiff and the Spotless step fail with the configuration cache · Issue #193 · openjavaformat/open-java-format
Description: What happens With the configuration cache on (--configuration-cache, or org.gradle.configuration-cache=true), two of the Gradle plugin's tasks fail. Reproduced with Gradle 9.3.1, Spotless 8.10.4 and JDK 21, with the plugin built from 21....
Open Graph Description: What happens With the configuration cache on (--configuration-cache, or org.gradle.configuration-cache=true), two of the Gradle plugin's tasks fail. Reproduced with Gradle 9.3.1, Spotless 8.10.4 an...
X Description: What happens With the configuration cache on (--configuration-cache, or org.gradle.configuration-cache=true), two of the Gradle plugin's tasks fail. Reproduced with Gradle 9.3.1, Spotless 8.10....
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/193
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"formatDiff and the Spotless step fail with the configuration cache","articleBody":"### What happens\n\nWith the configuration cache on (`--configuration-cache`, or `org.gradle.configuration-cache=true`), two of the Gradle plugin's tasks fail. Reproduced with Gradle 9.3.1, Spotless 8.10.4 and JDK 21, with the plugin built from `21.X.X`, whose sources are unchanged since 21.0.1.\n\n**`formatDiff`**, with the Java-based and the native formatter alike:\n\n```\n> Task :formatDiff FAILED\n1 problem was found storing the configuration cache.\n- Task `:formatDiff` of type `com.palantir.javaformat.gradle.PalantirJavaFormatPlugin$FormatDiffTask`: invocation of 'Task.project' at execution time is unsupported with the configuration cache.\n```\n\nThe entry is discarded, so every run fails the same way.\n\n**`spotlessCheck` and `spotlessApply`**, with `com.diffplug.spotless` applied: every file gets a lint error and the task fails.\n\n```\n> Task :spotlessJavaCheck FAILED\n> There were 1 lint error(s), they must be fixed or suppressed.\n src/main/java/Foo.java:LINE_UNDEFINED open-java-format(java.lang.NullPointerException) Cannot invoke \"java.util.function.Supplier.get()\" because \"this.jarsSupplier\" is null (...)\n```\n\nThe next run does not reuse the entry either: `configuration cache cannot be reused because an input to unknown location has changed`. In the same project without the open-java-format step, Spotless stores its entry and reuses it.\n\nThe IntelliJ tasks (`updateOpenJavaFormatXml`, `updateWorkspaceXml`, `updateExternalDependenciesXml`) work: their entry is stored and reused. Gradle turns the cache off when its own `idea` task runs, which is not compatible with it; that is not the plugin's doing.\n\n### Why\n\n- `FormatDiffTask.formatDiff()` calls `getProject()` when it runs, for the project directory and for the root project's `JavaFormatExtension`, which loads the formatter.\n- `PalantirJavaFormatStep.State` keeps the formatter jars and the loaded `FormatterService` in `transient` fields. The configuration cache serializes the Spotless step, and the step it reads back has both fields `null`, on the run that stores the entry too.\n\n`SupportsCurrentSpotlessTest`, the only plugin test with the cache on, runs `classes`: it creates the Spotless step but never formats with it. Every other plugin test runs with the cache off.\n\n### Proposal\n\n- `formatDiff` gets what it needs as task properties set at configuration time, the project directory and the formatter classpath, and loads the formatter when it runs, without `Project`.\n- The Spotless step keeps state that survives serialization: the formatter jar files, from which the formatter is loaded on first use. The jars stay an input, so another formatter version still makes `spotlessJava` out of date.\n- Tests run `formatDiff`, `spotlessApply`, `spotlessCheck` and the IntelliJ tasks twice with the cache on, and check that the first run stores the entry and the second reuses it.\n\n### Until then\n\nRun these tasks with `--no-configuration-cache`, or set `org.gradle.configuration-cache=false` in the project's `gradle.properties`.\n","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-11-06T20:02:54Z","url":"https://github.com/openjavaformat/open-java-format/issues/193"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e9c14740-9d6f-83de-607c-9c02ab26ec2f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9FC2:2ED591:371223:4928A2:6AFBBB5C |
| html-safe-nonce | 35722824d2556cb30223e9fa50a19cd84fe854a276d4ff405cea445328ab3916 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkMyOjJFRDU5MTozNzEyMjM6NDkyOEEyOjZBRkJCQjVDIiwidmlzaXRvcl9pZCI6IjU1MjYxMTA4ODU2OTAxOTQ3ODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2d5bb3aa7f3c0f2a22bf633e501b29f722ff786bc1a8f1c0ecc4eba5da09df3a |
| hovercard-subject-tag | issue:6249736519 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openjavaformat/open-java-format/193/issue_layout |
| twitter:image | https://opengraph.githubassets.com/740633b9bdd5f9a8085a69af7278cd450ca93f9ae0a836a65f5b083a44ebd75c/openjavaformat/open-java-format/issues/193 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/740633b9bdd5f9a8085a69af7278cd450ca93f9ae0a836a65f5b083a44ebd75c/openjavaformat/open-java-format/issues/193 |
| og:image:alt | What happens With the configuration cache on (--configuration-cache, or org.gradle.configuration-cache=true), two of the Gradle plugin's tasks fail. Reproduced with Gradle 9.3.1, Spotless 8.10.4 an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abashev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c |
| turbo-cache-control | no-preview |
| go-import | github.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git |
| octolytics-dimension-user_id | 325177626 |
| octolytics-dimension-user_login | openjavaformat |
| octolytics-dimension-repository_id | 1288055459 |
| octolytics-dimension-repository_nwo | openjavaformat/open-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 214273098 |
| octolytics-dimension-repository_parent_nwo | palantir/palantir-java-format |
| octolytics-dimension-repository_network_root_id | 214273098 |
| octolytics-dimension-repository_network_root_nwo | palantir/palantir-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e4cce0e99cf61481a318ff12c2e8580153a6c7c6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width