Skip to content

Commit aea8904

Browse files
committed
Remove the need to have separate spotless config
1 parent 401df3d commit aea8904

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,36 @@ 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+
val ktlintVersion = "1.5.0"
18+
19+
subprojects {
20+
apply(plugin = "com.diffplug.spotless")
21+
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
22+
kotlin {
23+
target("**/*.kt")
24+
targetExclude("**/build/**/*.kt")
25+
ktlint(ktlintVersion).editorConfigOverride(
26+
mapOf(
27+
"android" to "true",
28+
"ktlint_standard_property-naming" to "disabled"
29+
),
30+
)
31+
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
32+
}
33+
format("kts") {
34+
target("**/*.kts")
35+
targetExclude("**/build/**/*.kts")
36+
// Look for the first line that doesn't have a block comment (assumed to be the license)
37+
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
38+
}
39+
format("xml") {
40+
target("**/*.xml")
41+
targetExclude("**/build/**/*.xml")
42+
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
43+
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
44+
}
45+
}
1446
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ poseDetection = "18.0.0-beta5"
4949
profileinstaller = "1.4.1"
5050
retrofit = "2.11.0"
5151
robolectric = "4.14.1"
52+
spotless = "7.0.2"
5253
startup = "1.2.0"
5354
runner = "1.6.2"
5455
uiTextGoogleFonts = "1.8.0"
@@ -142,3 +143,4 @@ serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref
142143
android-test = { id = "com.android.test", version.ref = "agp" }
143144
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
144145
composeScreenshot = { id = "com.android.compose.screenshot", version = "0.0.1-alpha09" }
146+
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

0 commit comments

Comments
 (0)