Skip to content

Commit ccc716e

Browse files
committed
Add Kotlin formatting to Spotless
ratchetFrom means Spotless will apply only to files which have changed since origin/main It also means we need to make some changes to CI due to ensure builds pass due to shallow clones. See https://github.com/diffplug/spotless/tree/main/plugin-gradle#using-ratchetfrom-on-ci-systems for more details.
1 parent 2afa02b commit ccc716e

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,7 @@ ij_kotlin_while_on_new_line = false
9191
ij_kotlin_wrap_elvis_expressions = 1
9292
ij_kotlin_wrap_expression_body_functions = 1
9393
ij_kotlin_wrap_first_method_in_call_chain = false
94+
ktlint_standard_no-wildcard-imports = disabled
95+
ktlint_standard_filename = disabled
96+
ktlint_standard_package-name = disabled
97+
ktlint_standard_annotation = disabled

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
2929
with:
30+
fetch-depth: 0 # required due to setting Spotless ratchetFrom
3031
submodules: recursive
3132

3233
- name: Set up JDK version
@@ -39,7 +40,7 @@ jobs:
3940
uses: gradle/actions/setup-gradle@v3
4041

4142
- name: Run Code Formatting Checks
42-
run: ./gradlew code_format_checks
43+
run: ./gradlew spotlessCheck
4344

4445
unit_tests:
4546
name: Unit tests

.github/workflows/nightly.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020
with:
21+
fetch-depth: 0 # required due to setting Spotless ratchetFrom
2122
submodules: recursive
2223

2324
- name: Set up JDK version
@@ -30,7 +31,7 @@ jobs:
3031
uses: gradle/actions/setup-gradle@v3
3132

3233
- name: Run Code Formatting Checks
33-
run: ./gradlew code_format_checks
34+
run: ./gradlew spotlessCheck
3435

3536
unit_tests:
3637
name: Unit tests

code-formatting.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
apply plugin: 'com.diffplug.spotless'
22

33
spotless {
4+
ratchetFrom 'origin/develop'
5+
kotlin {
6+
target 'src/*/kotlin/**/*.kt', 'src/*/java/**/*.kt'
7+
ktlint("1.7.1")
8+
trimTrailingWhitespace()
9+
indentWithSpaces()
10+
}
411
java {
512
target 'src/*/java/**/*.java'
613
googleJavaFormat('1.22.0').aosp()

0 commit comments

Comments
 (0)