1plugins {2 id "com.android.application"3 id "org.jetbrains.kotlin.android"4 id "org.jetbrains.kotlin.plugin.compose"5 id "org.jetbrains.kotlin.plugin.parcelize"6 id "org.jetbrains.kotlin.plugin.serialization"7 id "kotlin-kapt"8 id "com.google.dagger.hilt.android"9}1011dependencyLocking {12 lockAllConfigurations()13}1415android {16 namespace "com.peachpasswords"17 compileSdk 351819 // VERSION is the single semantic-version authority. versionCode remains20 // Android/Gradle metadata because Kepr's manifest does not carry it; the21 // updater enforces exact VERSION plus a strictly newer code.22 def versionAuthorityFile = rootProject.file("VERSION")23 if (!versionAuthorityFile.isFile()) {24 throw new GradleException("VERSION is missing; it is the semantic-version authority")25 }26 def semanticVersion = versionAuthorityFile.getText("UTF-8").trim()27 if (!(semanticVersion ==~ /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/)) {28 throw new GradleException("VERSION must contain exactly one strict major.minor.patch value")29 }30 def versionParts = semanticVersion.split("\\.")31 def vMajor = versionParts[0].toInteger()32 def vMinor = versionParts[1].toInteger()33 def vPatch = versionParts[2].toInteger()34 if (vMajor > 99 || vMinor > 99 || vPatch > 999) {35 throw new GradleException("VERSION components exceed versionCode encoding range (major/minor <= 99, patch <= 999)")36 }37 // Derive a strictly-monotonic versionCode from semver so it can never38 // accidentally stay flat across releases (which breaks the updater's39 // versionCode > currentVersionCode identity gate).40 def derivedVersionCode = vMajor * 1000000 + vMinor * 10000 + vPatch * 104142 defaultConfig {43 applicationId "com.peachpasswords"44 minSdk 2645 targetSdk 3546 versionCode derivedVersionCode47 versionName semanticVersion4849 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"50 vectorDrawables {51 useSupportLibrary true52 }53 }5455 splits {56 abi {57 enable true58 reset()59 include "arm64-v8a", "x86_64"60 universalApk false61 }62 }6364 signingConfigs {65 release {66 def props = new Properties()67 def localPropertiesFile = rootProject.file("local.properties")68 if (localPropertiesFile.isFile()) {69 localPropertiesFile.withInputStream { props.load(it) }70 }71 def signingProperties = [72 "peachStoreFile", "peachStorePassword", "peachKeyAlias", "peachKeyPassword",73 ]74 def missingSigningProperties = signingProperties.findAll { !props.getProperty(it) }75 if (!missingSigningProperties.empty && gradle.startParameter.taskNames.any { it.toLowerCase().contains("release") }) {76 throw new GradleException("Missing release signing inputs: ${missingSigningProperties.join(", ")}")77 }78 if (props.getProperty("peachStoreFile")) {79 storeFile file(props.getProperty("peachStoreFile"))80 storePassword props.getProperty("peachStorePassword")81 keyAlias props.getProperty("peachKeyAlias")82 keyPassword props.getProperty("peachKeyPassword")83 }84 enableV2Signing true85 enableV3Signing true86 }87 }8889 buildTypes {90 debug {91 applicationIdSuffix ".debug"92 versionNameSuffix "-debug"93 debuggable true94 }95 release {96 minifyEnabled true97 shrinkResources true98 proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"99 signingConfig signingConfigs.release100 }101 }102103 // Kepr Beta APKs use the established certificate so installed users can update.104105 compileOptions {106 sourceCompatibility JavaVersion.VERSION_17107 targetCompatibility JavaVersion.VERSION_17108 }109110 kotlinOptions {111 jvmTarget = "17"112 }113114 buildFeatures {115 compose true116 buildConfig true117 }118119 composeOptions {120 kotlinCompilerExtensionVersion "1.5.15"121 }122123 packaging {124 resources {125 excludes += [126 "/META-INF/{AL2.0,LGPL2.1}",127 "META-INF/DEPENDENCIES",128 "META-INF/LICENSE*",129 "META-INF/NOTICE*",130 ]131 }132 }133134 testOptions {135 unitTests.returnDefaultValues = true136 unitTests.all {137 def coreDir = rootProject.file("../peach-browser/crypto-core")138 def nativeLibrary = new File(139 coreDir,140 "target/release/libpeach_noise_core.dylib",141 )142 if (coreDir.exists()) {143 dependsOn rootProject.tasks.named(name.contains("Test") ? "buildRustNoiseHostTest" : "buildRustNoiseHost")144 systemProperty "java.library.path", nativeLibrary.parentFile.absolutePath145 }146 }147 }148}149150dependencies {151 implementation platform("androidx.compose:compose-bom:2024.06.00")152 androidTestImplementation platform("androidx.compose:compose-bom:2024.06.00")153154 implementation "androidx.activity:activity-compose:1.9.2"155 implementation "androidx.autofill:autofill:1.1.0"156 implementation "androidx.biometric:biometric:1.1.0"157 implementation "androidx.core:core-splashscreen:1.0.1"158 implementation "androidx.appcompat:appcompat:1.7.0"159 implementation "androidx.credentials:credentials:1.5.0"160 implementation "androidx.credentials:credentials-play-services-auth:1.5.0"161 implementation "androidx.glance:glance-appwidget:1.1.0"162 implementation "androidx.glance:glance-material3:1.1.0"163 implementation "androidx.hilt:hilt-navigation-compose:1.2.0"164 // In-app updates: a periodic release check that survives Doze without a165 // service. hilt-work lets the worker take UpdateRepository by injection166 // rather than reaching for a global.167 implementation "androidx.hilt:hilt-work:1.2.0"168 kapt "androidx.hilt:hilt-compiler:1.2.0"169 implementation "androidx.work:work-runtime-ktx:2.9.1"170 implementation "androidx.lifecycle:lifecycle-runtime-compose:2.8.4"171 implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4"172 implementation "androidx.lifecycle:lifecycle-process:2.8.4"173 implementation "androidx.navigation:navigation-compose:2.8.0"174 // Deliberately pinned to 1.1.0-alpha06 (audit M-12). 1.1.0 stable exists175 // now and GradleDependency lint flags this coordinate; a bump is a policy176 // choice (Tink runtime vs. baseline AES, master-key rotation semantics),177 // not an oversight, and is tracked separately. Exact alpha (never a floating178 // range) so the resolved artifact is reproducible. Used only for the179 // duress/license EncryptedSharedPreferences; the vault slots are sealed by180 // VaultCrypto, not this.181 implementation "androidx.security:security-crypto:1.1.0-alpha06"182 implementation "androidx.compose.material3:material3"183 implementation "androidx.compose.ui:ui"184 implementation "androidx.compose.ui:ui-tooling-preview"185 implementation "androidx.compose.foundation:foundation"186 implementation "androidx.compose.material:material-icons-extended"187 implementation "androidx.core:core-ktx:1.13.1"188 implementation "com.google.android.material:material:1.12.0"189190 implementation "com.google.dagger:hilt-android:2.51.1"191 kapt "com.google.dagger:hilt-compiler:2.51.1"192 implementation "com.google.zxing:core:3.5.3"193 implementation "androidx.camera:camera-core:1.3.4"194 implementation "androidx.camera:camera-camera2:1.3.4"195 implementation "androidx.camera:camera-lifecycle:1.3.4"196 implementation "androidx.camera:camera-view:1.3.4"197 implementation "com.squareup.okhttp3:okhttp:4.12.0"198 implementation "org.bouncycastle:bcprov-jdk18on:1.84"199 // zstd-jni (reference libzstd) — per-section compression for the PeachScript200 // PCHS binary format (MF-2). Required for cross-platform interop with the201 // browser's zstd sections. The @aar variant ships the Android jniLibs202 // (lib/<abi>/libzstd-jni.so); the plain jar bundles only desktop natives and203 // would fail with UnsatisfiedLinkError on-device.204 implementation "com.github.luben:zstd-jni:1.5.6-3@aar"205 // The @aar ships only Android .so; the plain jar carries the desktop natives206 // the host JVM unit tests need.207 testImplementation "com.github.luben:zstd-jni:1.5.6-3"208 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"209 implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1"210211 debugImplementation "androidx.compose.ui:ui-tooling"212 debugImplementation "androidx.compose.ui:ui-test-manifest"213214 androidTestImplementation "androidx.test.ext:junit:1.2.1"215 androidTestImplementation "androidx.test:core:1.6.1"216 androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"217 androidTestImplementation "androidx.test.uiautomator:uiautomator:2.3.0"218 androidTestImplementation "androidx.compose.ui:ui-test-junit4"219220 testImplementation "junit:junit:4.13.2"221 // Real org.json on the unit-test classpath; android.jar's is a throwing stub,222 // so the release-manifest parser would otherwise be untestable off-device.223 testImplementation "org.json:json:20240303"224 testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1"225}226// PB-26-144: the alpha-train Play-Services identity-credentials artifact is227// reviewed by decision rather than removed, pending non-Play device evidence.228// A silent bump must fail with the review requirement named. The check is229// deferred to release-task execution: resolving the release runtime classpath230// at configuration time fails the variant model and would slow every build.231def pinnedCredentialsIdentityVersion = "16.0.0-alpha02"232233tasks.matching { it.name in ["assembleRelease", "bundleRelease", "packageRelease"] }.configureEach {234 doFirst {235 def resolved = configurations.getByName("releaseRuntimeClasspath")236 .resolvedConfiguration.resolvedArtifacts.find {237 it.moduleVersion.id.group == "com.google.android.gms" &&238 it.moduleVersion.id.name == "play-services-identity-credentials"239 }240 if (resolved == null || resolved.moduleVersion.id.version != pinnedCredentialsIdentityVersion) {241 def resolvedVersion = resolved?.moduleVersion?.id?.version ?: "missing"242 throw new GradleException(243 "play-services-identity-credentials must remain pinned to ${pinnedCredentialsIdentityVersion}; " +244 "resolved ${resolvedVersion}. Review the alpha artifact's manifest components and GMS " +245 "metadata, and update docs/ANDROID-RELEASE-MANIFEST-INVENTORY.md, before bumping it.",246 )247 }248 }249}