Prepare Android release and refine bookshelf
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
import java.util.Base64
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
val uploadProperties = Properties()
|
||||
val uploadPropertiesPath = providers.gradleProperty("LUMEN_UPLOAD_PROPERTIES")
|
||||
.orElse(providers.environmentVariable("LUMEN_UPLOAD_PROPERTIES"))
|
||||
.orNull
|
||||
if (uploadPropertiesPath != null) {
|
||||
val propertiesFile = file(uploadPropertiesPath)
|
||||
require(propertiesFile.isFile) { "Upload signing properties file does not exist." }
|
||||
propertiesFile.inputStream().use { uploadProperties.load(it) }
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.lumen.daily"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
@@ -15,8 +28,7 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId = "com.lumen.daily"
|
||||
applicationId = "de.softwareapp_hb.lumen.daily"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
minSdk = 24
|
||||
@@ -30,19 +42,25 @@ android {
|
||||
manifestPlaceholders["admobAppId"] = providers.gradleProperty("ADMOB_APP_ID").getOrElse("ca-app-pub-3940256099942544~3347511713")
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("upload") {
|
||||
uploadProperties.getProperty("storeFile")?.let { storeFile = file(it) }
|
||||
storePassword = uploadProperties.getProperty("storePassword")
|
||||
keyAlias = uploadProperties.getProperty("keyAlias")
|
||||
keyPassword = uploadProperties.getProperty("keyPassword")
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += "edition"
|
||||
productFlavors {
|
||||
create("prod") { dimension = "edition" }
|
||||
create("qa") { dimension = "edition"; applicationIdSuffix = ".qa"; versionNameSuffix = "-qa" }
|
||||
create("check") { dimension = "edition"; applicationIdSuffix = ".check"; versionNameSuffix = "-check" }
|
||||
create("prod") { dimension = "edition"; signingConfig = signingConfigs.getByName("upload") }
|
||||
create("qa") { dimension = "edition"; applicationId = "com.lumen.daily.qa"; versionNameSuffix = "-qa" }
|
||||
create("check") { dimension = "edition"; applicationId = "com.lumen.daily.check"; versionNameSuffix = "-check" }
|
||||
}
|
||||
buildTypes {
|
||||
debug { signingConfig = signingConfigs.getByName("debug") }
|
||||
release {
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
// Supply a private upload key before publishing. Never release with a debug key.
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,3 +74,38 @@ kotlin {
|
||||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
|
||||
// Never produce a production release with sample ad IDs or a debug key.
|
||||
gradle.taskGraph.whenReady {
|
||||
if (allTasks.any { it.project == project && it.name.contains("ProdRelease", ignoreCase = true) }) {
|
||||
val appId = providers.gradleProperty("ADMOB_APP_ID").orNull ?: ""
|
||||
val validAppId = Regex("ca-app-pub-[0-9]{16}~[0-9]{10}")
|
||||
require(validAppId.matches(appId) && !appId.startsWith("ca-app-pub-3940256099942544~")) {
|
||||
"Production release requires a real ADMOB_APP_ID Gradle property."
|
||||
}
|
||||
val defines = providers.gradleProperty("dart-defines").orNull.orEmpty()
|
||||
.split(",").filter { it.isNotBlank() }.mapNotNull {
|
||||
runCatching { String(Base64.getDecoder().decode(it), Charsets.UTF_8) }.getOrNull()
|
||||
}.mapNotNull { value ->
|
||||
val index = value.indexOf('=')
|
||||
if (index < 0) null else value.substring(0, index) to value.substring(index + 1)
|
||||
}.toMap()
|
||||
val validUnitId = Regex("ca-app-pub-[0-9]{16}/[0-9]{10}")
|
||||
for (name in listOf("ADMOB_REWARDED_ID", "ADMOB_INTERSTITIAL_ID")) {
|
||||
val id = defines[name].orEmpty()
|
||||
require(validUnitId.matches(id) && !id.startsWith("ca-app-pub-3940256099942544/")) {
|
||||
"Production release requires a real $name Dart define."
|
||||
}
|
||||
}
|
||||
for (name in listOf("storeFile", "storePassword", "keyAlias", "keyPassword")) {
|
||||
require(!uploadProperties.getProperty(name).isNullOrBlank()) {
|
||||
"Production release requires $name in the upload signing properties file."
|
||||
}
|
||||
}
|
||||
require(file(uploadProperties.getProperty("storeFile")).isFile) {
|
||||
"Production upload keystore does not exist."
|
||||
}
|
||||
// Remove only after the mixed-age flow and its device verification exist.
|
||||
error("Production release blocked: mixed-age screening and Families ad handling are not yet verified.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user