Skip to content

Commit

Permalink
feat: Don't throw if defaults provided. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
arriolac authored Jan 27, 2021
1 parent 63d31bc commit 123714b
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package com.google.secrets_gradle_plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import java.io.FileNotFoundException
import java.util.Properties

/**
* Plugin that reads secrets from a properties file and injects manifest build and BuildConfig
Expand All @@ -38,16 +40,24 @@ class SecretsPlugin : Plugin<Project> {
val defaultProperties = extension.defaultPropertiesFileName?.let {
project.rootProject.loadPropertiesFile(it)
}
val properties = project.rootProject.loadPropertiesFile(
extension.propertiesFileName
)

val properties: Properties? = try {
project.rootProject.loadPropertiesFile(
extension.propertiesFileName
)
} catch (e: FileNotFoundException) {
defaultProperties ?: throw e
}

project.androidProject()?.applicationVariants?.all { variant ->
// Inject defaults first
defaultProperties?.let {
variant.inject(it, extension.ignoreList)
}

variant.inject(properties, extension.ignoreList)
properties?.let {
variant.inject(properties, extension.ignoreList)
}
}
}
}
Expand Down

0 comments on commit 123714b

Please sign in to comment.