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

baseline-format: can format build.gradle files #1561

Merged
merged 2 commits into from
Nov 25, 2020

Conversation

iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox commented Nov 24, 2020

Before this PR

Every now and again, we stumble across some elaborate build.gradle files full of custom stuff. These are sometimes hard to read due to each project's own idiosyncratic styling opinions.

Well it turns out spotless can just zap em all with a consistent format!

After this PR

==COMMIT_MSG==
com.palantir.baseline-format now understands how to format build.gradle files. This is opt-in by default, so you need to run ./gradlew format -Pcom.palantir.baseline-format.gradle-files=true to try it, or add this property to your gradle.properties if you want to lock it in.
==COMMIT_MSG==

I've intentionally made this opt-in because I'm intending to write an auto-merging excavator which will just come round and re-format your files, without incurring the annoyance of failing builds because someone has got their indentation wrong.

Possible downsides?

  • people can be pretty opinionated about styling, and I think there's a risk this might make certain build.gradles longer (e.g. by expanding one-liners to multiple lines). Overall though, I think most people have recognised the value of applying palantir-java-format everywhere, so maybe they'll be receptive???
  • i've spent like 5 minutes on this PR, so there are no tests. #gottagofast

@changelog-app
Copy link

changelog-app bot commented Nov 24, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

com.palantir.baseline-format now understands how to format build.gradle files. This is opt-in by default, so you need to run ./gradlew format -Pcom.palantir.baseline-format.gradle-files=true to try it, or add this property to your gradle.properties if you want to lock it in.

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from CRogers November 24, 2020 22:52
@iamdanfox iamdanfox requested review from tpetracca and ferozco and removed request for CRogers November 24, 2020 22:53
@@ -0,0 +1,3 @@
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.indent_empty_lines=false
groovy.formatter.remove.unnecessary.semicolons=true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a trial run with this config on devx/template-witchcraft and it makes zero changes!! I didn't quite believe it, so I indented stuff like crazy and it restored it :)

@fawind
Copy link
Contributor

fawind commented Nov 25, 2020

The unit-test-15 errors are unrelated, put up a fix in #1565. But don't think we need to block on this.

Copy link
Contributor

@fawind fawind left a comment

Choose a reason for hiding this comment

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

I love it!

Will the excavator also be opt-in? I think its fine to just always let the excavator reformat the gradle files but maybe that's what you are already intending to do :)

@bulldozer-bot bulldozer-bot bot merged commit 8e4eb49 into develop Nov 25, 2020
@bulldozer-bot bulldozer-bot bot deleted the dfox/opt-in-gradle-file-formatting branch November 25, 2020 13:06
@svc-autorelease
Copy link
Collaborator

Released 3.55.0

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

Successfully merging this pull request may close these issues.

None yet

3 participants