Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / maps / build.gradle.kts
build.gradle.kts167 lines · 8.3 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 `:<module>:metadata` task name either way. |
| 5 | id("common-conventions-preview-metadata") |
| 6 | } |
| 7 | |
| 8 | launcherIcon { |
| 9 | symbol = "location_on" |
| 10 | } |
| 11 | |
| 12 | // Pixel Watch 5 is armeabi-v7a (32-bit) only: an arm64-only APK is rejected at install. |
| 13 | nativeAbis { |
| 14 | armv7 = true |
| 15 | } |
| 16 | |
| 17 | android { |
| 18 | defaultConfig { |
| 19 | applicationId = "com.vayunmathur.maps" |
| 20 | } |
| 21 | // PoiIndexTest exercises the real side-file reader, which logs. Without this every |
| 22 | // android.util.Log call throws "not mocked" and the test can only cover code that never logs. |
| 23 | testOptions.unitTests.isReturnDefaultValues = true |
| 24 | } |
| 25 | |
| 26 | androidComponents { |
| 27 | onVariants { variant -> |
| 28 | variant.sources.jniLibs?.addStaticSourceDirectory( |
| 29 | layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath |
| 30 | ) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | // Native offline routing engine + traffic MVT tile encoder (Rust). See |
| 35 | // maps/src/main/rust/. Replaces the previous CMake/C++ libofflinerouter. |
| 36 | rustNativeLib("offlinerouter", "maps") |
| 37 | |
| 38 | // Only the classes below actually load a Rust cdylib: they execute a path |
| 39 | // that touches OfflineRouterNative.available (libofflinerouter, via |
| 40 | // OfflineRouter.getRoute / OfflineRouterTransit / OfflineRouterTraffic's |
| 41 | // tile server / road-route planning) or render MapSurface (libmap_renderer |
| 42 | // via library:map's MapNative). Tests that merely construct |
| 43 | // OfflineRouter.Raw* rows or call the pure decoding helpers never load |
| 44 | // either library and stay in the main task. Quarantine the loaders and |
| 45 | // the shared-JVM polluters below into testDevUnitTestNative |
| 46 | // (forkEvery = 1); the remaining classes batch 20-per-JVM in |
| 47 | // testDevUnitTest, which depends on the quarantine task so the usual |
| 48 | // invocation still runs everything. |
| 49 | rustNativeTests { |
| 50 | nativeClasses.addAll( |
| 51 | listOf( |
| 52 | "com.vayunmathur.maps.ui.PlaceHeaderDeepSlice3ExtraTest", |
| 53 | "com.vayunmathur.maps.ui.map.Slice1Pass2MapSurfaceProbeTest", |
| 54 | "com.vayunmathur.maps.util.MapsTrafficServerC5Test", |
| 55 | "com.vayunmathur.maps.util.MapsTransitC5Test", |
| 56 | "com.vayunmathur.maps.util.MapsTransitLinesC5Test", |
| 57 | "com.vayunmathur.maps.util.OfflineRouterSlice3ExtraTest", |
| 58 | "com.vayunmathur.maps.util.OfflineRouterTransitSlice3ExtraTest", |
| 59 | "com.vayunmathur.maps.util.RoadRoutesSlice3Test", |
| 60 | ) |
| 61 | ) |
| 62 | // Shared-JVM polluters keep forkEvery = 1 in the same companion task: |
| 63 | // DataStoreUtils is a process-wide singleton whose init eagerly |
| 64 | // collects the preferences DataStore, and the DataStore-backed |
| 65 | // ViewModels (MapSettings / MapsSearch / Parking / SavedPlaces / |
| 66 | // SelectedFeature — plus TransitStopsViewModel's departures flow) |
| 67 | // turn its flows into viewModelScope collectors |
| 68 | // (several SharingStarted.Eagerly) that are never cleared when the |
| 69 | // test never calls onCleared; persisted DataStore state also leaks |
| 70 | // into classes expecting defaults. Same hazard for tests that drive |
| 71 | // the NavigationSessionManager / PoiIndex process-wide singletons. |
| 72 | // Audit rule: any test instantiating one of those ViewModels (or |
| 73 | // launching MainActivity, which builds them), using |
| 74 | // DataStoreUtils.getInstance / a DataStore-backed store directly, or |
| 75 | // calling NavigationSessionManager.init/start belongs here. All |
| 76 | // other classes batch. |
| 77 | isolatedClasses.addAll( |
| 78 | listOf( |
| 79 | "com.vayunmathur.maps.MainActivityNavigationSlice3Test", |
| 80 | "com.vayunmathur.maps.MainActivitySlice3Test", |
| 81 | "com.vayunmathur.maps.MapsActivityW6Test", |
| 82 | "com.vayunmathur.maps.car.CarSlice3ExtraTest", |
| 83 | "com.vayunmathur.maps.car.MapsCarNavScreenC5Test", |
| 84 | "com.vayunmathur.maps.data.StoresSlice3Test", |
| 85 | "com.vayunmathur.maps.ui.BottomSheetClicksSlice2Test", |
| 86 | "com.vayunmathur.maps.ui.BottomSheetContentVmSlice2Test", |
| 87 | "com.vayunmathur.maps.ui.BottomSheetHeaderDirectionsSlice2Test", |
| 88 | "com.vayunmathur.maps.ui.BottomSheetWiringSlice2Test", |
| 89 | "com.vayunmathur.maps.ui.ComposeSurfacesSlice3ExtraTest", |
| 90 | "com.vayunmathur.maps.ui.GoogleConsentDialogSlice2Test", |
| 91 | "com.vayunmathur.maps.ui.GoogleConsentRecordSlice2Test", |
| 92 | "com.vayunmathur.maps.ui.MapSheetEffectsSlice3ExtraTest", |
| 93 | "com.vayunmathur.maps.ui.MapsComposeC5bTest", |
| 94 | "com.vayunmathur.maps.ui.MapsContentBoxC5Test", |
| 95 | "com.vayunmathur.maps.ui.MapsPickingC5Test", |
| 96 | "com.vayunmathur.maps.ui.SavedPlacesDialogsSlice3ExtraTest", |
| 97 | "com.vayunmathur.maps.ui.SavedPlacesPageSlice3Test", |
| 98 | "com.vayunmathur.maps.ui.SearchActionsSlice3ExtraTest", |
| 99 | "com.vayunmathur.maps.ui.Slice3FinalBatchTest", |
| 100 | "com.vayunmathur.maps.ui.Slice3Pass5SheetsTest", |
| 101 | "com.vayunmathur.maps.ui.WideHostSlice3ExtraTest", |
| 102 | "com.vayunmathur.maps.ui.WideLayoutSlice3Test", |
| 103 | "com.vayunmathur.maps.ui.map.Slice1InitialCameraComposeTest", |
| 104 | "com.vayunmathur.maps.ui.map.Slice1Pass2InitialCameraTest", |
| 105 | "com.vayunmathur.maps.ui.settings.Slice1Pass2SettingsTest", |
| 106 | "com.vayunmathur.maps.ui.settings.Slice1SettingsComposeTest", |
| 107 | "com.vayunmathur.maps.util.MapsNavSensorC5Test", |
| 108 | "com.vayunmathur.maps.util.MapsSearchVmC5Test", |
| 109 | "com.vayunmathur.maps.util.MapsSelectedFeatureC5Test", |
| 110 | "com.vayunmathur.maps.util.NavigationServiceModesSlice3ExtraTest", |
| 111 | "com.vayunmathur.maps.util.NavigationServiceSlice3ExtraTest", |
| 112 | "com.vayunmathur.maps.util.NavigationSessionSlice3ExtraTest", |
| 113 | "com.vayunmathur.maps.util.OverlayDefaultsSlice3Test", |
| 114 | "com.vayunmathur.maps.util.PoiMapViewModelSlice2Test", |
| 115 | "com.vayunmathur.maps.util.PoiViewportSlice2Test", |
| 116 | "com.vayunmathur.maps.util.RecalcAndSearchSlice3ExtraTest", |
| 117 | "com.vayunmathur.maps.util.SelectedFeatureSlice3ExtraTest", |
| 118 | "com.vayunmathur.maps.util.SelectedPoiInfoSlice3ExtraTest", |
| 119 | "com.vayunmathur.maps.util.SelectedRoutesReviewsSlice3ExtraTest", |
| 120 | "com.vayunmathur.maps.util.Slice3Pass3NavTest", |
| 121 | "com.vayunmathur.maps.util.Slice3Pass4TransitVmTest", |
| 122 | "com.vayunmathur.maps.util.TransitAndRideSlice3ExtraTest", |
| 123 | "com.vayunmathur.maps.util.UtilBatch2Slice3Test", |
| 124 | "com.vayunmathur.maps.util.ViewModelsSlice3Test", |
| 125 | ) |
| 126 | ) |
| 127 | } |
| 128 | |
| 129 | dependencies { |
| 130 | implementation(project(":library:map")) |
| 131 | implementation(project(":library:image")) |
| 132 | implementation(project(":library:network")) |
| 133 | |
| 134 | implementation(project(":library:downloadservice")) |
| 135 | |
| 136 | // WorkManager: the map-overlay check worker outlives the settings screen. |
| 137 | implementation(project(":library:work")) |
| 138 | |
| 139 | // Both sides of the Wear OS sync live in this one APK (same |
| 140 | // applicationId and signing, as the WearLink handshake requires): |
| 141 | // platform/WearMapsSync publishes the phone region/route/position, |
| 142 | // sync/WearLinkBridge receives them on a watch. FormFactor picks |
| 143 | // the side at runtime. |
| 144 | implementation(project(":library:wearlink")) |
| 145 | // Watch experience (ui/Wear*): Wear Compose + the repo log facade the |
| 146 | // watch data/sync code writes through. |
| 147 | implementation(libs.androidx.wear.compose.material) |
| 148 | implementation(libs.androidx.wear.compose.foundation) |
| 149 | implementation(project(":library:log")) |
| 150 | |
| 151 | // Manifest JSON parsing (pure JVM: unit-testable, unlike org.json). |
| 152 | implementation(libs.kotlinx.serialization.json) |
| 153 | |
| 154 | // Android Auto (P12): AndroidX Car App Library. `app` provides the |
| 155 | // CarAppService/Session/Screen/template model; `app-projected` provides the |
| 156 | // phone-projected (Android Auto) host connection. Only pulled into the car |
| 157 | // code path — the phone UI is untouched. |
| 158 | implementation(libs.androidx.car.app) |
| 159 | implementation(libs.androidx.car.app.projected) |
| 160 | // Host-side car screens (CarSearchScreen/CarMapRenderer) run against |
| 161 | // TestCarContext under Robolectric; the real head unit is DHU-only. |
| 162 | testImplementation(libs.androidx.car.app.testing) |
| 163 | testImplementation(libs.androidx.work.testing) |
| 164 | |
| 165 | // Car-view store-listing screenshots render through the shared host renderer. |
| 166 | add("screenshotTestImplementation", project(":library:carhost")) |
| 167 | } |