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.
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:
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:This has been fixed in Spotless 6.23 and above. Latest version is 6.25.0. However, updating results in another error:
This is because of a breaking change in which
userData
was removed when changing the default version of ktlint to 1.0.1.