Skip to content

Commit 3afa1c4

Browse files
authored
Add spotless support for *.gradle.kts files (#6399)
The more we cover by the formatter the better. That being said, support for groovy is broken. I hit diffplug/spotless#1922 when trying to use groovyGradle formatting.
1 parent 99f4325 commit 3afa1c4

File tree

24 files changed

+410
-489
lines changed

24 files changed

+410
-489
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ configure(subprojects) {
9494
target 'src/**/*.kt'
9595
ktfmt('0.41').googleStyle()
9696
}
97+
kotlinGradle {
98+
target('*.gradle.kts') // default target for kotlinGradle
99+
ktfmt('0.41').googleStyle()
100+
}
97101
}
98102
}
99103

firebase-annotations/firebase-annotations.gradle.kts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,19 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
plugins {
16-
id("firebase-java-library")
17-
}
15+
plugins { id("firebase-java-library") }
1816

1917
firebaseLibrary {
2018
publishSources = true
2119
publishJavadoc = false
22-
releaseNotes {
23-
enabled.set(false)
24-
}
20+
releaseNotes { enabled.set(false) }
2521
}
2622

2723
java {
2824
sourceCompatibility = JavaVersion.VERSION_1_8
2925
targetCompatibility = JavaVersion.VERSION_1_8
3026
}
31-
tasks.withType<JavaCompile> {
32-
options.compilerArgs.add("-Werror")
33-
}
3427

35-
dependencies {
36-
implementation(libs.javax.inject)
37-
}
28+
tasks.withType<JavaCompile> { options.compilerArgs.add("-Werror") }
29+
30+
dependencies { implementation(libs.javax.inject) }

firebase-common/data-collection-tests/data-collection-tests.gradle.kts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
plugins {
16-
id("com.android.application")
17-
}
15+
plugins { id("com.android.application") }
1816

