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

toggleOffOn breaks the configuration cache hack #2317

Open
breskeby opened this issue Oct 25, 2024 · 3 comments
Open

toggleOffOn breaks the configuration cache hack #2317

breskeby opened this issue Oct 25, 2024 · 3 comments
Labels

Comments

@breskeby
Copy link
Contributor

breskeby commented Oct 25, 2024

We validate the cache ability of our elasticsearch build once on a regular basis. Testing updating spotless gradle plugin to 7.0.0BETA3(and 4) the cachabiltiy of one of the spotlessJava tasks within our build-tool-internal subproject is not cacheable due to stepsInternalEquality is reported to be different. I don't understand what causes this to be honest. it must be something special with the subproject. the only configuration there is using onOffToggle that we do not do in other places.

spotless {
  java {
    toggleOffOn()
  }
}

Find attached a screenshot of our develocity check:
Screenshot 2024-10-25 at 21 50 42

@nedtwigg
Copy link
Member

That spotless block wouldn't do anything, there must be some other configuration blocks hiding somewhere else...

@breskeby
Copy link
Contributor Author

It must be the spotless block. I had added a workaround by excluding the file in question instead of using a toggle and that fixes the problem:

spotless {
  java {

    // workaround for https://github.com/diffplug/spotless/issues/2317
    //toggleOffOn()
    target project.fileTree("src/main/java") {
      include '**/*.java'
      exclude '**/DockerBase.java'
    }
  }
}

@nedtwigg nedtwigg added the bug label Oct 28, 2024
@nedtwigg nedtwigg changed the title spotless plugin gradle plugin 7.0.0.BETA4 (also beta30 breaks spotlessJava cacheability toggleOffOn breaks the configuration cache hack Oct 28, 2024
@nedtwigg
Copy link
Member

Ah, here is the problem, thanks for reporting it so clearly. FenceStep is the code that implements toggleOffOn. It stores a list of the steps that must be "toggled-on"

@SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED")
private static abstract class BaseStep implements Serializable, FormatterStep {
final String name;
private static final long serialVersionUID = -2301848328356559915L;
final Pattern regex;
final List<FormatterStep> steps;

It implements full roundtripping, but it does not implement the crazy equality hack that we did in

This is fixable, but pretty tricky to fix. It will probably still be broken in 7.0.0 when it comes out of beta.

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

No branches or pull requests

2 participants