diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4ed7c8d..215ea3d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -21,8 +21,8 @@ android { applicationId = Constants.APP_ID minSdk = Constants.MIN_SDK targetSdk = Constants.TARGET_SDK - versionCode = versionCode() - versionName = versionName() + versionCode = Constants.VERSION_CODE + versionName = Constants.VERSION_NAME ksp { arg("room.schemaLocation", "$projectDir/schemas") } @@ -67,12 +67,14 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) - signingConfig = signingConfigs.getByName(signingConfigName()) + signingConfig = signingConfigs.getByName(Constants.RELEASE) } debug { isDebuggable = true } - create("nightly") { + create(Constants.NIGHTLY) { initWith(getByName("release")) + defaultConfig.versionName = nightlyVersionName() + defaultConfig.versionCode = nightlyVersionCode() } } flavorDimensions.add(Constants.TYPE) @@ -183,10 +185,10 @@ dependencies { implementation(libs.androidx.core.splashscreen) } -fun versionCode() : Int { - return if(!isNightlyBuild()) Constants.VERSION_CODE else Constants.VERSION_CODE + Constants.NIGHTLY_CODE +fun nightlyVersionCode() : Int { + return Constants.VERSION_CODE + Constants.NIGHTLY_CODE } -fun versionName() : String { - return if(!isNightlyBuild()) Constants.VERSION_NAME else Constants.VERSION_NAME + "-${grgitService.service.get().grgit.head().abbreviatedId}" +fun nightlyVersionName() : String { + return Constants.VERSION_NAME + "-${grgitService.service.get().grgit.head().abbreviatedId}" } diff --git a/buildSrc/src/main/kotlin/Constants.kt b/buildSrc/src/main/kotlin/Constants.kt index 9555fea..2c3b2b0 100644 --- a/buildSrc/src/main/kotlin/Constants.kt +++ b/buildSrc/src/main/kotlin/Constants.kt @@ -13,6 +13,7 @@ object Constants { const val KEY_STORE_PATH_VAR = "KEY_STORE_PATH" const val RELEASE = "release" + const val NIGHTLY = "nightly" const val DEBUG = "debug" const val TYPE = "type" diff --git a/buildSrc/src/main/kotlin/Extensions.kt b/buildSrc/src/main/kotlin/Extensions.kt index 7eb5a5d..5f92fc2 100644 --- a/buildSrc/src/main/kotlin/Extensions.kt +++ b/buildSrc/src/main/kotlin/Extensions.kt @@ -39,16 +39,6 @@ fun Project.isGeneralFlavor(gradle: Gradle): Boolean { return getCurrentFlavor(gradle) == "general" } -fun Project.isReleaseBuild(): Boolean { - return (gradle.startParameter.taskNames.size > 0 && - gradle.startParameter.taskNames[0].contains( - "Release", - )) -} - -fun Project.isNightlyBuild(): Boolean { - return gradle.startParameter.taskNames.contains("Nightly") -} fun Project.getSigningProperties() : Properties { return Properties().apply { @@ -80,10 +70,6 @@ fun Project.getSigningProperty(property: String) : String { ) } -fun Project.signingConfigName() : String { - return if(getSigningProperty(Constants.KEY_PASS_VAR).isBlank()) Constants.DEBUG else Constants.RELEASE -} -