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

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

build.gradle.kts85 lines · 3.9 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 `:translate:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6 alias(libs.plugins.ksp)
7}
8
9launcherIcon {
10 symbol = "translate"
11}
12
13// This module has no rustNativeLib of its own: the native load arrives
14// transitively from :library:ml (libmodelrunner, via :library:ocr too),
15// which is what puts this module's tests on the forkEvery = 1 path at
16// all. Only the classes below actually load it: PlatformEnginesTest
17// drives NllbTranslator/MadladTranslator availability (and fabricates
18// model files in-class, so a handle construction — which reads
19// MlNative.isAvailable — is reachable), and ImageTranslateScreenTest
20// reaches TextRecognizer through the OCR seam (its init reads
21// MlNative.isAvailable). Tests that merely reference a handle's pure
22// constants, stub the engines, or compose screens from fake actions
23// never load the library and stay in the main task. Quarantine the
24// loaders and the shared-JVM polluters below into
25// testDevUnitTestNative (forkEvery = 1); the remaining classes batch
26// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so
27// the usual invocation still runs everything.
28rustNativeTests {
29 nativeClasses.addAll(
30 listOf(
31 "com.vayunmathur.translate.platform.PlatformEnginesTest",
32 "com.vayunmathur.translate.ui.ImageTranslateScreenTest",
33 )
34 )
35 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
36 // TranslateViewModel launches a viewModelScope init read over
37 // TranslateSettings (the module's preferences DataStore) and calls
38 // translator.isAvailable() from it, stateIns the process-wide
39 // TranslateRepository.get singleton's Room flows in viewModelScope,
40 // and is never cleared when the test never calls onCleared; the
41 // repository singleton and persisted DataStore/Room state also leak
42 // into classes expecting defaults. Audit rule: any test
43 // instantiating TranslateViewModel (or launching MainActivity, which
44 // builds one), using TranslateSettings directly, or using the
45 // TranslateRepository singleton belongs here. ImageTranslateScreenTest
46 // also instantiates the ViewModel but is already quarantined as a
47 // native loader above. All other classes batch.
48 isolatedClasses.addAll(
49 listOf(
50 "com.vayunmathur.translate.data.DataLayerTest",
51 "com.vayunmathur.translate.data.DbBackedRepositoryTest",
52 "com.vayunmathur.translate.platform.BackupWiringTest",
53 "com.vayunmathur.translate.platform.SharedImageIntentTest",
54 "com.vayunmathur.translate.platform.ViewModelAndPagesTest",
55 "com.vayunmathur.translate.ui.CameraScreenProbeTest",
56 "com.vayunmathur.translate.ui.DbBackedPagesTest",
57 "com.vayunmathur.translate.ui.ExpandedAndLoopTest",
58 "com.vayunmathur.translate.ui.ImageAndActivityTest",
59 )
60 )
61}
62
63android {
64 defaultConfig {
65 applicationId = "com.vayunmathur.translate"
66 }
67}
68
69dependencies {
70 // On-device translation runs on `:library:ml`'s own Vulkan compute runtime (NLLB-200 via
71 // `NllbHandle`); the two model files are downloaded at runtime from the mirror.
72 implementation(project(":library:ml"))
73 implementation(project(":library:downloadservice"))
74 implementation(project(":library:ocr"))
75 implementation(project(":library:network"))
76 implementation(libs.androidx.exifinterface)
77 implementation(libs.androidx.datastore.preferences)
78 implementation(libs.androidx.camera.core)
79 implementation(libs.androidx.camera.camera2)
80 implementation(libs.androidx.camera.lifecycle)
81 implementation(libs.androidx.camera.view)
82 implementation(libs.androidx.camera.compose)
83 implementRoom(libs)
84 implementation(project(":library:room"))
85}