Move build parameters to a common file

This commit is contained in:
Benoit Marty 2025-02-19 17:10:30 +01:00 committed by Benoit Marty
parent 86d9abfef7
commit c9890d3073
3 changed files with 23 additions and 25 deletions

View file

@ -10,6 +10,7 @@
import com.android.build.api.variant.FilterConfiguration.FilterType.ABI import com.android.build.api.variant.FilterConfiguration.FilterType.ABI
import com.android.build.gradle.internal.tasks.factory.dependsOn import com.android.build.gradle.internal.tasks.factory.dependsOn
import com.android.build.gradle.tasks.GenerateBuildConfig import com.android.build.gradle.tasks.GenerateBuildConfig
import config.BuildTimeConfig
import extension.AssetCopyTask import extension.AssetCopyTask
import extension.ComponentMergingStrategy import extension.ComponentMergingStrategy
import extension.GitBranchNameValueSource import extension.GitBranchNameValueSource
@ -43,11 +44,7 @@ android {
namespace = "io.element.android.x" namespace = "io.element.android.x"
defaultConfig { defaultConfig {
applicationId = if (isEnterpriseBuild) { applicationId = BuildTimeConfig.APPLICATION_ID
"io.element.enterprise"
} else {
"io.element.android.x"
}
targetSdk = Versions.TARGET_SDK targetSdk = Versions.TARGET_SDK
versionCode = Versions.VERSION_CODE versionCode = Versions.VERSION_CODE
versionName = Versions.VERSION_NAME versionName = Versions.VERSION_NAME
@ -97,11 +94,7 @@ android {
} }
} }
val baseAppName = if (isEnterpriseBuild) { val baseAppName = BuildTimeConfig.APPLICATION_NAME
"Element Enterprise"
} else {
"Element X"
}
logger.warnInBox("Building $baseAppName") logger.warnInBox("Building $baseAppName")
buildTypes { buildTypes {

View file

@ -7,6 +7,7 @@
@file:Suppress("UnstableApiUsage") @file:Suppress("UnstableApiUsage")
import config.BuildTimeConfig
import extension.setupAnvil import extension.setupAnvil
plugins { plugins {
@ -22,22 +23,14 @@ android {
resValue( resValue(
type = "string", type = "string",
name = "google_app_id", name = "google_app_id",
value = if (isEnterpriseBuild) { value = BuildTimeConfig.GOOGLE_APP_ID_RELEASE,
"1:912726360885:android:d273c2077ec3291500427c"
} else {
"1:912726360885:android:d097de99a4c23d2700427c"
}
) )
} }
getByName("debug") { getByName("debug") {
resValue( resValue(
type = "string", type = "string",
name = "google_app_id", name = "google_app_id",
value = if (isEnterpriseBuild) { value = BuildTimeConfig.GOOGLE_APP_ID_DEBUG,
"1:912726360885:android:f8de9126a94143d300427c"
} else {
"1:912726360885:android:def0a4e454042e9b00427c"
}
) )
} }
register("nightly") { register("nightly") {
@ -46,11 +39,7 @@ android {
resValue( resValue(
type = "string", type = "string",
name = "google_app_id", name = "google_app_id",
value = if (isEnterpriseBuild) { value = BuildTimeConfig.GOOGLE_APP_ID_NIGHTLY,
"1:912726360885:android:3f7e1fe644d99d5a00427c"
} else {
"1:912726360885:android:e17435e0beb0303000427c"
}
) )
} }
} }

View file

@ -0,0 +1,16 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package config
object BuildTimeConfig {
const val APPLICATION_ID = "io.element.android.x"
const val APPLICATION_NAME = "Element X"
const val GOOGLE_APP_ID_RELEASE = "1:912726360885:android:d097de99a4c23d2700427c"
const val GOOGLE_APP_ID_DEBUG = "1:912726360885:android:def0a4e454042e9b00427c"
const val GOOGLE_APP_ID_NIGHTLY = "1:912726360885:android:e17435e0beb0303000427c"
}