Skip to content

Commit b340be0

Browse files
authored
Merge pull request #66 from android/spotless
Remove the need to have separate spotless config
2 parents cca81c5 + 4b1c0d5 commit b340be0

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: chmod +x gradlew
4141

4242
- name: Apply Spotless
43-
run: ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache
43+
run: ./gradlew spotlessApply
4444

4545
- name: Commit Spotless changes
4646
uses: stefanzweifel/git-auto-commit-action@v5

.run/spotlessApply.run.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<option name="executionName" />
2020
<option name="externalProjectPath" value="$PROJECT_DIR$" />
2121
<option name="externalSystemIdString" value="GRADLE" />
22-
<option name="scriptParameters" value="--init-script=gradle/init.gradle.kts" />
2322
<option name="taskDescriptions">
2423
<list />
2524
</option>

build.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,35 @@ plugins {
1111
alias(libs.plugins.crashlytics) apply false
1212
alias(libs.plugins.android.test) apply false
1313
alias(libs.plugins.baselineprofile) apply false
14+
alias(libs.plugins.spotless) apply false
15+
}
16+
17+
18+
subprojects {
19+
apply(plugin = "com.diffplug.spotless")
20+
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
21+
kotlin {
22+
target("**/*.kt")
23+
targetExclude("**/build/**/*.kt")
24+
ktlint(libs.versions.ktlint.get()).editorConfigOverride(
25+
mapOf(
26+
"android" to "true",
27+
"ktlint_standard_property-naming" to "disabled"
28+
),
29+
)
30+
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
31+
}
32+
kotlinGradle {
33+
target("**/*.kts")
34+
targetExclude("**/build/**/*.kts")
35+
// Look for the first line that doesn't have a block comment (assumed to be the license)
36+
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
37+
}
38+
format("xml") {
39+
target("**/*.xml")
40+
targetExclude("**/build/**/*.xml")
41+
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
42+
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
43+
}
44+
}
1445
}

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ ksp = "2.1.20-1.0.32"
3838
kotlinxCoroutines = "1.10.2"
3939
kotlinxSerialization = "2.1.20"
4040
kotlinxSerializationJson = "1.8.1"
41+
ktlint = "1.5.0"
4142
lifecycleRuntimeKtx = "2.8.7"
4243
lifecycleViewmodelNavigation3 = "1.0.0-SNAPSHOT"
4344
loggingInterceptor = "5.0.0-alpha.14"
@@ -49,6 +50,7 @@ poseDetection = "18.0.0-beta5"
4950
profileinstaller = "1.4.1"
5051
retrofit = "2.11.0"
5152
robolectric = "4.14.1"
53+
spotless = "7.0.2"
5254
startup = "1.2.0"
5355
runner = "1.6.2"
5456
uiTextGoogleFonts = "1.8.0"
@@ -142,3 +144,4 @@ serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref
142144
android-test = { id = "com.android.test", version.ref = "agp" }
143145
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
144146
composeScreenshot = { id = "com.android.compose.screenshot", version = "0.0.1-alpha09" }
147+
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

0 commit comments

Comments
 (0)