Skip to content

Commit

Permalink
Cleanup root build files (#6606)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
daymxn authored Dec 18, 2024
1 parent 3dd8ddf commit e3dd809
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 192 deletions.
93 changes: 0 additions & 93 deletions build.gradle

This file was deleted.

71 changes: 71 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import com.diffplug.gradle.spotless.SpotlessPlugin
import java.util.regex.Pattern

plugins {
alias(libs.plugins.spotless)
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.errorprone)
alias(libs.plugins.crashlytics) apply false
id("PublishingPlugin")
id("firebase-ci")
id("smoke-tests")
alias(libs.plugins.google.services)
}

extra["targetSdkVersion"] = 34

extra["compileSdkVersion"] = 34

extra["minSdkVersion"] = 21

firebaseContinuousIntegration {
ignorePaths =
listOf(
Pattern.compile(".*\\.gitignore$"),
Pattern.compile(".*\\/.*.md$"),
Pattern.compile(".*\\.gitignore$"),
)
}

fun Project.applySpotless() {
apply<SpotlessPlugin>()
spotless {
java {
target("src/**/*.java")
targetExclude("**/test/resources/**")
googleJavaFormat("1.22.0").reorderImports(true).skipJavadocFormatting()
}
kotlin {
target("src/**/*.kt")
ktfmt("0.41").googleStyle()
}
kotlinGradle {
target("*.gradle.kts") // default target for kotlinGradle
ktfmt("0.41").googleStyle()
}
}
}

applySpotless()

configure(subprojects) { applySpotless() }

tasks.named("clean") { delete(rootProject.layout.buildDirectory) }

apply(from = "gradle/errorProne.gradle")
10 changes: 7 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ gradlePlugin {
id = "LicenseResolverPlugin"
implementationClass = "com.google.firebase.gradle.plugins.license.LicenseResolverPlugin"
}
register("multiProjectReleasePlugin") {
id = "MultiProjectReleasePlugin"
implementationClass = "com.google.firebase.gradle.MultiProjectReleasePlugin"
register("continuousIntegrationPlugin") {
id = "firebase-ci"
implementationClass = "com.google.firebase.gradle.plugins.ci.ContinuousIntegrationPlugin"
}
register("smokeTestsPlugin") {
id = "smoke-tests"
implementationClass = "com.google.firebase.gradle.plugins.ci.SmokeTestsPlugin"
}
register("publishingPlugin") {
id = "PublishingPlugin"
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,9 @@ findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version = "3.0.2
firebase-appdistribution-gradle = { module = "com.google.firebase:firebase-appdistribution-gradle", version.ref = "firebaseAppdistributionGradle" }
firebase-common = { module = "com.google.firebase:firebase-common", version.ref = "firebaseCommon" }
firebase-components = { module = "com.google.firebase:firebase-components", version.ref = "firebaseComponents" }
firebase-crashlytics-gradle = { module = "com.google.firebase:firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsGradle" }
glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
google-api-client = { module = "com.google.api-client:google-api-client", version.ref = "googleApiClient" }
google-dexmaker = { module = "com.google.dexmaker:dexmaker", version.ref = "dexmakerVersion" }
google-services = { module = "com.google.gms:google-services", version.ref = "googleServices" }
gradle-errorprone-plugin = { module = "net.ltgt.gradle:gradle-errorprone-plugin", version.ref = "gradleErrorpronePlugin" }
grpc-android = { module = "io.grpc:grpc-android", version.ref = "grpc" }
grpc-kotlin-stub = { module = "io.grpc:grpc-kotlin-stub", version.ref = "grpcKotlin" }
grpc-okhttp = { module = "io.grpc:grpc-okhttp", version.ref = "grpc" }
Expand Down Expand Up @@ -173,7 +170,6 @@ playservices-base = { module = "com.google.android.gms:play-services-base", vers
playservices-basement = { module = "com.google.android.gms:play-services-basement", version = "18.3.0" }
playservices-tasks = { module = "com.google.android.gms:play-services-tasks", version = "18.1.0" }
proto-google-common-protos = { module = "com.google.api.grpc:proto-google-common-protos", version.ref = "protoGoogleCommonProtos" }
protobuf-gradle-plugin = { module = "com.google.protobuf:protobuf-gradle-plugin", version.ref = "protobufGradlePlugin" }
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "javalite" }
protobuf-java-lite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "javalite" }
protobuf-kotlin-lite = { module = "com.google.protobuf:protobuf-kotlin-lite", version.ref = "javalite" }
Expand Down Expand Up @@ -235,3 +231,7 @@ maven-resolver = [
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization-plugin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufGradlePlugin" }
errorprone = { id = "net.ltgt.errorprone", version.ref = "gradleErrorpronePlugin" }
google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" }
41 changes: 0 additions & 41 deletions gradle/projectSettings.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions health-metrics/apk-size/apk-size.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ plugins {
id "com.dorongold.task-tree" version "3.0.0"
}

apply from: '../../sdkProperties.gradle'

task clean(type: Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion health-metrics/apk-size/app/default.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {

defaultConfig {
applicationId 'com.google.apksize'
minSdkVersion project.targetSdkVersion
minSdkVersion 34
multiDexEnabled true
targetSdkVersion 33
versionCode 1
Expand Down
19 changes: 0 additions & 19 deletions sdkProperties.gradle

This file was deleted.

29 changes: 0 additions & 29 deletions settings.gradle

This file was deleted.

Loading

0 comments on commit e3dd809

Please sign in to comment.