Skip to content

Commit

Permalink
Add releaseAlternative build variant for non Google releases
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Jul 8, 2023
1 parent 055ebeb commit 81997ef
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,25 @@ android {

signingConfigs {
val properties = configProperties
val certificateFile = properties?.getProperty("playStore.storeFile")
if (properties != null && certificateFile != null) {
val playStoreCertificateFile = properties?.getProperty("playStore.storeFile")
if (properties != null && playStoreCertificateFile != null) {
signingConfigs.create("playStore") {
storeFile(File(certificateFile))
storeFile(File(playStoreCertificateFile))
storePassword(properties.getProperty("playStore.storePassword"))
keyAlias(properties.getProperty("playStore.keyAlias"))
keyPassword(properties.getProperty("playStore.keyPassword"))
}
}

val alternativeCertificateFile = properties?.getProperty("alternative.storeFile")
if (properties != null && alternativeCertificateFile != null) {
signingConfigs.create("alternative") {
storeFile(File(alternativeCertificateFile))
storePassword(properties.getProperty("alternative.storePassword"))
keyAlias(properties.getProperty("alternative.keyAlias"))
keyPassword(properties.getProperty("alternative.keyPassword"))
}
}
}

buildTypes {
Expand All @@ -67,10 +77,18 @@ android {

create("releasePlayStore") {
initWith(getByName("release"))

signingConfig = try {
signingConfigs.getByName("playStore")
} catch (e: UnknownDomainObjectException) {
} catch (error: UnknownDomainObjectException) {
signingConfigs.getByName("debug")
}
}

create("releaseAlternative") {
initWith(getByName("release"))
signingConfig = try {
signingConfigs.getByName("alternative")
} catch (error: UnknownDomainObjectException) {
signingConfigs.getByName("debug")
}
}
Expand All @@ -81,6 +99,11 @@ android {
java.srcDirs("src/release/kotlin")
res.srcDirs("src/release/res")
}

named("releaseAlternative") {
java.srcDirs("src/release/kotlin")
res.srcDirs("src/release/res")
}
}

buildFeatures {
Expand Down

0 comments on commit 81997ef

Please sign in to comment.