Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Provider to provide signing config information at runtime #11

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import dev.shreyaspatil.bytemask.plugin.util.capitalized
import java.io.File
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.provider.Provider

/** Bytemask Gradle Plugin. Applies on Android projects. Entry point of the plugin. */
class BytemaskPlugin : Plugin<Project> {
Expand Down Expand Up @@ -117,15 +118,27 @@ class BytemaskPlugin : Plugin<Project> {
)
}

private fun <T> getEncryptionKey(keySource: KeySource?, project: Project, variant: T) where
T : Variant =
when (keySource) {
is KeySource.SigningConfig -> {
getAppSigningKeyForVariant(project, keySource, variant)
private fun <T> getEncryptionKey(
keySource: KeySource?,
project: Project,
variant: T
): Provider<Sha256DigestableKey?> where T : Variant =
project.provider {
when (keySource) {
is KeySource.SigningConfig ->
getAppSigningKeyForVariant(
project = project,
keySource = keySource,
variant = variant
)
is KeySource.Key -> Sha256DigestableKey(value = keySource.encryptionKey)
null ->
getAppSigningKeyForVariant(
project = project,
keySource = KeySource.SigningConfig(variant.name),
variant = variant
)
}
is KeySource.Key -> Sha256DigestableKey(keySource.encryptionKey)
else ->
getAppSigningKeyForVariant(project, KeySource.SigningConfig(variant.name), variant)
}

/** Returns the signing key for the variant. It will be used as an encryption key. */
Expand Down
Loading