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

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

build.gradle.kts174 lines · 9.0 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 `:photos:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6 alias(libs.plugins.ksp)
7}
8
9launcherIcon {
10 symbol = "photo_library"
11}
12
13android {
14 defaultConfig {
15 applicationId = "com.vayunmathur.photos"
16 }
17 androidResources {
18 // The four .maml files are read straight out of the APK by :library:ml, which opens them
19 // with `AssetManager.openFd` and streams them into the GPU. `openFd` throws outright for a
20 // deflated entry, so this is required rather than an optimisation — and it costs nothing on
21 // download size, since int8 and fp16 weights barely deflate.
22 noCompress += "maml"
23 }
24}
25
26androidComponents {
27 onVariants { variant ->
28 variant.sources.jniLibs?.addStaticSourceDirectory(
29 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
30 )
31 }
32}
33
34// Native pixel filters (Rust). See photos/src/main/rust/.
35rustNativeLib("photos_fx", "photos")
36
37// Only the classes below actually load a native library: they execute a
38// PhotosNative-backed adjustment (Blur/Stylize/Liquify via the *Data
39// applyToBitmap extensions, reached directly or through LayerCompositor)
40// or probe the :library:ml bridges (FaceRecognizer.modelsAvailable /
41// detectAndEmbed, ClipEmbedder.embeddingSupport — both construct
42// FaceDetector/FaceEmbedder/ClipHandle, whose initialisers touch
43// MlNative and load libmodelrunner). Classes that merely use the pure
44// FaceRecognizer/ClipEmbedder helpers (similarity, l2Normalize,
45// floatsToBytes), construct identity adjustments, or stub the ML paths
46// never load either library and stay in the main task. Quarantine the
47// loaders and the shared-JVM polluters below into
48// testDevUnitTestNative (forkEvery = 1); the remaining classes batch
49// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so
50// the usual invocation still runs everything.
51rustNativeTests {
52 nativeClasses.addAll(
53 listOf(
54 "com.vayunmathur.photos.data.AdjustmentBitmapsRealTest",
55 "com.vayunmathur.photos.data.AdjustmentPixelsEqualityTest",
56 "com.vayunmathur.photos.data.PhotosSlice1DataPass3Test",
57 "com.vayunmathur.photos.util.PhotosCovC2CompositorTest",
58 "com.vayunmathur.photos.util.PhotosCovC2IndexingTest",
59 "com.vayunmathur.photos.util.PhotosCovC2LogicTest",
60 "com.vayunmathur.photos.util.PhotosSlice1MlInertTest",
61 )
62 )
63 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
64 // GalleryViewModel and SecureFolderViewModel eagerly collect the
65 // process-wide DataStoreUtils singleton (its init launches a
66 // DataStore collector) from viewModelScope on the Robolectric main
67 // looper, and the Sync/Face workers and LiveWallpaper paths drive
68 // the same singleton; leaked collectors and persisted DataStore
69 // state leak into classes expecting defaults. The editor ViewModels
70 // pollute the same way: PhotoEditViewModel/VideoEditViewModel launch
71 // preview/composite jobs in viewModelScope that outlive the test and
72 // render through LayerCompositor on a torn-down Robolectric sandbox
73 // (observed: a leaked renderTextPixels NPE surfacing as
74 // UncaughtExceptionsBeforeTest in the next batched class). Audit
75 // rule: any test instantiating GalleryViewModel/
76 // SecureFolderViewModel/PhotoEditViewModel/VideoEditViewModel,
77 // launching MainActivity (which builds them), or driving
78 // SyncWorker/FaceWorker/LiveWallpaper/DataStoreUtils directly
79 // belongs here. All other classes batch.
80 isolatedClasses.addAll(
81 listOf(
82 "com.vayunmathur.photos.MainActivityRealLaunchTest",
83 "com.vayunmathur.photos.service.LiveWallpaperServiceRealTest",
84 "com.vayunmathur.photos.ui.AlbumDetailAndPickerTest",
85 "com.vayunmathur.photos.ui.FavoriteToggleComposeTest",
86 "com.vayunmathur.photos.ui.FavoritesWallpaperMotionTest",
87 "com.vayunmathur.photos.ui.GalleryActionsRealRepoTest",
88 "com.vayunmathur.photos.ui.GalleryPageDeepDriveTest",
89 "com.vayunmathur.photos.ui.PhotoDetailAndFilmstripTest",
90 "com.vayunmathur.photos.ui.PhotosPagesDeepDriveTest",
91 "com.vayunmathur.photos.ui.VaultViewerPageRealTest",
92 "com.vayunmathur.photos.ui.WallpaperSetFlowTest",
93 "com.vayunmathur.photos.util.GalleryViewModelRealRepoTest",
94 "com.vayunmathur.photos.util.PhotosCovC2NavigationTest",
95 "com.vayunmathur.photos.util.PhotosCovC2PagesTest",
96 "com.vayunmathur.photos.util.PhotosCovC2VmTest",
97 "com.vayunmathur.photos.util.PhotosFavoritesAlbumTest",
98 "com.vayunmathur.photos.util.PhotosNavEntriesDeepTest",
99 "com.vayunmathur.photos.util.PhotosNavigationDeepTest",
100 "com.vayunmathur.photos.util.PhotosPagesRealRepoTest",
101 "com.vayunmathur.photos.util.PhotosPrivacyFixesTest",
102 "com.vayunmathur.photos.util.PhotosSlice1VaultPage2Test",
103 "com.vayunmathur.photos.util.PhotosSlice1VaultUiTest",
104 "com.vayunmathur.photos.util.PhotosSlice1VaultVm2Test",
105 "com.vayunmathur.photos.util.PhotosSlice1VaultVm3Test",
106 "com.vayunmathur.photos.util.PhotosSlice1WorkersTest",
107 "com.vayunmathur.photos.util.PhotosSlice3EditPanelsTest",
108 "com.vayunmathur.photos.util.PhotosSlice3ExtrasTest",
109 "com.vayunmathur.photos.util.PhotosSlice3GalleryTest",
110 "com.vayunmathur.photos.util.PhotosSlice3PagesTest",
111 "com.vayunmathur.photos.util.PhotosSlice3VaultTest",
112 "com.vayunmathur.photos.util.SecureFolderRestoreRealTest",
113 "com.vayunmathur.photos.util.SyncWorkersRealRepoTest",
114 "com.vayunmathur.photos.photoslice2.BottomControlsEditingPass3Test",
115 "com.vayunmathur.photos.photoslice2.CurvesAndPanelsEditingPass3Test",
116 "com.vayunmathur.photos.photoslice2.EditPageEditingPass3Test",
117 "com.vayunmathur.photos.photoslice2.EditorStateEditingPass3Test",
118 "com.vayunmathur.photos.photoslice2.LayerControllerEditingPass3Test",
119 "com.vayunmathur.photos.photoslice2.LoadedPagesEditingPass3Test",
120 "com.vayunmathur.photos.photoslice2.OverlaysEditingPass3Test",
121 "com.vayunmathur.photos.photoslice2.PhotosCovC2EditorClickTest",
122 "com.vayunmathur.photos.photoslice2.PhotosCovC2EditorTest",
123 "com.vayunmathur.photos.photoslice2.RoutePreviewEditingPass3Test",
124 "com.vayunmathur.photos.photoslice2.Slice2Pass2LogicTest",
125 "com.vayunmathur.photos.photoslice2.Slice2Pass2PanelsTest",
126 "com.vayunmathur.photos.photoslice2.SliderGestureEditingPass3Test",
127 "com.vayunmathur.photos.photoslice2.StateLayerEditingPass3Test",
128 "com.vayunmathur.photos.photoslice2.VideoEditingPass3Test",
129 "com.vayunmathur.photos.photoslice2.VideoVmEditingPass3Test",
130 "com.vayunmathur.photos.ui.EditorDriveAllModesTest",
131 "com.vayunmathur.photos.ui.EditorStateFunctionsTest",
132 "com.vayunmathur.photos.ui.MaskAndVideoEditPageTest",
133 "com.vayunmathur.photos.ui.VideoPreviewAndCropTest",
134 "com.vayunmathur.photos.util.EditControllersDeepTest",
135 "com.vayunmathur.photos.util.EditSaverAndVideoWriteTest",
136 "com.vayunmathur.photos.util.PhotoEditDecodeAndExportTest",
137 "com.vayunmathur.photos.util.PhotosCovC2PixelTest",
138 "com.vayunmathur.photos.util.VideoEditAndWallpaperRealTest",
139 )
140 )
141}
142
143dependencies {
144 implementation(libs.androidx.compose.foundation)
145 // collectAsStateWithLifecycle in Navigation (as in :auto).
146 implementation(libs.androidx.lifecycle.runtime.compose)
147 implementation(libs.androidx.fragment.ktx)
148 implementation(project(":library:map"))
149 implementation(project(":library:image"))
150 implementation(libs.androidx.exifinterface)
151 // No ncnn and no onnxruntime anywhere in this APK. Face detection (SCRFD 500M), face
152 // embedding (MobileFaceNet), subject segmentation (U²-Net portable), PP-OCRv5 text
153 // recognition and TinyCLIP semantic search all run on :library:ml, our own Vulkan compute
154 // runtime.
155 implementation(project(":library:ml"))
156
157 implementRoom(libs)
158 implementation(project(":library:room"))
159 implementation(project(":library:ink"))
160
161 implementation(libs.androidx.media3.exoplayer)
162 implementation(libs.androidx.media3.ui.compose.material3)
163 implementation(libs.androidx.media3.transformer)
164 implementation(libs.androidx.media3.effect)
165 implementation(libs.androidx.media3.common)
166
167
168 implementation(project(":library:widgets"))
169 implementation(project(":library:biometric"))
170 implementation(project(":library:ocr"))
171 testImplementation(libs.androidx.work.testing)
172 testImplementation(libs.androidx.sqlite.bundled.jvm)
173 testImplementation(libs.mockito.core)
174}