Skip to content

Commit

Permalink
feat: Add support for build-variant properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
arriolac committed Feb 17, 2021
1 parent 4adfc22 commit b85ff47
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ secrets {
}
```

### Build-Variant Specific Properties

To set build-variant specific properties (build type or flavor), create a properties file at the
root directory of the project with the same name as the variant. For example, to set keys specific
for the `release` build type, create a new file called `release.properties` containing
release-specific keys.

## Contributing

Contributions to this library are always welcome and highly encouraged!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ class SecretsPlugin : Plugin<Project> {
properties?.let {
variant.inject(properties, extension.ignoreList)
}

// Inject build-type specific properties
val buildTypeFileName = "${variant.buildType.name}.properties"
val buildTypeProperties = try {
project.rootProject.loadPropertiesFile(buildTypeFileName)
} catch (e: FileNotFoundException) {
println("Could not find $buildTypeFileName")
null
}
buildTypeProperties?.let {
variant.inject(it, extension.ignoreList)
}

// Inject flavor-specific properties
val flavorFileName = "${variant.flavorName}.properties"
val flavorProperties = try {
project.rootProject.loadPropertiesFile(flavorFileName)
} catch (e: FileNotFoundException) {
println("Could not find $flavorFileName")
null
}
flavorProperties?.let {
variant.inject(it, extension.ignoreList)
}
}
}
}
Expand Down

0 comments on commit b85ff47

Please sign in to comment.