Skip to content

Commit 9983dec

Browse files
author
David Motsonashvili
committed
refactor out the if
1 parent 8f07a3b commit 9983dec

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ import org.gradle.kotlin.dsl.register
3737
*/
3838
abstract class CopyGoogleServicesPlugin : Plugin<Project> {
3939
override fun apply(project: Project) {
40-
val sourcePath = getSourcePath(project)
41-
if (sourcePath == null) {
40+
if (File(project.projectDir, "google-services.json").exists()) {
4241
project.logger.warn("Google Services file already present in project, skipping copy task")
4342
return
4443
}
4544

45+
val sourcePath = getSourcePath(project)
4646
val copyRootGoogleServices = registerCopyRootGoogleServicesTask(project, sourcePath)
4747

4848
project.allprojects {
@@ -99,12 +99,9 @@ abstract class CopyGoogleServicesPlugin : Plugin<Project> {
9999
return !file.readText().contains(targetPackageLine)
100100
}
101101

102-
private fun getSourcePath(project: Project): String? {
102+
private fun getSourcePath(project: Project): String {
103103
val path =
104104
System.getenv("FIREBASE_GOOGLE_SERVICES_PATH") ?: "${project.rootDir}/google-services.json"
105-
if (File(project.projectDir, "google-services.json").exists()) {
106-
return null
107-
}
108105
if (File(path).exists()) {
109106
return path
110107
}

0 commit comments

Comments
 (0)