Skip to content

Commit e3dd809

Browse files
authored
Cleanup root build files (#6606)
Per [b/384956859](https://b.corp.google.com/issues/384956859), This migrates all of our root build files to `kts`. It also refactors our usages to be more inline with modern gradle practices. Furthermore, this PR also fixes the following: - [b/384956861](https://b.corp.google.com/issues/384956861) -> Provide fallback for build script names
1 parent 3dd8ddf commit e3dd809

10 files changed

+185
-192
lines changed

build.gradle

-93
This file was deleted.

build.gradle.kts

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.diffplug.gradle.spotless.SpotlessPlugin
18+
import java.util.regex.Pattern
19+
20+
plugins {
21+
alias(libs.plugins.spotless)
22+
alias(libs.plugins.protobuf) apply false
23+
alias(libs.plugins.errorprone)
24+
alias(libs.plugins.crashlytics) apply false
25+
id("PublishingPlugin")
26+
id("firebase-ci")
27+
id("smoke-tests")
28+
alias(libs.plugins.google.services)
29+
}
30+
31+
extra["targetSdkVersion"] = 34
32+
33+
extra["compileSdkVersion"] = 34
34+
35+
extra["minSdkVersion"] = 21
36+
37+
firebaseContinuousIntegration {
38+
ignorePaths =
39+
listOf(
40+
Pattern.compile(".*\\.gitignore$"),
41+
Pattern.compile(".*\\/.*.md$"),
42+
Pattern.compile(".*\\.gitignore$"),
43+
)
44+
}
45+
46+
fun Project.applySpotless() {
47+
apply<SpotlessPlugin>()
48+
spotless {
49+
java {
50+
target("src/**/*.java")
51+
targetExclude("**/test/resources/**")
52+
googleJavaFormat("1.22.0").reorderImports(true).skipJavadocFormatting()
53+
}
54+
kotlin {
55+
target("src/**/*.kt")
56+
ktfmt("0.41").googleStyle()
57+
}
58+
kotlinGradle {
59+
target("*.gradle.kts") // default target for kotlinGradle
60+
ktfmt("0.41").googleStyle()
61+
}
62+
}
63+
}
64+
65+
applySpotless()
66+
67+
configure(subprojects) { applySpotless() }
68+
69+
tasks.named("clean") { delete(rootProject.layout.buildDirectory) }
70+
71+
apply(from = "gradle/errorProne.gradle")

buildSrc/build.gradle.kts

+7-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ gradlePlugin {
7474
id = "LicenseResolverPlugin"
7575
implementationClass = "com.google.firebase.gradle.plugins.license.LicenseResolverPlugin"
7676
}
77-
register("multiProjectReleasePlugin") {
78-
id = "MultiProjectReleasePlugin"
79-
implementationClass = "com.google.firebase.gradle.MultiProjectReleasePlugin"
77+
register("continuousIntegrationPlugin") {
78+
id = "firebase-ci"
79+
implementationClass = "com.google.firebase.gradle.plugins.ci.ContinuousIntegrationPlugin"
80+
}
81+
register("smokeTestsPlugin") {
82+
id = "smoke-tests"
83+
implementationClass = "com.google.firebase.gradle.plugins.ci.SmokeTestsPlugin"
8084
}
8185
register("publishingPlugin") {
8286
id = "PublishingPlugin"

gradle/libs.versions.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,9 @@ findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version = "3.0.2
114114
firebase-appdistribution-gradle = { module = "com.google.firebase:firebase-appdistribution-gradle", version.ref = "firebaseAppdistributionGradle" }
115115
firebase-common = { module = "com.google.firebase:firebase-common", version.ref = "firebaseCommon" }
116116
firebase-components = { module = "com.google.firebase:firebase-components", version.ref = "firebaseComponents" }
117-
firebase-crashlytics-gradle = { module = "com.google.firebase:firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsGradle" }
118117
glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
119118
google-api-client = { module = "com.google.api-client:google-api-client", version.ref = "googleApiClient" }
120119
google-dexmaker = { module = "com.google.dexmaker:dexmaker", version.ref = "dexmakerVersion" }
121-
google-services = { module = "com.google.gms:google-services", version.ref = "googleServices" }
122-
gradle-errorprone-plugin = { module = "net.ltgt.gradle:gradle-errorprone-plugin", version.ref = "gradleErrorpronePlugin" }
123120
grpc-android = { module = "io.grpc:grpc-android", version.ref = "grpc" }
124121
grpc-kotlin-stub = { module = "io.grpc:grpc-kotlin-stub", version.ref = "grpcKotlin" }
125122
grpc-okhttp = { module = "io.grpc:grpc-okhttp", version.ref = "grpc" }
@@ -173,7 +170,6 @@ playservices-base = { module = "com.google.android.gms:play-services-base", vers
173170
playservices-basement = { module = "com.google.android.gms:play-services-basement", version = "18.3.0" }
174171
playservices-tasks = { module = "com.google.android.gms:play-services-tasks", version = "18.1.0" }
175172
proto-google-common-protos = { module = "com.google.api.grpc:proto-google-common-protos", version.ref = "protoGoogleCommonProtos" }
176-
protobuf-gradle-plugin = { module = "com.google.protobuf:protobuf-gradle-plugin", version.ref = "protobufGradlePlugin" }
177173
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "javalite" }
178174
protobuf-java-lite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "javalite" }
179175
protobuf-kotlin-lite = { module = "com.google.protobuf:protobuf-kotlin-lite", version.ref = "javalite" }
@@ -235,3 +231,7 @@ maven-resolver = [
235231
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
236232
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization-plugin" }
237233
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
234+
protobuf = { id = "com.google.protobuf", version.ref = "protobufGradlePlugin" }
235+
errorprone = { id = "net.ltgt.errorprone", version.ref = "gradleErrorpronePlugin" }
236+
google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
237+
crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" }

gradle/projectSettings.gradle

-41
This file was deleted.

health-metrics/apk-size/apk-size.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ plugins {
2828
id "com.dorongold.task-tree" version "3.0.0"
2929
}
3030

31-
apply from: '../../sdkProperties.gradle'
32-
3331
task clean(type: Delete) {
3432
delete rootProject.buildDir
3533
}

health-metrics/apk-size/app/default.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ android {
2929

3030
defaultConfig {
3131
applicationId 'com.google.apksize'
32-
minSdkVersion project.targetSdkVersion
32+
minSdkVersion 34
3333
multiDexEnabled true
3434
targetSdkVersion 33
3535
versionCode 1

sdkProperties.gradle

-19
This file was deleted.

settings.gradle

-29
This file was deleted.

0 commit comments

Comments
 (0)