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

Update Spotless and ktlint - Code style rule changes #1002

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dturner
Copy link
Collaborator

@dturner dturner commented Apr 8, 2024

What have I done and why
tl;dr I have updated spotless and ktlint versions, however, this has resulted in some code style rule changes. This PR is to discuss:

  • whether we want to modify those rules.
  • whether doing spotlessApply with an init script is still the right way of doing things. This was originally implemented because spotless didn't support gradle configuration caching. Not sure if that's changed.

Background
Updating to gradle 8.6 causes the spotlessApply command to fail:

 ./gradlew --init-script gradle/init.gradle.kts spotlessApply
FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

2 problems were found storing the configuration cache.
- Initialization script 'gradle/init.gradle.kts': external process started '/opt/homebrew/bin/git --version'
  See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Initialization script 'gradle/init.gradle.kts': external process started '/opt/homebrew/bin/git config --system --show-origin --list -z'
  See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes

See the complete report at file:///Users/donturner/Code/workspace-android/architecture-samples/build/reports/configuration-cache/1esjztc97tjp4wgqxvsn7m1so/57o8ne9vw46zzt740jxphe4h9/configuration-cache-report.html
> Starting an external process '/opt/homebrew/bin/git --version' during configuration time is unsupported.
> Starting an external process '/opt/homebrew/bin/git config --system --show-origin --list -z' during configuration time is unsupported.

This has been fixed in Spotless 6.23 and above. Latest version is 6.25.0. However, updating results in another error:

e: file:///Users/donturner/Code/workspace-android/architecture-samples/gradle/init.gradle.kts:42:39: Unresolved reference: userData

FAILURE: Build failed with an exception.

* Where:
Initialization script '/Users/donturner/Code/workspace-android/architecture-samples/gradle/init.gradle.kts' line: 42

* What went wrong:
Script compilation error:

  Line 42:                 ktlint(ktlintVersion).userData(mapOf("android" to "true"))
                                                 ^ Unresolved reference: userData

1 error

This is because of a breaking change in which userData was removed when changing the default version of ktlint to 1.0.1.

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.

1 participant