{{ message }}
Repository navigation
build: add Spotless with ktlint formatting checks - #2452
Merged
Merged
Conversation
Adds the Spotless Gradle plugin (8.9.0) with ktlint for Kotlin and google-java-format (AOSP style) for Java, runs ./gradlew spotlessCheck in the lint workflow, and documents ./gradlew spotlessApply in CONTRIBUTING.md.
Output of ./gradlew spotlessApply, plus manual, behaviour-neutral fixes for violations ktlint cannot fix on its own (wildcard imports, misplaced KDoc, long lines and string literals split with +). Documentation region tags are unchanged in count, order and position. No identifiers were renamed.
dkhawk
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds Spotless with ktlint (Kotlin) and google-java-format (Java) so formatting is checked automatically on pull requests, instead of in review comments.
The configuration matches the one already used in android-maps3d-samples, so all the Maps Android repos format code the same way.
Changes
build: add Spotless with ktlint...:spotless {}block covering every.ktand.javafile, including the tutorials outside the Gradle build.googleJavaFormat().aosp()(4-space), matching the existing code..editorconfignow hasmax_line_length = 120for Kotlin../gradlew spotlessCheckstep in thelintjob oflint.yml, and a note inCONTRIBUTING.mdto run./gradlew spotlessApplybefore opening a PR.style: apply Spotless formatting: the output of./gradlew spotlessApply, plus manual, behaviour-neutral fixes ktlint cannot do on its own: wildcard imports replaced, misplaced KDocs turned into block comments, long lines wrapped, and long string literals (mostly@Sample/@SnippetItemdescriptions) split with+so their values are unchanged. Seven lines over 120 characters are suppressed instead (raw-string Gemini prompts and one URL).Disabled ktlint rules, so this stays formatting-only:
package-name,property-naming,backing-property-naming,filename: fixing them would mean renames.annotation-spacing: in several ApiDemos files the// [START ...]tag sits between@Sample(...)and the class, and this rule would move the tag above the annotation, pulling@Sampleinto the published snippet.Region tags
Checked against
main: every file has the same[START/[ENDtags in the same order, each still on its own line, and no code moved into or out of a region. Code inside some regions is re-indented or reformatted (for example trailing commas or expression bodies), so the published snippets will look slightly different after the next docs sync.Merging
Please use rebase and merge so the reformat stays a separate commit. After merging, I will add its SHA to
.git-blame-ignore-revsin a small follow-up, sogit blameskips it.Open PRs will likely need a rebase and a
./gradlew spotlessApplyafter this lands.Verification
./gradlew spotlessCheck assembleDebug testDebugUnitTestpass locally, and the androidTest sources forsnippets:kotlin-appandApiDemos:kotlin-appcompile.