Skip to content

Commit

Permalink
Add spotless support for *.gradle.kts files (#6399)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rlazo authored Oct 22, 2024
1 parent 99f4325 commit 3afa1c4
Show file tree
Hide file tree
Showing 24 changed files with 410 additions and 489 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ configure(subprojects) {
target 'src/**/*.kt'
ktfmt('0.41').googleStyle()
}
kotlinGradle {
target('*.gradle.kts') // default target for kotlinGradle
ktfmt('0.41').googleStyle()
}
}
}

Expand Down
17 changes: 5 additions & 12 deletions firebase-annotations/firebase-annotations.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

plugins {
id("firebase-java-library")
}
plugins { id("firebase-java-library") }

firebaseLibrary {
publishSources = true
publishJavadoc = false
releaseNotes {
enabled.set(false)
}
releaseNotes { enabled.set(false) }
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<JavaCompile> {
options.compilerArgs.add("-Werror")
}

dependencies {
implementation(libs.javax.inject)
}
tasks.withType<JavaCompile> { options.compilerArgs.add("-Werror") }

dependencies { implementation(libs.javax.inject) }
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

plugins {
id("com.android.application")
}
plugins { id("com.android.application") }

android {
val compileSdkVersion : Int by rootProject
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject
val compileSdkVersion: Int by rootProject
val targetSdkVersion: Int by rootProject
val minSdkVersion: Int by rootProject
compileSdk = compileSdkVersion
namespace = "com.google.firebase.datacollectiontests"
defaultConfig {
Expand All @@ -36,15 +34,15 @@ android {
}

dependencies {
implementation("com.google.firebase:firebase-common:21.0.0")
implementation("com.google.firebase:firebase-components:18.0.0")
implementation("com.google.firebase:firebase-common:21.0.0")
implementation("com.google.firebase:firebase-components:18.0.0")

testImplementation(libs.androidx.core)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.autovalue.annotations)
testImplementation(libs.junit)
testImplementation(libs.mockito.core)
testImplementation(libs.robolectric)
testImplementation(libs.truth)
testImplementation(libs.androidx.core)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.autovalue.annotations)
testImplementation(libs.junit)
testImplementation(libs.mockito.core)
testImplementation(libs.robolectric)
testImplementation(libs.truth)
}
100 changes: 46 additions & 54 deletions firebase-common/firebase-common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@
// limitations under the License.

plugins {
id("firebase-library")
id("kotlin-android")
id("firebase-library")
id("kotlin-android")
}

firebaseLibrary {
libraryGroup("common")
testLab.enabled = true
publishSources = true
releaseNotes {
enabled = false
}
libraryGroup("common")
testLab.enabled = true
publishSources = true
releaseNotes { enabled = false }
}

android {
val compileSdkVersion : Int by rootProject
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject
val compileSdkVersion: Int by rootProject
val targetSdkVersion: Int by rootProject
val minSdkVersion: Int by rootProject

compileSdk = compileSdkVersion
namespace = "com.google.firebase"
Expand All @@ -41,62 +39,56 @@ android {
consumerProguardFiles("proguard.txt")
}
sourceSets {
getByName("androidTest") {
java.srcDirs("src/testUtil")
}
getByName("test") {
java.srcDirs("src/testUtil")
}
getByName("androidTest") { java.srcDirs("src/testUtil") }
getByName("test") { java.srcDirs("src/testUtil") }
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
kotlinOptions { jvmTarget = "1.8" }
testOptions.unitTests.isIncludeAndroidResources = true
}

dependencies {
api(libs.kotlin.coroutines.tasks)
api(libs.kotlin.coroutines.tasks)

api("com.google.firebase:firebase-components:18.0.0")
api("com.google.firebase:firebase-annotations:16.2.0")
implementation(libs.androidx.annotation)
implementation(libs.androidx.futures)
implementation(libs.kotlin.stdlib)
implementation(libs.playservices.basement)
implementation(libs.playservices.tasks)
api("com.google.firebase:firebase-components:18.0.0")
api("com.google.firebase:firebase-annotations:16.2.0")
implementation(libs.androidx.annotation)
implementation(libs.androidx.futures)
implementation(libs.kotlin.stdlib)
implementation(libs.playservices.basement)
implementation(libs.playservices.tasks)

compileOnly(libs.autovalue.annotations)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.kotlin.stdlib)
compileOnly(libs.autovalue.annotations)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.kotlin.stdlib)

annotationProcessor(libs.autovalue)
annotationProcessor(libs.autovalue)

testImplementation("com.google.guava:guava-testlib:12.0-rc2")
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.junit)
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.mockito.core)
testImplementation(libs.org.json)
testImplementation(libs.robolectric)
testImplementation(libs.truth)
testImplementation("com.google.guava:guava-testlib:12.0-rc2")
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.junit)
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.mockito.core)
testImplementation(libs.org.json)
testImplementation(libs.robolectric)
testImplementation(libs.truth)

