-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Move Spotless configurations from buildscripts/init.gradle.kts to build.gradle.kts #1549
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @cartland, 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!
Summary of Changes
This pull request migrates the Spotless configuration from buildscripts/init.gradle.kts
to build.gradle.kts
for several projects (JetLagged, JetNews, Jetcaster, Jetchat, Jetsnack, and Reply). This change allows developers to use the standard ./gradlew spotlessCheck
command. The Spotless configuration includes ktlint with a set of disabled rules and applies a license header. The libs.versions.toml
file is also updated to include the Spotless plugin version.
Highlights
- Spotless Configuration Migration: Moves Spotless configuration from
buildscripts/init.gradle.kts
tobuild.gradle.kts
for easier discoverability and execution. - Gradle Plugin Update: Adds the Spotless Gradle plugin to the
libs.versions.toml
file. - Ktlint Configuration: Configures ktlint with specific rules and exclusions, including disabling certain rules introduced in ktlint 0.46.0.
- License Header: Applies a license header to Kotlin and KTS files.
Changelog
Click here to see the changelog
- JetLagged/build.gradle.kts
- Adds the Spotless plugin.
- Configures Spotless extension with Kotlin and KTS formatting rules.
- Specifies ktlint configuration with disabled rules and license header.
- JetLagged/buildscripts/init.gradle.kts
- Removes the entire file, as the Spotless configuration is now in
build.gradle.kts
.
- Removes the entire file, as the Spotless configuration is now in
- JetLagged/gradle/libs.versions.toml
- Adds the Spotless plugin and its version to the TOML file.
- JetNews/build.gradle.kts
- Adds the Spotless plugin.
- Configures Spotless extension with Kotlin and KTS formatting rules.
- Specifies ktlint configuration with disabled rules and license header.
- JetNews/buildscripts/init.gradle.kts
- Removes the entire file, as the Spotless configuration is now in
build.gradle.kts
.
- Removes the entire file, as the Spotless configuration is now in
- JetNews/gradle/libs.versions.toml
- Adds the Spotless plugin and its version to the TOML file.
- Jetcaster/build.gradle.kts
- Adds the Spotless plugin.
- Configures Spotless extension with Kotlin and KTS formatting rules.
- Specifies ktlint configuration with disabled rules and license header.
- Jetcaster/buildscripts/init.gradle.kts
- Removes the entire file, as the Spotless configuration is now in
build.gradle.kts
.
- Removes the entire file, as the Spotless configuration is now in
- Jetcaster/gradle/libs.versions.toml
- Adds the Spotless plugin and its version to the TOML file.
- Jetchat/build.gradle.kts
- Adds the Spotless plugin.
- Configures Spotless extension with Kotlin and KTS formatting rules.
- Specifies ktlint configuration with disabled rules and license header.
- Jetchat/buildscripts/init.gradle.kts
- Removes the entire file, as the Spotless configuration is now in
build.gradle.kts
.
- Removes the entire file, as the Spotless configuration is now in
- Jetchat/gradle/libs.versions.toml
- Adds the Spotless plugin and its version to the TOML file.
- Jetsnack/build.gradle.kts
- Adds the Spotless plugin.
- Configures Spotless extension with Kotlin and KTS formatting rules.
- Specifies ktlint configuration with disabled rules and license header.
- Jetsnack/buildscripts/init.gradle.kts
- Removes the entire file, as the Spotless configuration is now in
build.gradle.kts
.
- Removes the entire file, as the Spotless configuration is now in
- Jetsnack/gradle/libs.versions.toml
- Adds the Spotless plugin and its version to the TOML file.
- Reply/build.gradle.kts
- Adds the Spotless plugin.
- Configures Spotless extension with Kotlin and KTS formatting rules.
- Specifies ktlint configuration with disabled rules and license header.
- Reply/buildscripts/init.gradle.kts
- Removes the entire file, as the Spotless configuration is now in
build.gradle.kts
.
- Removes the entire file, as the Spotless configuration is now in
- Reply/gradle/libs.versions.toml
- Adds the Spotless plugin and its version to the TOML file.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 is currently in preview and 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 to provide feedback.
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.
From init script's hold,
Spotless config takes flight,
In build's embrace now.
Footnotes
-
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. ↩
There was a problem hiding this 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 moves the Spotless configurations from buildscripts/init.gradle.kts
to build.gradle.kts
for several Android projects. This change allows developers to use the ./gradlew spotlessCheck
command, which was previously unavailable due to the configuration being in an init script. The changes look good overall, but there are a few areas that could be improved.
Summary of Findings
- Redundant
apply(plugin = "com.diffplug.spotless")
: Theapply(plugin = "com.diffplug.spotless")
call within thesubprojects
block inbuild.gradle.kts
files is redundant because the plugin is already applied at the top level. This redundancy can be removed to simplify the build configuration. - Consistency in
ktlint_code_style
: Thektlint_code_style
is set toandroid_studio
in the new configuration, while it wasandroid
in the old configuration. It's important to ensure that this change is intentional and doesn't introduce unintended formatting differences.
Merge Readiness
The pull request is almost ready for merging. Addressing the redundant plugin application and confirming the intentional change in ktlint_code_style
would improve the overall quality of the changes. I am unable to approve the pull request in any circumstance, and users should have others review and approve this code before merging. Once these points are addressed, the pull request should be good to go.
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct because I want to apply the plugin to the subprojects
. @bentrengrove do you see any optimization I can make?
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub Actions cannot references origin/main ratchetFrom = "57913c513a17c39a93d9a5bab4284fbf9c85dc98"
The spotless action requires enough git history to correctly determine which files have been modified. This commit configures the checkout action to fetch the full history by setting `fetch-depth: 0`. If we remove usage of ratchetFrom we should be able to remove this.
This reverts commit 75ad3bc.
I have updated all projects to the latest version of Compose (1.8) which was released today. [More info here](https://android-developers.googleblog.com/2025/04/whats-new-in-jetpack-compose-april-25.html). I encountered the following issues and have documented their resolutions below: **Could not get unknown property 'keepUnusedLibraries'** After updating the version-catalog-update-plugin from 0.8.5 to 1.0.0 I received the following error: ``` Could not get unknown property 'keepUnusedLibraries' for extension 'versionCatalogUpdate' property 'keep' of type nl.littlerobots.vcu.plugin.KeepConfiguration. ``` Cause: The plugin no longer supports various `keep` properties. Fix: Remove the unsupported `keep` properties from the build config. More info: [here](littlerobots/version-catalog-update-plugin@787b856#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L27-L215 ) and [here](https://github.com/littlerobots/version-catalog-update-plugin/blob/main/CHANGELOG.md#resolving-dependencies) **Minimum supported Gradle version is 8.11.1. Current version is 8.10.2.** Fix: Search and replace `gradle-8.10.2-bin.zip` with `gradle-8.13-bin.zip` throughout repo **Suspend function 'suspend fun navigateBack(backNavigationBehavior: BackNavigationBehavior): Boolean' can only be called from a coroutine or another suspend function.** Full error: ``` e: file:///Users/donturner/Code/workspace-android/compose-samples/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt:268:19 Suspend function 'suspend fun navigateBack(backNavigationBehavior: BackNavigationBehavior): Boolean' can only be called from a coroutine or another suspend function. ``` Root cause: `ThreePaneScaffoldNavigator.navigateBack` [became a suspend fun](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive#1.1.0-alpha04). Fix: Wrap `navigate` calls in `coroutineScope.launch` **Unresolved reference ThreePaneScaffoldNavigator.currentDestination.content** Cause: Property name changed from `content` to `contentKey` Fix: Change to `contentKey` **Core library desugaring runtime library version 1.2.2 does not support compileSdk=35 or later; please upgrade to version 2.1.5** Fix: Update jdkDesugar to 2.1.5 **Failed to apply plugin 'com.diffplug.spotless'.** Cause: `scripts/verify_samples.sh` still assumed that the spotless config would be in a separate init file, but no longer does following [this PR](#1549). Fix: Update `scripts/verify_samples.sh` to use the `spotlessCheck` task from each app's `build.gradle.kts`. **Spotless formatting issues** `Home.kt` from Jetcaster had formatting issues. Running `spotlessApply` fixes the issues but also changes code that isn't directly related to the version updates and makes reviewing difficult. For the purposes of reviewing, the original changes are [in this commit](52154e0#diff-419acc413220ab5d19bee9df1ca6b8c76d269287edf45c2895759df050d1e05a).
Getting Spotless to fully work on these projects can be separated in 2 steps:
buildscripts/init.gradle.kts
andbuild-sample.yml
ratchetFrom = "origin/main"
and fix Spotless issues.Each project currently uses Spotless with
--init-script buildscripts/init.gradle.kts
. The team decided not to configure Spotless inbuild.gradle.kts
because Spotless did not yet support Gradle Configuration Cache, which would significantly impact build performance. That means that these projects cannot use the typical Gradle command./gradlew spotlessCheck
. The flag--init-script buildscripts/init.gradle.kts
is currently used in this GitHub Actions configuration that is shared by all 6 projects withuses: ./.github/workflows/build-sample.yml
.compose-samples/.github/workflows/build-sample.yml
Line 62 in 57913c5
Spotless version 7.0.0 supports configuration cache. From the release notes: "Full, no asterisk support for configuration cache (end of diffplug/spotless#987)"
As a first step, we can move the Spotless configuration from
buildscripts/init.gradle.kts
tobuild.gradle.kts
. This has the immediate benefit that you can discover and run Spotless.This configuration uses
ratchetFrom = "origin/main"
which only enforces Spotless checks on files that are different fromorigin/main
. In a future step, we can remove this line and fix the Spotless checks for each project. For example, Jetcaster has violations of:standard:filename
,standard:property-naming
,standard:backing-property-naming
,standard:package-name
. Instead of suppressing or fixing all potential issues for all 6 projects now, we can separate the configuration (right now) and fix each project one-at-a-time (later).