Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / weather / build.gradle.kts
build.gradle.kts143 lines · 6.5 KiBRaw
| 1 | plugins { |
| 2 | id("common-conventions-app") |
| 3 | // Listing screenshots come from Compose previews (src/screenshotTest), not from an |
| 4 | // instrumented test on a device. Same `:weather:metadata` task name either way. |
| 5 | id("common-conventions-preview-metadata") |
| 6 | alias(libs.plugins.ksp) |
| 7 | } |
| 8 | |
| 9 | launcherIcon { |
| 10 | symbol = "partly_cloudy_day" |
| 11 | } |
| 12 | |
| 13 | // Pixel Watch 5 is armeabi-v7a (32-bit) only: an arm64-only APK is rejected at install. |
| 14 | nativeAbis { |
| 15 | armv7 = true |
| 16 | } |
| 17 | |
| 18 | android { |
| 19 | defaultConfig { |
| 20 | applicationId = "com.vayunmathur.weather" |
| 21 | } |
| 22 | |
| 23 | androidResources { |
| 24 | // The places database asset is already brotli-compressed by |
| 25 | // scripts/generate_places_db.py. Letting AAPT deflate it again costs |
| 26 | // build time, gains nothing, and makes the app pay a second inflate |
| 27 | // pass on top of its own when unpacking it. |
| 28 | noCompress += "br" |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | androidComponents { |
| 33 | onVariants { variant -> |
| 34 | variant.sources.jniLibs?.addStaticSourceDirectory( |
| 35 | layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath |
| 36 | ) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // Native `.om` weather-file decoder (Rust). See weather/src/main/rust/. |
| 41 | rustNativeLib("weather_om", "weather") |
| 42 | |
| 43 | // This module loads two Rust libraries in tests: its own libweather_om |
| 44 | // (above) and libmap_renderer from :library:map (implementation dep |
| 45 | // below), so every unit test here has kept forkEvery = 1. Only the |
| 46 | // classes below actually load one: they render WeatherMapPage (whose |
| 47 | // VectorMap surface touches MapNative.isAvailable and whose metadata / |
| 48 | // decode effects touch OmTilesNative.isAvailable) or compose the map |
| 49 | // metadata/decode effects directly. Tests that merely construct |
| 50 | // WeatherMapState, use the pure-Kotlin WxTiles/WxGrid decoders, or stub |
| 51 | // the native path before isAvailable is evaluated never load a library |
| 52 | // and stay in the main task. Quarantine the loaders and the shared-JVM |
| 53 | // polluters below into testDevUnitTestNative (forkEvery = 1); the |
| 54 | // remaining classes batch 20-per-JVM in testDevUnitTest, which depends |
| 55 | // on the quarantine task so the usual invocation still runs everything. |
| 56 | rustNativeTests { |
| 57 | nativeClasses.addAll( |
| 58 | listOf( |
| 59 | "com.vayunmathur.weather.ui.MapDecodeCacheTest", |
| 60 | "com.vayunmathur.weather.ui.MapPageTest", |
| 61 | "com.vayunmathur.weather.ui.PagesTest", |
| 62 | "com.vayunmathur.weather.ui.Wave3bWeatherCoverageTest", |
| 63 | ) |
| 64 | ) |
| 65 | // Shared-JVM polluters keep forkEvery = 1 in the same companion task: |
| 66 | // WeatherViewModel turns the repository's locations flow into a |
| 67 | // viewModelScope stateIn collector (SharingStarted.WhileSubscribed) |
| 68 | // that is never cleared when the test never calls onCleared, and its |
| 69 | // init enqueues WeatherRefreshWorker's hourly WorkManager work; |
| 70 | // its fetch paths also launch viewModelScope coroutines the test |
| 71 | // drains by polling. Same hazard for tests that launch MainActivity |
| 72 | // (which builds the ViewModel over WeatherRepository.get's |
| 73 | // process-wide singleton). This module has no DataStore owner (its |
| 74 | // datastore dependency is unused by main/test sources), so no |
| 75 | // DataStore polluters exist here. Audit rule: any test instantiating |
| 76 | // WeatherViewModel (or launching MainActivity, which builds one) |
| 77 | // belongs here; Wave3bWeatherCoverageTest and PagesTest also |
| 78 | // instantiate one but are already quarantined as native loaders |
| 79 | // above. All other classes batch. |
| 80 | isolatedClasses.addAll( |
| 81 | listOf( |
| 82 | // WxStaticDiskCacheTest installs a throwing WxStatic.fetcher |
| 83 | // mid-test and never restores it (resetForTest does not touch |
| 84 | // the fetcher), so any later same-JVM test that reaches |
| 85 | // WxStatic inherits the bomb (WeatherMiscTest's intent test |
| 86 | // failed exactly that way once batch composition shifted). |
| 87 | // forkEvery = 1 keeps the leak inside its own JVM. |
| 88 | "com.vayunmathur.weather.network.WxStaticDiskCacheTest", |
| 89 | "com.vayunmathur.weather.platform.ViewModelAddLocationTest", |
| 90 | "com.vayunmathur.weather.platform.ViewModelDeviceFixTest", |
| 91 | "com.vayunmathur.weather.platform.ViewModelFetchTest", |
| 92 | "com.vayunmathur.weather.platform.ViewModelSuccessTest", |
| 93 | "com.vayunmathur.weather.platform.WeatherViewModelTest", |
| 94 | "com.vayunmathur.weather.ui.DeviceLocationGrantedTest", |
| 95 | "com.vayunmathur.weather.ui.HomeAndLocationsExtraTest", |
| 96 | "com.vayunmathur.weather.ui.MoreEdgesTest", |
| 97 | "com.vayunmathur.weather.ui.Wave3WeatherCoverageTest", |
| 98 | ) |
| 99 | ) |
| 100 | } |
| 101 | |
| 102 | dependencies { |
| 103 | implementation(project(":library:network")) |
| 104 | implementation(project(":library:widgets")) |
| 105 | implementation(libs.androidx.datastore.preferences) |
| 106 | implementation(project(":library:map")) |
| 107 | // Both sides of the Wear OS sync live in this one APK (same |
| 108 | // applicationId and signing, as the WearLink handshake requires): |
| 109 | // sync/WearWeatherSync publishes the phone snapshot, sync/WearLinkBridge |
| 110 | // receives it on a watch. FormFactor picks the side at runtime. |
| 111 | implementation(project(":library:wearlink")) |
| 112 | // Watch experience (ui/Wear*): Wear Compose + the repo log facade the |
| 113 | // watch platform/sync code writes through. |
| 114 | implementation(libs.androidx.wear.compose.material) |
| 115 | implementation(libs.androidx.wear.compose.foundation) |
| 116 | implementation(project(":library:log")) |
| 117 | implementRoom(libs) |
| 118 | implementation(project(":library:room")) |
| 119 | |
| 120 | // Decodes the brotli-compressed places database asset. This is the only |
| 121 | // reason the app links a codec at all; it does not use the network. |
| 122 | implementation(libs.brotli.dec) |
| 123 | |
| 124 | // Android Auto (WEATHER): AndroidX Car App Library. `app` provides the |
| 125 | // CarAppService/Session/Screen/template model. Only pulled into the car |
| 126 | // code path (service/car/) — the phone UI is untouched. |
| 127 | implementation(libs.androidx.car.app) |
| 128 | |
| 129 | // Car-view store-listing screenshots render through the shared host renderer. |
| 130 | add("screenshotTestImplementation", project(":library:carhost")) |
| 131 | |
| 132 | testImplementation(libs.androidx.car.app.testing) |
| 133 | testImplementation(libs.androidx.work.testing) |
| 134 | testImplementation(libs.androidx.glance.appwidget.testing) |
| 135 | // work-testing carries Robolectric for JVM tests; on-device it is |
| 136 | // unavailable from the mirror and unused, so exclude it there. |
| 137 | "androidTestImplementation"(libs.androidx.work.testing) { |
| 138 | exclude(group = "org.robolectric") |
| 139 | } |
| 140 | "androidTestImplementation"(libs.androidx.car.app.testing) { |
| 141 | exclude(group = "org.robolectric") |
| 142 | } |
| 143 | } |