androidTestImplementation(project(":integ-testing")) {
exclude("com.google.firebase","firebase-common")
exclude("com.google.firebase","firebase-common-ktx")
}
androidTestImplementation(project(":integ-testing")) {
exclude("com.google.firebase", "firebase-common")
exclude("com.google.firebase", "firebase-common-ktx")
}

// TODO(Remove when FirbaseAppTest has been modernized to use LiveData)
androidTestImplementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.mockito.core)
androidTestImplementation(libs.mockito.dexmaker)
androidTestImplementation(libs.truth)
// TODO(Remove when FirbaseAppTest has been modernized to use LiveData)
androidTestImplementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.mockito.core)
androidTestImplementation(libs.mockito.dexmaker)
androidTestImplementation(libs.truth)
}
64 changes: 28 additions & 36 deletions firebase-common/ktx/ktx.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,41 @@
// limitations under the License.

plugins {
id("firebase-library")
id("kotlin-android")
id("firebase-library")
id("kotlin-android")
}

firebaseLibrary {
libraryGroup("common")
publishJavadoc = false
releaseNotes {
enabled.set(false)
}
libraryGroup("common")
publishJavadoc = false
releaseNotes { enabled.set(false) }
}

android {
val compileSdkVersion : Int by rootProject
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject
compileSdk = compileSdkVersion
namespace = "com.google.firebase.ktx"
defaultConfig {
minSdk = minSdkVersion
targetSdk = targetSdkVersion
}
sourceSets {
getByName("main") {
java.srcDirs("src/main/kotlin")
}
getByName("test") {
java.srcDirs("src/test/kotlin")
}
}
kotlinOptions {
jvmTarget = "1.8"
}
testOptions.unitTests.isIncludeAndroidResources = true
val compileSdkVersion: Int by rootProject
val targetSdkVersion: Int by rootProject
val minSdkVersion: Int by rootProject
compileSdk = compileSdkVersion
namespace = "com.google.firebase.ktx"
defaultConfig {
minSdk = minSdkVersion
targetSdk = targetSdkVersion
}
sourceSets {
getByName("main") { java.srcDirs("src/main/kotlin") }
getByName("test") { java.srcDirs("src/test/kotlin") }
}
kotlinOptions { jvmTarget = "1.8" }
testOptions.unitTests.isIncludeAndroidResources = true
}

dependencies {
api(project(":firebase-common"))
implementation("com.google.firebase:firebase-components:18.0.0")
implementation("com.google.firebase:firebase-annotations:16.2.0")
testImplementation(libs.androidx.test.core)
testImplementation(libs.junit)
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.robolectric)
testImplementation(libs.truth)
api(project(":firebase-common"))
implementation("com.google.firebase:firebase-components:18.0.0")
implementation("com.google.firebase:firebase-annotations:16.2.0")
testImplementation(libs.androidx.test.core)
testImplementation(libs.junit)
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.robolectric)
testImplementation(libs.truth)
}
18 changes: 7 additions & 11 deletions firebase-components/firebase-components.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

plugins {
id("firebase-library")
}
plugins { id("firebase-library") }

firebaseLibrary {
publishSources = true
publishJavadoc = false
releaseNotes {
enabled.set(false)
}
publishSources = true
publishJavadoc = false
releaseNotes { enabled.set(false) }
}

android {
val compileSdkVersion : Int by rootProject
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject
val compileSdkVersion: Int by rootProject
val targetSdkVersion: Int by rootProject
val minSdkVersion: Int by rootProject
compileSdk = compileSdkVersion
namespace = "com.google.firebase.components"
defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

plugins {
id("firebase-library")
}
plugins { id("firebase-library") }

group = "com.google.firebase"

Expand All @@ -30,9 +28,9 @@ firebaseLibrary {
}

android {
val compileSdkVersion : Int by rootProject
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject
val compileSdkVersion: Int by rootProject
val targetSdkVersion: Int by rootProject
val minSdkVersion: Int by rootProject
compileSdk = compileSdkVersion
namespace = "com.google.firebase.dynamicloading"
defaultConfig {
Expand Down
Loading

0 comments on commit 3afa1c4

Please sign in to comment.