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

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

build.gradle.kts98 lines · 4.5 KiBRaw
1plugins {
2 id("common-conventions-app")
3 id("common-conventions-preview-metadata")
4}
5
6launcherIcon {
7 symbol = "share"
8}
9
10android {
11 defaultConfig {
12 applicationId = "com.vayunmathur.share"
13 }
14}
15
16androidComponents {
17 onVariants { variant ->
18 variant.sources.jniLibs?.addStaticSourceDirectory(
19 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
20 )
21 }
22}
23
24// Rust protocol crate (UKEY2, protobuf framing, secure messages, payload).
25// See share/src/main/rust/ and share/PROTOCOL_CONTRACT.md.
26rustNativeLib("share_nearby", "share")
27
28// Only the classes below actually load libshare_nearby: they call
29// ShareNativeDiscovery.native* directly, construct ShareSession
30// (ShareNative.nativeInit), run TcpTransport listen/connect (which
31// creates a ShareSession per socket), drive the Ble/Nsd discovery
32// managers (native advertisement/endpoint codecs, NSD service type),
33// or touch ShareReceiveController (ensure() builds endpoint info via
34// native, transport() is the process-wide TcpTransport). Tests that
35// merely read the inlined ShareNative.DEVICE_TYPE_PHONE constant, use
36// the pure plist/HTTP/DvZip helpers, compose with FakeActions, or drive
37// a per-instance AirDropReceiver/ShareReceiveNotifier never load the
38// library and stay in the main task. Quarantine the loaders and the
39// shared-JVM polluters below into testDevUnitTestNative
40// (forkEvery = 1); the remaining classes batch 20-per-JVM in
41// testDevUnitTest, which depends on the quarantine task so the usual
42// invocation still runs everything.
43rustNativeTests {
44 nativeClasses.addAll(
45 listOf(
46 "com.vayunmathur.share.domain.protocol.ShareSessionTest",
47 "com.vayunmathur.share.network.transport.TcpTransportExtraTest",
48 "com.vayunmathur.share.network.transport.TcpTransportTest",
49 "com.vayunmathur.share.platform.FinalPushTest",
50 "com.vayunmathur.share.platform.GapPush2Test",
51 "com.vayunmathur.share.platform.GapPush3Test",
52 "com.vayunmathur.share.platform.GapPush4Test",
53 "com.vayunmathur.share.platform.GapPush5Test",
54 "com.vayunmathur.share.platform.GapPush6Test",
55 "com.vayunmathur.share.platform.GapPush7Test",
56 "com.vayunmathur.share.platform.GapPush8Test",
57 "com.vayunmathur.share.platform.GapPush9Test",
58 "com.vayunmathur.share.platform.GapPushTest",
59 "com.vayunmathur.share.platform.MoreCoverageTest",
60 "com.vayunmathur.share.platform.ShareViewModelConnectTest",
61 "com.vayunmathur.share.platform.discovery.DiscoveryManagersTest",
62 "com.vayunmathur.share.platform.receive.ReceiveComponentsTest",
63 "com.vayunmathur.share.protocol.ShareNativeDiscoveryTest",
64 )
65 )
66 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
67 // ShareViewModel turns its combined flows into a viewModelScope
68 // stateIn collector (SharingStarted.WhileSubscribed) that is never
69 // cleared when the test never calls onCleared, and
70 // ShareReceiveController is a process-wide singleton (cached
71 // transport/managers/notifier, IO scope, mutable localName) over
72 // the DataStoreUtils singleton, whose init eagerly collects the
73 // preferences DataStore; persisted DataStore state also leaks into
74 // classes expecting defaults. Audit rule: any test instantiating
75 // ShareViewModel or launching MainActivity / SharePopupActivity
76 // (which build one) belongs here, unless it already loads the
77 // native library above. All other classes batch.
78 isolatedClasses.addAll(
79 listOf(
80 "com.vayunmathur.share.platform.ShareViewModelHelpersTest",
81 "com.vayunmathur.share.ui.SharePopupAndActivitiesTest",
82 // Victim of FileProvider's static path-strategy cache: the first
83 // getUriForFile in a shared sandbox caches that test method's
84 // per-method filesDir root, and AirDropReceiver's upload then
85 // fails its contentUri root check (500) whenever
86 // ReceivedFileStoreTest's contentUri test ran first in the JVM.
87 "com.vayunmathur.share.platform.airdrop.AirDropReceiverTest",
88 )
89 )
90}
91
92dependencies {
93 // ViewModel/Compose already via common-conventions-app; explicit lifecycle for clarity.
94 implementation(libs.androidx.lifecycle.viewmodel.ktx)
95 // @SystemApi NetworkAgent/NetworkProvider for the Mosey `mosey0` AirDrop link; compile-only,
96 // must NOT be packaged. See :library:aosp-stubs.
97 compileOnly(project(":library:aosp-stubs"))
98}