Skip to content

android: fix ktfmt for agp 9.4 - #873

Merged
hiimtmac merged 1 commit into
mainfrom
hiimtmac/ktfmt-fix
Sep 16, 2026
Merged

hiimtmac merged 1 commit into
mainfrom
hiimtmac/ktfmt-fix

Conversation

@hiimtmac

Copy link
Copy Markdown
Contributor

Fixes tailscale/corp#48331

Upgrade the ktfmt Gradle plugin from 0.17.0 to 0.27.0 for compatibility with AGP 9.4. With 0.17.0, ktfmtCheck had no actions because the plugin did not discover AGP 9.4’s Kotlin source. Version 0.27.0 correctly registers and runs the source-set-specific ktfmt tasks.

The plugin upgrade also moves the bundled ktfmt engine from 0.47 to 0.64, so this PR includes the resulting one-time formatting changes. CI continues to run ktfmtCheck across all Kotlin source sets (not just what is changed in the PR).

@hiimtmac
hiimtmac added this pull request to stack #872 September 16, 2026 17:07

@barnstar barnstar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hiimtmac Does ktfmt have rules like SwiftLint where we might be able to override some if it's more colourful choices like not liking single line if statements or trailing brackets? At some point, those were acceptable formatting to it. I dislike that this touched everything (and I didn't look carefully - we use ktfmt so I will defer to its new choices).

If we have to to, we might as well rip off the bandaid. I didn't check every change - but if it still compiles - merge it.

Base automatically changed from hiimtmac/fix-kotlin-warnings to main September 16, 2026 17:56
Fixes tailscale/corp#48331

Signed-off-by: Taylor McIntyre <taylorm@tailscale.com>
@hiimtmac

Copy link
Copy Markdown
Contributor Author

@hiimtmac Does ktfmt have rules like SwiftLint where we might be able to override some if it's more colourful choices like not liking single line if statements or trailing brackets? At some point, those were acceptable formatting to it. I dislike that this touched everything (and I didn't look carefully - we use ktfmt so I will defer to its new choices).

If we have to to, we might as well rip off the bandaid. I didn't check every change - but if it still compiles - merge it.

ktfmt has a few broad options, but nothing like SwiftLint, and unfortunately many choices are controlled by the formatter. This diff comes from upgrading the ktfmt plugin 0.17.0->0.27.0 (for AGP comp). And this brings along a formatter change for ktfmt 0.47->0.64. So I think we are out of luck for trailing brackets/single line statements unfortunately 👎.

@hiimtmac
hiimtmac merged commit 03a7349 into main Sep 16, 2026
5 checks passed
@hiimtmac
hiimtmac deleted the hiimtmac/ktfmt-fix branch September 16, 2026 18:49
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.

2 participants