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

HV-2051 Use spotless maven plugin instead of formatter/impsorter/license check plugins #1460

Merged
merged 12 commits into from
Oct 14, 2024

Conversation

marko-bekhta
Copy link
Member

@marko-bekhta marko-bekhta commented Sep 25, 2024

https://hibernate.atlassian.net/browse/HV-2051

This one is only to evaluate the option and not actually to apply the change ...
I thought that it would be better to test this on the Validator as it uses all 3 plugins and has a smaller codebase.
Best to look by commit (if looked at all 😅).

  • Not all things that we are checking with checkstyle have an alternative (or at least I couldn't find one). I kept those rules in the checkstyle file so we can review them. I'll add a comment on that file so it's easier to find.
  • I couldn't split the license header check from formatting; hence, the files with different licenses are not formatted... (I suspect that having multiple executions would do the trick, but I didn't want to go that route as I suppose the idea was to simplify the build and have fewer executions....)
  • import sorting removes the comments. This means that the tags we have in the docs tests to include in the documentation file have to be excluded from spotless, resulting in those imports not being sorted (not a big deal, but a bit annoying 😃)
  • While trying to figure out the patterns for XML headers I've noticed that the plugin does not always fail when there's a problem in the config. I had a bad regex that was capturing the license header itself resulting in infinite update of the same file (at least that is what I've seen while debugging). This resulted in the build just passing successfully and the files not affected (I'd rather it failed with a build error .... )

(this work is not complete: the maven properties and builds should also be updated to make it all work and I haven't done that here yet...)


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on licensing, please check here.


@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Sep 25, 2024

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@marko-bekhta
Copy link
Member Author

@yrodiere I'll let you have a look at this one (probably whenever you have nothing interesting to look into 😄 )

@yrodiere
Copy link
Member

  • I couldn't split the license header check from formatting; hence, the files with different licenses are not formatted... (I suspect that having multiple executions would do the trick, but I didn't want to go that route as I suppose the idea was to simplify the build and have fewer executions....)
    [...]
  • While trying to figure out the patterns for XML headers I've noticed that the plugin does not always fail when there's a problem in the config. I had a bad regex that was capturing the license header itself resulting in infinite update of the same file (at least that is what I've seen while debugging). This resulted in the build just passing successfully and the files not affected (I'd rather it failed with a build error .... )

Looks like we'd be better off keeping license header checks in checkstyle?

import sorting removes the comments. This means that the tags we have in the docs tests to include in the documentation file have to be excluded from spotless, resulting in those imports not being sorted (not a big deal, but a bit annoying 😃)

Annoying indeed... though it's quite rare that we include comments in docs code snippets, at least for Hibernate Search, so I suppose we can live with it.
Do you know if there's a bug report / feature request in Spotless regarding this?

Not all things that we are checking with checkstyle have an alternative (or at least I couldn't find one). I kept those rules in the checkstyle file so we can review them. I'll add a comment on that file so it's easier to find.

Will have a look, but if we need checkstyle for license header checks anyway, I suppose it's no big deal.

@marko-bekhta marko-bekhta force-pushed the build/formatter-spotless branch from ad4fddc to 9dd74cf Compare October 10, 2024 15:50
@marko-bekhta marko-bekhta force-pushed the build/formatter-spotless branch 2 times, most recently from cb2cd91 to ca1b592 Compare October 11, 2024 09:01
@marko-bekhta marko-bekhta force-pushed the build/formatter-spotless branch 2 times, most recently from 1e8c5c5 to 12fd79b Compare October 11, 2024 14:24
@marko-bekhta marko-bekhta force-pushed the build/formatter-spotless branch from 12fd79b to 16bcbd2 Compare October 11, 2024 14:29
@marko-bekhta marko-bekhta changed the title DRAFT: switch to spotless HV-2051 Use spotless maven plugin instead of formatter/impsorter/license check plugins Oct 14, 2024
@marko-bekhta marko-bekhta marked this pull request as ready for review October 14, 2024 10:53
@marko-bekhta marko-bekhta merged commit cf94b1f into hibernate:main Oct 14, 2024
7 checks passed
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