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

Modern-Apps.git / games / chess / build.gradle.kts

build.gradle.kts89 lines · 4.1 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 `:games:chess:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6}
7
8launcherIcon {
9 symbol = "chess"
10}
11
12android {
13 defaultConfig {
14 applicationId = "com.vayunmathur.games.chess"
15 }
16 androidResources {
17 // Maia3's weights are read in place through an `AssetFileDescriptor`, and
18 // `AssetManager.openFd` throws for a deflated entry. Costs nothing on download size:
19 // fp16 weights barely compress.
20 noCompress += "maml"
21 }
22}
23
24// This module has no Rust of its own, but :library:ml registers
25// libmodelrunner (rustNativeLib), so every unit test here has kept
26// forkEvery = 1. Only the classes below actually load that library:
27// they construct ChessViewModel, whose init launches
28// ChessApi.isAvailable() -> MaiaEngine.ensure() ->
29// MaiaHandle.inAssets, which touches MlNative.isAvailable
30// (System.loadLibrary("modelrunner") via NativeLoader); Y3MainActivityTest
31// reaches the same probe by launching MainActivity, whose Game
32// destination builds ChessViewModel. Tests that merely call the pure
33// MaiaEngine.encodePlanes/moveIndex helpers (MaiaEncodingTest),
34// compose boards/screens with fake actions, or drive the pure rules
35// never load the library and stay in the main task. Quarantine the
36// loaders and the shared-JVM polluters below into
37// testDevUnitTestNative (forkEvery = 1); the remaining classes batch
38// 20-per-JVM in testDevUnitTest, which depends on the quarantine task
39// so the usual invocation still runs everything.
40rustNativeTests {
41 nativeClasses.addAll(
42 listOf(
43 "com.vayunmathur.games.chess.ChessDropTest",
44 "com.vayunmathur.games.chess.Y3ChessGameFlowTest",
45 "com.vayunmathur.games.chess.Y3MainActivityTest",
46 "com.vayunmathur.games.chess.util.ChessViewModelTest",
47 "com.vayunmathur.games.chess.util.ViewModelCoverageTest",
48 )
49 )
50 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
51 // PuzzleViewModel/LearnViewModel collect their uiState in
52 // viewModelScope and persist through the DataStoreUtils
53 // process-wide singleton (its init eagerly collects the
54 // preferences DataStore), OnlineChessViewModel launches its
55 // Lichess event-stream/redirect collectors in init over the same
56 // singleton via LichessTokenStore (whose sealerForTest is a
57 // process-wide static and whose migration scope is never
58 // cancelled), and LearnRepository/PuzzleRepository cache their
59 // bundled data process-wide; persisted DataStore state also leaks
60 // into classes expecting defaults (the online tests clear the
61 // token store in setUp/tearDown for exactly this reason). Audit
62 // rule: any test instantiating PuzzleViewModel / LearnViewModel /
63 // OnlineChessViewModel, using LichessTokenStore directly, or
64 // launching MainActivity (already quarantined as a native loader
65 // above) belongs here. All other classes batch.
66 isolatedClasses.addAll(
67 listOf(
68 "com.vayunmathur.games.chess.ChessPass3DrawTest",
69 "com.vayunmathur.games.chess.LearnStageScreenTest",
70 "com.vayunmathur.games.chess.OnlineScreensTest",
71 "com.vayunmathur.games.chess.Y3LearnScreensTest",
72 "com.vayunmathur.games.chess.Y3LichessNetTest",
73 "com.vayunmathur.games.chess.Y3OnlineScreensTest",
74 "com.vayunmathur.games.chess.Y3OnlineVmNetTest",
75 "com.vayunmathur.games.chess.platform.AuthCoverageTest",
76 "com.vayunmathur.games.chess.data.LichessTokenStoreTest",
77 "com.vayunmathur.games.chess.platform.OnlineChessViewModelTest",
78 "com.vayunmathur.games.chess.platform.OnlineStreamCoverageTest",
79 "com.vayunmathur.games.chess.platform.OnlineViewModelCoverageTest",
80 "com.vayunmathur.games.chess.util.PuzzleAndLearnViewModelTest",
81 )
82 )
83}
84
85dependencies {
86 implementation(project(":library:ml"))
87 implementation(project(":library:network"))
88 implementation(libs.androidx.browser)
89}