Files
breeze/droid/app/build.gradle
T

254 lines
9.9 KiB
Groovy

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
def hasGplayFirebaseConfig = file("src/gplay/google-services.json").exists()
if (hasGplayFirebaseConfig) {
apply plugin: 'com.google.gms.google-services'
tasks.configureEach { task ->
if (task.name == "processDebugGoogleServices" || task.name == "processReleaseGoogleServices") {
task.enabled = false
}
}
}
def appOnlyAbi = (project.findProperty('app.onlyAbi') ?: '').toString()
def verificationInstance = (project.findProperty('app.verificationInstance') ?: 'false').toString().toBoolean()
if (verificationInstance && gradle.startParameter.taskNames.any {
def name = it.toLowerCase()
name.contains('release') || name.contains('gplay') || name.contains('bundle')
}) {
throw new GradleException('The verification instance is only available for debug APK checks')
}
def buildingAndroidBundle = gradle.startParameter.taskNames.any { it.toLowerCase().contains("bundle") }
def kryonDirOverride = (project.findProperty('kryon.dir') ?: System.getenv("KRYON_DIR") ?: '').toString()
android {
useLibrary 'android.test.runner', false
useLibrary 'android.test.base', false
namespace 'xyz.waozi.inbe'
compileSdk 36
buildToolsVersion "35.0.0"
ndkVersion "28.2.13676358"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
def keystorePropsFile = rootProject.file("local.properties")
def keystoreProps = new Properties()
if (keystorePropsFile.exists()) {
keystoreProps.load(new FileInputStream(keystorePropsFile))
}
def getKeystorePath = { -> project.findProperty('keystore.path') ?: keystoreProps['keystore.path'] ?: System.getenv("HOME") + "/.android/kryon-release.keystore" }
def getKeystoreAlias = { -> project.findProperty('keystore.alias') ?: keystoreProps['keystore.alias'] ?: "inbe-key" }
def releasePassword = project.findProperty('keystore.password') ?: ""
signingConfigs {
release {
storeFile getKeystorePath() ? file(getKeystorePath()) : null
storePassword releasePassword
keyAlias getKeystoreAlias()
keyPassword releasePassword
}
}
// F-Droid builds without a key and copies the signature from the release's
// F-Droid APK, which CI builds the same way with -PfDroidBuild plus the key.
def releaseSigning = releasePassword ? signingConfigs.release : null
defaultConfig {
applicationId "xyz.waozi.inbe"
minSdk 21
targetSdk 36
testInstrumentationRunner "android.test.InstrumentationTestRunner"
versionCode 180
versionName "2.1.43"
manifestPlaceholders = [
inbeAppLabel: "Inner Breeze",
inbeUsesCleartextTraffic: "false"
]
externalNativeBuild {
cmake {
if (kryonDirOverride) {
arguments "-DKRYON_DIR=${kryonDirOverride}"
}
if (System.getProperty('os.name').toLowerCase().contains('freebsd')) {
arguments '-DANDROID_HOST_TAG=linux-x86_64',
'-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON'
}
}
}
}
buildFeatures {
buildConfig true
}
buildTypes {
release {
signingConfig releaseSigning
ndk.debugSymbolLevel 'FULL'
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "GPLAY", "false"
// Direct APK installs update themselves; F-Droid updates through its store.
buildConfigField "boolean", "SELF_UPDATE", project.hasProperty('fDroidBuild') ? "false" : "true"
buildConfigField "String", "UPDATE_FEED", '"https://github.com/waozixyz/breeze/releases/latest/download/appcast.json"'
}
gplay {
initWith release
signingConfig releaseSigning
matchingFallbacks = ['release']
buildConfigField "boolean", "GPLAY", "true"
buildConfigField "boolean", "SELF_UPDATE", "false"
buildConfigField "String", "UPDATE_FEED", '""'
}
debug {
// Device verification must not replace or restart the owner's debug app.
applicationIdSuffix verificationInstance ? ".verification" : ".debug"
signingConfig signingConfigs.debug
buildConfigField "boolean", "GPLAY", "false"
// Debug builds update only from a test feed: -Papp.updateFeed=URL.
buildConfigField "boolean", "SELF_UPDATE", project.hasProperty('app.updateFeed') ? "true" : "false"
buildConfigField "String", "UPDATE_FEED", '"' + (project.findProperty('app.updateFeed') ?: '') + '"'
manifestPlaceholders.inbeAppLabel = verificationInstance ? "Inner Breeze Verification" : "Inner Breeze Debug"
manifestPlaceholders.inbeUsesCleartextTraffic = "true"
}
}
externalNativeBuild {
cmake {
path 'src/main/cpp/CMakeLists.txt'
}
}
splits {
abi {
enable !buildingAndroidBundle
reset()
if (!buildingAndroidBundle && appOnlyAbi) {
include appOnlyAbi
universalApk false
} else if (!buildingAndroidBundle) {
include 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
universalApk true
}
}
}
dependenciesInfo {
includeInApk = false
}
// App text comes from locales/*.txt; keep library resources (Firebase,
// AndroidX) only in the languages the app itself ships.
androidResources {
localeFilters += ['en', 'cs', 'de', 'es', 'fr', 'in', 'it', 'ja', 'ko',
'pt', 'pt-rBR', 'ru', 'zh', 'zh-rCN', 'zh-rTW']
}
packaging {
jniLibs {
useLegacyPackaging = true
}
resources {
// Protobuf schema sources and Kotlin reflection metadata; the app
// uses neither at runtime.
excludes += ['google/protobuf/*.proto', '**/*.kotlin_builtins']
}
}
}
androidComponents {
beforeVariants(selector().withBuildType("gplay")) { variantBuilder ->
variantBuilder.minSdk = 23
}
}
// Always run, including Java-only incremental builds. CMake independently
// checks the same Ziran laws for direct native builds.
tasks.register('checkBuildLaws') {
doLast {
exec {
workingDir rootProject.file('..')
commandLine 'make', 'build-laws'
}
}
}
tasks.named('preBuild').configure {
dependsOn 'checkBuildLaws'
}
// Architecture-independent app code and artwork belong once in APK assets,
// including direct Gradle/F-Droid builds and incremental asset-only changes.
tasks.register('prepareAppPackage', Exec) {
workingDir rootProject.file('..')
commandLine 'make', 'cells'
}
def sharedAppAssets = layout.buildDirectory.dir('generated/app-assets')
def stageAppPackage = tasks.register('stageAppPackage', Sync) {
dependsOn 'prepareAppPackage'
from(rootProject.file('../build/inbe.zib'))
from(rootProject.file('../build/apps-ui/apps.zib'))
into(sharedAppAssets)
}
// Declare generated sources through their producing task; lint consumers also
// need the explicit dependency below because AGP resolves their paths eagerly.
android.sourceSets.main.assets.srcDir(stageAppPackage)
tasks.configureEach { task ->
// A clean Gradle/F-Droid build must produce the shared packages before
// configuring the native host and staging APK assets.
if (task.name.startsWith('configureCMake') || task.name.startsWith('buildCMake')) {
task.dependsOn('prepareAppPackage')
}
// AGP's lint model resolves srcDirs as plain files, losing builtBy.
if ((task.name.startsWith('merge') && task.name.endsWith('Assets')) ||
task.name.toLowerCase().contains('lint')) {
task.dependsOn(stageAppPackage)
}
if (task.name in ['assembleRelease', 'assembleGplay', 'bundleRelease', 'bundleGplay']) {
task.doLast {
def variant = task.name.endsWith('Gplay') ? 'gplay' : 'release'
def artifacts
if (task.name.startsWith('bundle')) {
artifacts = [layout.buildDirectory.file("outputs/bundle/${variant}/app-${variant}.aab").get().asFile]
} else {
def outputDir = layout.buildDirectory.dir("outputs/apk/${variant}").get().asFile
def metadata = new groovy.json.JsonSlurper().parse(new File(outputDir, 'output-metadata.json'))
artifacts = metadata.elements.collect { new File(outputDir, it.outputFile) }
}
exec {
workingDir rootProject.file('..')
commandLine(['python3', 'scripts/check-package-size.py'] + artifacts*.absolutePath)
}
}
}
}
gradle.taskGraph.whenReady { taskGraph ->
def signedTasks = [":app:assembleRelease", ":app:bundleRelease", ":app:assembleGplay", ":app:bundleGplay"]
if (signedTasks.any { taskGraph.hasTask(it) }
&& !project.findProperty('keystore.password')
&& !project.hasProperty('fDroidBuild')) {
throw new GradleException("Use: make android-release PASSWORD=your-password")
}
}
dependencies {
implementation 'androidx.core:core:1.12.0'
implementation 'androidx.health.connect:connect-client:1.1.0'
implementation 'org.unifiedpush.android:connector:3.3.3-rc1'
// QR code scanning. ZXing core 3.3 keeps Android 5 supported.
implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'
gplayImplementation platform('com.google.firebase:firebase-bom:34.18.0')
gplayImplementation 'com.google.firebase:firebase-messaging'
}