fix versioning (#280)
This commit is contained in:
parent
66e89c83e2
commit
45e63e9910
|
@ -20,8 +20,8 @@ android {
|
|||
applicationId = Constants.APP_ID
|
||||
minSdk = Constants.MIN_SDK
|
||||
targetSdk = Constants.TARGET_SDK
|
||||
versionCode = Constants.VERSION_CODE
|
||||
versionName = Constants.VERSION_NAME
|
||||
versionCode = determineVersionCode()
|
||||
versionName = determineVersionName()
|
||||
|
||||
ksp { arg("room.schemaLocation", "$projectDir/schemas") }
|
||||
|
||||
|
@ -56,14 +56,12 @@ android {
|
|||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
signingConfig = signingConfigs.getByName(Constants.RELEASE)
|
||||
signingConfig = signingConfigs.getByName(Constants.DEBUG)
|
||||
}
|
||||
debug { isDebuggable = true }
|
||||
|
||||
create(Constants.NIGHTLY) {
|
||||
initWith(buildTypes.getByName(Constants.RELEASE))
|
||||
defaultConfig.versionName = nightlyVersionName()
|
||||
defaultConfig.versionCode = nightlyVersionCode()
|
||||
}
|
||||
|
||||
applicationVariants.all {
|
||||
|
@ -185,10 +183,10 @@ dependencies {
|
|||
implementation(libs.androidx.core.splashscreen)
|
||||
}
|
||||
|
||||
fun nightlyVersionCode(): Int {
|
||||
return Constants.VERSION_CODE + Constants.NIGHTLY_CODE
|
||||
fun determineVersionCode(): Int {
|
||||
return if(isNightlyBuild()) Constants.VERSION_CODE + Constants.NIGHTLY_CODE else Constants.VERSION_CODE
|
||||
}
|
||||
|
||||
fun nightlyVersionName(): String {
|
||||
return Constants.VERSION_NAME + "-${grgitService.service.get().grgit.head().abbreviatedId}"
|
||||
fun determineVersionName(): String {
|
||||
return if(isNightlyBuild()) Constants.VERSION_NAME + "-${grgitService.service.get().grgit.head().abbreviatedId}" else Constants.VERSION_NAME
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ import org.gradle.api.invocation.Gradle
|
|||
import java.io.File
|
||||
import java.util.Properties
|
||||
|
||||
private fun getCurrentFlavor(gradle: Gradle): String {
|
||||
fun Project.getCurrentFlavor(): String {
|
||||
val taskRequestsStr = gradle.startParameter.taskRequests.toString()
|
||||
val pattern: java.util.regex.Pattern =
|
||||
if (taskRequestsStr.contains("assemble")) {
|
||||
java.util.regex.Pattern.compile("assemble(\\w+)(Release|Debug)")
|
||||
if (taskRequestsStr.contains(":app:assemble")) {
|
||||
java.util.regex.Pattern.compile(":app:assemble(\\w+)(Release|Debug)")
|
||||
} else {
|
||||
java.util.regex.Pattern.compile("bundle(\\w+)(Release|Debug)")
|
||||
java.util.regex.Pattern.compile(":app:bundle(\\w+)(Release|Debug)")
|
||||
}
|
||||
|
||||
val matcher = pattern.matcher(taskRequestsStr)
|
||||
|
@ -23,8 +23,15 @@ private fun getCurrentFlavor(gradle: Gradle): String {
|
|||
return flavor
|
||||
}
|
||||
|
||||
fun Project.isNightlyBuild(): Boolean {
|
||||
val taskRequestsStr = gradle.startParameter.taskRequests[0].toString()
|
||||
return taskRequestsStr.lowercase().contains(Constants.NIGHTLY).also {
|
||||
project.logger.lifecycle("Nightly build: $it")
|
||||
}
|
||||
}
|
||||
|
||||
fun getLocalProperty(key: String, file: String = "local.properties"): String? {
|
||||
val properties = java.util.Properties()
|
||||
val properties = Properties()
|
||||
val localProperties = File(file)
|
||||
if (localProperties.isFile) {
|
||||
java.io.InputStreamReader(java.io.FileInputStream(localProperties), Charsets.UTF_8)
|
||||
|
@ -35,10 +42,6 @@ fun getLocalProperty(key: String, file: String = "local.properties"): String? {
|
|||
return properties.getProperty(key)
|
||||
}
|
||||
|
||||
fun Project.isGeneralFlavor(gradle: Gradle): Boolean {
|
||||
return getCurrentFlavor(gradle) == "general"
|
||||
}
|
||||
|
||||
|
||||
fun Project.getSigningProperties(): Properties {
|
||||
return Properties().apply {
|
||||
|
|
|
@ -23,8 +23,8 @@ android {
|
|||
)
|
||||
}
|
||||
|
||||
create("nightly") {
|
||||
initWith(getByName("release"))
|
||||
create(Constants.NIGHTLY) {
|
||||
initWith(getByName(Constants.RELEASE))
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
|
|
Loading…
Reference in New Issue