Skip to content

Apply spotless by default#2055

Merged
liutikas merged 4 commits intoandroid:mainfrom
liutikas:spotlessdefaulton
Jan 30, 2026
Merged

Apply spotless by default#2055
liutikas merged 4 commits intoandroid:mainfrom
liutikas:spotlessdefaulton

Conversation

@liutikas
Copy link
Collaborator

@liutikas liutikas commented Jan 30, 2026

  • Upgrades to spotless 8.2.1
  • Moves spotless setup from an init.gradle.kts to build-logic
  • Narrows down the scope of target in spotless configuration to be more precise to workaround Reduce performance overhead diffplug/spotless#2717
  • Updates all references to init.gradle.kts
  • Enables validating build-logic sources through the root project.

Ran gradle-profiler ./gradlew build --dry-run to validate performance impact.
Before PR:
Mean 10,527.96 ms with 289.01 ms std dev
After PR:
Mean 11,251.78 ms with 530.29 ms std dev

Regression is there, but quite minor.

Test: ./gradlew spotlessCheck

Fixes #1832

- Upgrades to spotless 8.2.1
- Moves spotless setup from an init.gradle.kts to build-logic
- Narrows down the scope of `target` in spotless configuration to
  be more precise to workaround diffplug/spotless#2717
- Updates all references to init.gradle.kts

Ran gradle-profiler ./gradlew build --dry-run to validate performance
impact.
Before PR:
Mean 10,527.96 ms with 289.01 ms std dev
After PR:
Mean 11,251.78 ms with 530.29 ms std dev

Regression is there, but quite minor.

Test: ./gradlew spotlessCheck
@liutikas liutikas requested a review from dturner as a code owner January 30, 2026 00:23
@gemini-code-assist
Copy link

Summary of Changes

Hello @liutikas, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the project's code formatting setup by integrating the Spotless plugin directly into the build-logic convention plugins. This change ensures that consistent code style is enforced by default across all modules, simplifying the development workflow and reducing manual configuration. The migration also involves updating the Spotless plugin version and refining its application scope.

Highlights

  • Spotless Upgrade: The Spotless Gradle plugin has been upgraded to version 8.2.1, bringing the project up to date with the latest formatting capabilities and fixes.
  • Configuration Migration to Build-Logic: The entire Spotless configuration has been moved from the gradle/init.gradle.kts initialization script into the build-logic convention plugins. This centralizes and standardizes the formatting setup, making Spotless applied by default to all relevant modules (Android applications, Android libraries, and JVM libraries).
  • Refined Spotless Target Scopes: The target scopes within the Spotless configuration have been narrowed down for more precision, specifically for XML files, to work around a known issue (Reduce performance overhead diffplug/spotless#2717).
  • Removal of init.gradle.kts: The gradle/init.gradle.kts file, which previously housed the Spotless configuration, has been removed. All references to this init script in documentation and run configurations have also been updated.
  • Performance Impact: A minor performance regression was observed during gradlew build --dry-run, with the mean build time increasing from 10,527.96 ms to 11,251.78 ms. This is considered acceptable given the benefits of standardized formatting.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/Build.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great improvement, refactoring the Spotless configuration from a Gradle init script into the build-logic convention plugins. This enhances the project's structure and maintainability. The dependency updates and removal of the old init script are all handled correctly. I've added a few suggestions to remove some unused imports and to make the new Spotless configuration more robust by enforcing that all formatted files end with a newline.

@SimonMarquis
Copy link
Contributor

Hi @liutikas, can you add this issue as fixed in your PR?


Also, I was wondering if is there was a specific reason to move the init.gradle.kts to build-logic? (apart from using init script altogether, and making it slightly easier to use from the gradlew CLI).

One last thing to note here also is that spotless is sadly not run on the build-logic project itself :/

Copy link
Collaborator

@dturner dturner left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. One very minor suggestion.

@liutikas
Copy link
Collaborator Author

Hi @liutikas, can you add this issue as fixed in your PR?

Added to the PR message

Also, I was wondering if is there was a specific reason to move the init.gradle.kts to build-logic? (apart from using init script altogether, and making it slightly easier to use from the gradlew CLI).

Init scripts are burdensome to invoke and now that spotless is CC compatible the need to have it spit out is no longer there.

One last thing to note here also is that spotless is sadly not run on the build-logic project itself :/

Fixed, now root project validates build-logic sources.

@liutikas liutikas merged commit 5ba16ed into android:main Jan 30, 2026
6 checks passed
@liutikas liutikas deleted the spotlessdefaulton branch January 30, 2026 17:17
@ColtonIdle
Copy link

Hello! I'm confused how this PR actually introduces a slight regression. is this due to the move to build-logic?

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.

Spotless config is using heavily discouraged wildcards

4 participants