Skip to content

Commit 8f07a3b

Browse files
author
David Motsonashvili
committed
refactored to explicitly do nothing in cases where a google-service file is already present in the directory
1 parent 5295a5a commit 8f07a3b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/src/main/java/com/google/firebase/gradle/plugins/CopyGoogleServicesPlugin.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ import org.gradle.kotlin.dsl.register
3838
abstract class CopyGoogleServicesPlugin : Plugin<Project> {
3939
override fun apply(project: Project) {
4040
val sourcePath = getSourcePath(project)
41+
if (sourcePath == null) {
42+
project.logger.warn("Google Services file already present in project, skipping copy task")
43+
return
44+
}
45+
4146
val copyRootGoogleServices = registerCopyRootGoogleServicesTask(project, sourcePath)
4247

4348
project.allprojects {
@@ -94,10 +99,13 @@ abstract class CopyGoogleServicesPlugin : Plugin<Project> {
9499
return !file.readText().contains(targetPackageLine)
95100
}
96101

97-
private fun getSourcePath(project: Project): String {
102+
private fun getSourcePath(project: Project): String? {
98103
val path =
99104
System.getenv("FIREBASE_GOOGLE_SERVICES_PATH") ?: "${project.rootDir}/google-services.json"
100-
if (File(project.projectDir, "google-services.json").exists() || File(path).exists()) {
105+
if (File(project.projectDir, "google-services.json").exists()) {
106+
return null
107+
}
108+
if (File(path).exists()) {
101109
return path
102110
}
103111
project.logger.warn("Google services file not found, using fallback")

0 commit comments

Comments
 (0)