Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / vpn / build.gradle.kts
build.gradle.kts81 lines · 3.1 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 `:vpn:metadata` task name either way. |
| 5 | id("common-conventions-preview-metadata") |
| 6 | alias(libs.plugins.ksp) |
| 7 | } |
| 8 | |
| 9 | launcherIcon { |
| 10 | symbol = "vpn_lock" |
| 11 | } |
| 12 | |
| 13 | android { |
| 14 | defaultConfig { |
| 15 | applicationId = "com.vayunmathur.vpn" |
| 16 | minSdk = 31 // required for VpnService with per-app config etc (keep same as others) |
| 17 | } |
| 18 | packaging { |
| 19 | jniLibs { |
| 20 | pickFirsts.add("**/libc++_shared.so") |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | androidComponents { |
| 26 | onVariants { variant -> |
| 27 | variant.sources.jniLibs?.addStaticSourceDirectory( |
| 28 | layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath |
| 29 | ) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | rustNativeLib("vpn_wireguard", "vpn") |
| 34 | |
| 35 | // Only the classes below actually load libvpn_wireguard: they call |
| 36 | // VpnNative key/tunnel externs directly (guarded by a nativeAvailable() |
| 37 | // probe, but the call still binds the library in that JVM). Tests that |
| 38 | // merely parse configs, inspect packets, or exercise the pure service |
| 39 | // helpers never touch VpnNative and stay in the main task. Quarantine |
| 40 | // the loaders and the shared-JVM polluters below into |
| 41 | // testDevUnitTestNative (forkEvery = 1); the remaining classes batch |
| 42 | // 20-per-JVM in testDevUnitTest, which depends on the quarantine task so |
| 43 | // the usual invocation still runs everything. |
| 44 | rustNativeTests { |
| 45 | nativeClasses.addAll( |
| 46 | listOf( |
| 47 | "com.vayunmathur.vpn.service.FinalCoverageBatchTest", |
| 48 | "com.vayunmathur.vpn.service.PumpLoopTest", |
| 49 | "com.vayunmathur.vpn.service.TunnelSessionMoreTest", |
| 50 | "com.vayunmathur.vpn.service.TwoTunnelRouteTest", |
| 51 | "com.vayunmathur.vpn.service.VpnTunnelServiceTest", |
| 52 | "com.vayunmathur.vpn.util.VpnNativeTest", |
| 53 | ) |
| 54 | ) |
| 55 | // Shared-JVM polluters keep forkEvery = 1 in the same companion task: |
| 56 | // VpnViewModel's init starts a never-ending viewModelScope poll loop |
| 57 | // plus WhileSubscribed stateIn collectors that are never cleared when |
| 58 | // the test never calls onCleared, and BypassList reads/writes the |
| 59 | // process-wide DataStoreUtils singleton (persisted bypass set leaks |
| 60 | // into classes expecting defaults). Audit rule: any test |
| 61 | // instantiating VpnViewModel (or rendering a page that takes one) or |
| 62 | // using BypassList directly belongs here. All other classes batch. |
| 63 | isolatedClasses.addAll( |
| 64 | listOf( |
| 65 | "com.vayunmathur.vpn.platform.VpnViewModelTest", |
| 66 | "com.vayunmathur.vpn.ui.FinalVpnBatchTest", |
| 67 | "com.vayunmathur.vpn.ui.MainActivityAndBypassSwitchTest", |
| 68 | "com.vayunmathur.vpn.ui.NavigationAndPagesTest", |
| 69 | "com.vayunmathur.vpn.ui.PageCallbacksTest", |
| 70 | "com.vayunmathur.vpn.ui.VpnComposeScreensTest", |
| 71 | ) |
| 72 | ) |
| 73 | } |
| 74 | |
| 75 | dependencies { |
| 76 | implementRoom(libs) |
| 77 | implementation(project(":library:room")) |
| 78 | implementation(libs.androidx.datastore.preferences) |
| 79 | // User-supplied VPN endpoint: cannot pin, must use platform SYSTEM trust; document escape hatch. |
| 80 | implementation(project(":library:network")) |
| 81 | } |