Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / weather / build.gradle.kts

build.gradle.kts144 lines · 6.5 KiBRaw
1plugins {
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
9launcherIcon {
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.
14nativeAbis {
15 armv7 = true
16}
17
18android {
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
32androidComponents {
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/.
41rustNativeLib("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.
56rustNativeTests {
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
102dependencies {
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 implementation(project(":library:weartiles"))
113 // Watch experience (ui/Wear*): Wear Compose + the repo log facade the
114 // watch platform/sync code writes through.
115 implementation(libs.androidx.wear.compose.material)
116 implementation(libs.androidx.wear.compose.foundation)
117 implementation(project(":library:log"))
118 implementRoom(libs)
119 implementation(project(":library:room"))
120
121 // Decodes the brotli-compressed places database asset. This is the only
122 // reason the app links a codec at all; it does not use the network.
123 implementation(libs.brotli.dec)
124
125 // Android Auto (WEATHER): AndroidX Car App Library. `app` provides the
126 // CarAppService/Session/Screen/template model. Only pulled into the car
127 // code path (service/car/) — the phone UI is untouched.
128 implementation(libs.androidx.car.app)
129
130 // Car-view store-listing screenshots render through the shared host renderer.
131 add("screenshotTestImplementation", project(":library:carhost"))
132
133 testImplementation(libs.androidx.car.app.testing)
134 testImplementation(libs.androidx.work.testing)
135 testImplementation(libs.androidx.glance.appwidget.testing)
136 // work-testing carries Robolectric for JVM tests; on-device it is
137 // unavailable from the mirror and unused, so exclude it there.
138 "androidTestImplementation"(libs.androidx.work.testing) {
139 exclude(group = "org.robolectric")
140 }
141 "androidTestImplementation"(libs.androidx.car.app.testing) {
142 exclude(group = "org.robolectric")
143 }
144}