1917
android {
20-
val compileSdkVersion : Int by rootProject
21-
val targetSdkVersion : Int by rootProject
22-
val minSdkVersion : Int by rootProject
18+
val compileSdkVersion: Int by rootProject
19+
val targetSdkVersion: Int by rootProject
20+
val minSdkVersion: Int by rootProject
2321
compileSdk = compileSdkVersion
2422
namespace = "com.google.firebase.datacollectiontests"
2523
defaultConfig {
@@ -36,15 +34,15 @@ android {
3634
}
3735

3836
dependencies {
39-
implementation("com.google.firebase:firebase-common:21.0.0")
40-
implementation("com.google.firebase:firebase-components:18.0.0")
37+
implementation("com.google.firebase:firebase-common:21.0.0")
38+
implementation("com.google.firebase:firebase-components:18.0.0")
4139

42-
testImplementation(libs.androidx.core)
43-
testImplementation(libs.androidx.test.junit)
44-
testImplementation(libs.androidx.test.runner)
45-
testImplementation(libs.autovalue.annotations)
46-
testImplementation(libs.junit)
47-
testImplementation(libs.mockito.core)
48-
testImplementation(libs.robolectric)
49-
testImplementation(libs.truth)
40+
testImplementation(libs.androidx.core)
41+
testImplementation(libs.androidx.test.junit)
42+
testImplementation(libs.androidx.test.runner)
43+
testImplementation(libs.autovalue.annotations)
44+
testImplementation(libs.junit)
45+
testImplementation(libs.mockito.core)
46+
testImplementation(libs.robolectric)
47+
testImplementation(libs.truth)
5048
}

firebase-common/firebase-common.gradle.kts

Lines changed: 46 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,21 @@
1313
// limitations under the License.
1414

1515
plugins {
16-
id("firebase-library")
17-
id("kotlin-android")
16+
id("firebase-library")
17+
id("kotlin-android")
1818
}
1919

2020
firebaseLibrary {
21-
libraryGroup("common")
22-
testLab.enabled = true
23-
publishSources = true
24-
releaseNotes {
25-
enabled = false
26-
}
21+
libraryGroup("common")
22+
testLab.enabled = true
23+
publishSources = true
24+
releaseNotes { enabled = false }
2725
}
2826

2927
android {
30-
val compileSdkVersion : Int by rootProject
31-
val targetSdkVersion : Int by rootProject
32-
val minSdkVersion : Int by rootProject
28+
val compileSdkVersion: Int by rootProject
29+
val targetSdkVersion: Int by rootProject
30+
val minSdkVersion: Int by rootProject
3331

3432
compileSdk = compileSdkVersion
3533
namespace = "com.google.firebase"
@@ -41,62 +39,56 @@ android {
4139
consumerProguardFiles("proguard.txt")
4240
}
4341
sourceSets {
44-
getByName("androidTest") {
45-
java.srcDirs("src/testUtil")
46-
}
47-
getByName("test") {
48-
java.srcDirs("src/testUtil")
49-
}
42+
getByName("androidTest") { java.srcDirs("src/testUtil") }
43+
getByName("test") { java.srcDirs("src/testUtil") }
5044
}
5145
compileOptions {
5246
sourceCompatibility = JavaVersion.VERSION_1_8
5347
targetCompatibility = JavaVersion.VERSION_1_8
5448
}
55-
kotlinOptions {
56-
jvmTarget = "1.8"
57-
}
49+
kotlinOptions { jvmTarget = "1.8" }
5850
testOptions.unitTests.isIncludeAndroidResources = true
5951
}
6052

6153
dependencies {
62-
api(libs.kotlin.coroutines.tasks)
54+
api(libs.kotlin.coroutines.tasks)
6355

64-
api("com.google.firebase:firebase-components:18.0.0")
65-
api("com.google.firebase:firebase-annotations:16.2.0")
66-
implementation(libs.androidx.annotation)
67-
implementation(libs.androidx.futures)
68-
implementation(libs.kotlin.stdlib)
69-
implementation(libs.playservices.basement)
70-
implementation(libs.playservices.tasks)
56+
api("com.google.firebase:firebase-components:18.0.0")
57+
api("com.google.firebase:firebase-annotations:16.2.0")
58+
implementation(libs.androidx.annotation)
59+
implementation(libs.androidx.futures)
60+
implementation(libs.kotlin.stdlib)
61+
implementation(libs.playservices.basement)
62+
implementation(libs.playservices.tasks)
7163

72-
compileOnly(libs.autovalue.annotations)
73-
compileOnly(libs.findbugs.jsr305)
74-
compileOnly(libs.kotlin.stdlib)
64+
compileOnly(libs.autovalue.annotations)
65+
compileOnly(libs.findbugs.jsr305)
66+
compileOnly(libs.kotlin.stdlib)
7567

76-
annotationProcessor(libs.autovalue)
68+
annotationProcessor(libs.autovalue)
7769

78-
testImplementation("com.google.guava:guava-testlib:12.0-rc2")
79-
testImplementation(libs.androidx.test.core)
80-
testImplementation(libs.androidx.test.junit)
81-
testImplementation(libs.androidx.test.runner)
82-
testImplementation(libs.junit)
83-
testImplementation(libs.kotlin.coroutines.test)
84-
testImplementation(libs.mockito.core)
85-
testImplementation(libs.org.json)
86-
testImplementation(libs.robolectric)
87-
testImplementation(libs.truth)
70+
testImplementation("com.google.guava:guava-testlib:12.0-rc2")
71+
testImplementation(libs.androidx.test.core)
72+
testImplementation(libs.androidx.test.junit)
73+
testImplementation(libs.androidx.test.runner)
74+
testImplementation(libs.junit)
75+
testImplementation(libs.kotlin.coroutines.test)
76+
testImplementation(libs.mockito.core)
77+
testImplementation(libs.org.json)
78+
testImplementation(libs.robolectric)
79+
testImplementation(libs.truth)
8880

89-
androidTestImplementation(project(":integ-testing")) {
90-
exclude("com.google.firebase","firebase-common")
91-
exclude("com.google.firebase","firebase-common-ktx")
92-
}
81+
androidTestImplementation(project(":integ-testing")) {
82+
exclude("com.google.firebase", "firebase-common")
83+
exclude("com.google.firebase", "firebase-common-ktx")
84+
}
9385

94-
// TODO(Remove when FirbaseAppTest has been modernized to use LiveData)
95-
androidTestImplementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
96-
androidTestImplementation(libs.androidx.test.junit)
97-
androidTestImplementation(libs.androidx.test.runner)
98-
androidTestImplementation(libs.junit)
99-
androidTestImplementation(libs.mockito.core)
100-
androidTestImplementation(libs.mockito.dexmaker)
101-
androidTestImplementation(libs.truth)
86+
// TODO(Remove when FirbaseAppTest has been modernized to use LiveData)
87+
androidTestImplementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
88+
androidTestImplementation(libs.androidx.test.junit)
89+
androidTestImplementation(libs.androidx.test.runner)
90+
androidTestImplementation(libs.junit)
91+
androidTestImplementation(libs.mockito.core)
92+
androidTestImplementation(libs.mockito.dexmaker)
93+
androidTestImplementation(libs.truth)
10294
}

firebase-common/ktx/ktx.gradle.kts

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,41 @@
1313
// limitations under the License.
1414

1515
plugins {
16-
id("firebase-library")
17-
id("kotlin-android")
16+
id("firebase-library")
17+
id("kotlin-android")
1818
}
1919

2020
firebaseLibrary {
21-
libraryGroup("common")
22-
publishJavadoc = false
23-
releaseNotes {
24-
enabled.set(false)
25-
}
21+
libraryGroup("common")
22+
publishJavadoc = false
23+
releaseNotes { enabled.set(false) }
2624
}
2725

2826
android {
29-
val compileSdkVersion : Int by rootProject
30-
val targetSdkVersion : Int by rootProject
31-
val minSdkVersion : Int by rootProject
32-
compileSdk = compileSdkVersion
33-
namespace = "com.google.firebase.ktx"
34-
defaultConfig {
35-
minSdk = minSdkVersion
36-
targetSdk = targetSdkVersion
37-
}
38-
sourceSets {
39-
getByName("main") {
40-
java.srcDirs("src/main/kotlin")
41-
}
42-
getByName("test") {
43-
java.srcDirs("src/test/kotlin")
44-
}
45-
}
46-
kotlinOptions {
47-
jvmTarget = "1.8"
48-
}
49-
testOptions.unitTests.isIncludeAndroidResources = true
27+
val compileSdkVersion: Int by rootProject
28+
val targetSdkVersion: Int by rootProject
29+
val minSdkVersion: Int by rootProject
30+
compileSdk = compileSdkVersion
31+
namespace = "com.google.firebase.ktx"
32+
defaultConfig {
33+
minSdk = minSdkVersion
34+
targetSdk = targetSdkVersion
35+
}
36+
sourceSets {
37+
getByName("main") { java.srcDirs("src/main/kotlin") }
38+
getByName("test") { java.srcDirs("src/test/kotlin") }
39+
}
40+
kotlinOptions { jvmTarget = "1.8" }
41+
testOptions.unitTests.isIncludeAndroidResources = true
5042
}
5143

5244
dependencies {
53-
api(project(":firebase-common"))
54-
implementation("com.google.firebase:firebase-components:18.0.0")
55-
implementation("com.google.firebase:firebase-annotations:16.2.0")
56-
testImplementation(libs.androidx.test.core)
57-
testImplementation(libs.junit)
58-
testImplementation(libs.kotlin.coroutines.test)
59-
testImplementation(libs.robolectric)
60-
testImplementation(libs.truth)
45+
api(project(":firebase-common"))
46+
implementation("com.google.firebase:firebase-components:18.0.0")
47+
implementation("com.google.firebase:firebase-annotations:16.2.0")
48+
testImplementation(libs.androidx.test.core)
49+
testImplementation(libs.junit)
50+
testImplementation(libs.kotlin.coroutines.test)
51+
testImplementation(libs.robolectric)
52+
testImplementation(libs.truth)
6153
}

firebase-components/firebase-components.gradle.kts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
plugins {
16-
id("firebase-library")
17-
}
15+
plugins { id("firebase-library") }
1816

1917
firebaseLibrary {
20-
publishSources = true
21-
publishJavadoc = false
22-
releaseNotes {
23-
enabled.set(false)
24-
}
18+
publishSources = true
19+
publishJavadoc = false
20+
releaseNotes { enabled.set(false) }
2521
}
2622

2723
android {
28-
val compileSdkVersion : Int by rootProject
29-
val targetSdkVersion : Int by rootProject
30-
val minSdkVersion : Int by rootProject
24+
val compileSdkVersion: Int by rootProject
25+
val targetSdkVersion: Int by rootProject
26+
val minSdkVersion: Int by rootProject
3127
compileSdk = compileSdkVersion
3228
namespace = "com.google.firebase.components"
3329
defaultConfig {

firebase-components/firebase-dynamic-module-support/firebase-dynamic-module-support.gradle.kts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
plugins {
16-
id("firebase-library")
17-
}
15+
plugins { id("firebase-library") }
1816

1917
group = "com.google.firebase"
2018

@@ -30,9 +28,9 @@ firebaseLibrary {
3028
}
3129

3230
android {
33-
val compileSdkVersion : Int by rootProject
34-
val targetSdkVersion : Int by rootProject
35-
val minSdkVersion : Int by rootProject
31+
val compileSdkVersion: Int by rootProject
32+
val targetSdkVersion: Int by rootProject
33+
val minSdkVersion: Int by rootProject
3634
compileSdk = compileSdkVersion
3735
namespace = "com.google.firebase.dynamicloading"
3836
defaultConfig {

0 commit comments

Comments
 (0)