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

Regression in 2.41.0, no longer ignoring target/generated-sources #1914

Closed
6 tasks done
hylkevds opened this issue Nov 27, 2023 · 8 comments · Fixed by #1928
Closed
6 tasks done

Regression in 2.41.0, no longer ignoring target/generated-sources #1914

hylkevds opened this issue Nov 27, 2023 · 8 comments · Fixed by #1928

Comments

@hylkevds
Copy link

Version 2.40.0 works without problems, switching to 2.41.0 fails the build due to formatting violations in code in target/generated-sources. Naturally, source code in target should not be checked for formatting violations.
The Changelog mentions #1846 that is probably related, but I'm not sure what config option to use to fix the issue.

If you are submitting a bug, please include the following:

  • summary of problem
  • Gradle or Maven version
  • spotless version
  • operating system and version
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace
@hylkevds
Copy link
Author

Found the fix:

                            <excludes>
                                <exclude>target/**</exclude>
                            </excludes>

in the <java> configuration block.
If excluding target by default is not feasible, then it may a good idea to add that to the examples.

@julius-d
Copy link

julius-d commented Nov 27, 2023

I tried to update my project to spotless-maven-plugin version 2.41.0 but it fails with:

Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.41.0:check (default) on project my-service: 
The following files had format violations:
     target/generated-sources/openapi/src/main/java [...]

I think that the generated-sources should not be checked by default!

@basil
Copy link

basil commented Nov 27, 2023

Same issue in the Jenkins project — all our builds are now failing due to this regression.

I think that the generated-sources should not be checked by default!

Agreed.

@nedtwigg
Copy link
Member

nedtwigg commented Nov 28, 2023

For anybody who has this problem, can you please

@jlorenzen
Copy link

Ran into this issue on all my team's projects. I think I would prefer maintaining backwards compatible behavior.
If one wants to run spotless on generated code, they should change the output directory to src/main/java so they can check the code in. Not sure why you'd want to run spotless on generated code that is not checked in.

@lutovich
Copy link
Contributor

lutovich commented Dec 2, 2023

So sorry about this issue! Here's a revert PR: #1928. It does feel correct to restore the previous behavior.

@tisonkun
Copy link
Contributor

tisonkun commented Dec 2, 2023

For an even better solution, I ever think of respecting gitignore configs.

I implement a similar function in apache/skywalking-eyes#13.

And plan to implement in a Java codebase https://github.com/korandoru/hawkeye/blob/main/hawkeye-core/src/main/java/io/korandoru/hawkeye/core/Selection.java with JGit.

For your reference :D

@nedtwigg
Copy link
Member

nedtwigg commented Dec 4, 2023

We went with a full revert to the previous behavior in plugin-maven 2.41.1. If it comes back, it'll be flag-gated and possibly also enhanced with .gitignore, tbd.

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 a pull request may close this issue.

7 participants