Skip to content

Fix Spotless targetExclude patterns being overridden#1690

Open
crogoz wants to merge 4 commits into
developfrom
cr/fix-target-exclude
Open

Fix Spotless targetExclude patterns being overridden#1690
crogoz wants to merge 4 commits into
developfrom
cr/fix-target-exclude

Conversation

@crogoz

@crogoz crogoz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Before this PR

#1568 was not additive, calling targetExclude multiple times was overriding previous values instead of accumulating them.

After this PR

FLUP for #1568

  • Fix SpotlessInterop calling targetExclude multiple times, which overrides previous patterns instead of accumulating them - only the last exclude (**/groovy-dsl-plugins/**) was actually applied
  • Add SpotlessExcludesTest to verify spotlessJavaCheck skips files in all excluded directories

==COMMIT_MSG==
Fix Spotless targetExclude patterns being overridden
==COMMIT_MSG==

Possible downsides?

@changelog-app

changelog-app Bot commented Jun 15, 2026

Copy link
Copy Markdown

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Fix Spotless targetExclude patterns being overridden

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app

changelog-app Bot commented Jun 15, 2026

Copy link
Copy Markdown

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

🐛 Fixes

  • Fix Spotless targetExclude patterns being overridden (#1690)

Comment on lines +63 to +67
"build/generated/java",
"src/generated/java",
"src/main/generated_testsrc",
"generated_testSrc",
"build/groovy-dsl-plugins/output",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also test some edge cases which should be included, like src/foo/generated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated here

Comment on lines +58 to +65
"**/build/generated*/**",
"**/src/generated*/**",
"**/generated_*src/**",
"**/generated_*Src/**",
// build/groovy-dsl-plugins contains Java wrapper classes for
// https://docs.gradle.org/9.3.1/userguide/implementing_gradle_plugins_convention.html
// and don't need to be formatted.
"**/groovy-dsl-plugins/**");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a PR to suppressible-error-prone aligning with these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they should be aligned already, no ? https://github.com/palantir/suppressible-error-prone/blob/0f2c42970e20b98d1b569e15ca9e86afc1c52a66/gradle-suppressible-error-prone/src/main/java/com/palantir/gradle/suppressibleerrorprone/SuppressibleErrorPronePlugin.java#L225

except for the groovy-dsl-plugins addition - which I am not really sure what it is and wether it is relevant to error prones

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it seems to be the same.

we false positive on a few cases in both repos, but that is a separate change!

foo/generated_foo/blah/src/bar
foo/build/generatedbar/baz
foo/src/generatedxforms/bar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from internal discussion, ^ these aren't false positives.

Comment on lines +60 to +61
"**/generated_*src/**",
"**/generated_*Src/**",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small correctness thing which might not matter: will this match generated_foo_src?

the current behavior matches SEP

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's the case, let's explicate this in a test case? to document this behavior + make it easy to include generated_foo_src for formatting in the future if we want to .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think line 54, 56 are explaining that we exclude generated source directories. This is where people usually set up these generated source sets.

@crogoz crogoz requested a review from kelvinou01 June 15, 2026 14:12
Comment on lines +90 to +91
@Test
void format_checks_non_generated_files(GradleInvoker gradle, RootProject project) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this test parameterized as well? It'd be nice to quickly grok what's included and excluded by glancing at the two tests.

Let's add a few non-obvious test cases? It'd be good to explicate this behavior for our future selves.

foo/generated_foo_src/bar
foo/generated_foo/blah/src/bar
foo/build/generatedbar/baz
foo/src/generatedxforms/bar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test cases here. Fysa - from the above list only the foo/generated_foo/blah/src/bar will be not-ignored

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