Skip to content

Commit

Permalink
android: Add SigningConfig.fromProperties function
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Jul 25, 2024
1 parent f483e8a commit e75ee7a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ android {
}
```

### Introduce `SigningConfig.fromProperties` (Experimental)

It is common practice to store keystore credentials in `.properties` file.
This extension lets you apply configurations from a property file.

```kotlin
android {
signingConfigs.getByName<SigningConfig>("debug") {
fromProperties(file("cert/debug.properties"))
}
}
```

### :warning: BREAKING CHANGES

- **common:** Deprecate `redmadrobot.jvmTarget` with deprecation level `Error`.
Expand Down
29 changes: 29 additions & 0 deletions infrastructure-android/src/main/kotlin/dsl/Signing.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dsl

import com.android.build.api.dsl.SigningConfig
import org.gradle.api.Incubating
import java.io.File
import java.util.*

/**
* Applies signature configuration from the specified [propertiesFile].
*
* The file content should have the following format:
* ```
* store_file=[relative path to keystore file]
* store_password=[keystore password]
* key_alias=[the alias of the needed key]
* key_password=[the password for the specified alias]
* ```
*/
@Incubating
public fun SigningConfig.fromProperties(propertiesFile: File) {
val directory = propertiesFile.parentFile
val properties = Properties()
propertiesFile.inputStream().use(properties::load)

storeFile = File(directory, properties.getProperty("store_file"))
storePassword = properties.getProperty("store_password")
keyAlias = properties.getProperty("key_alias")
keyPassword = properties.getProperty("key_password")
}

0 comments on commit e75ee7a

Please sign in to comment.