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

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

build.gradle.kts105 lines · 5.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 `:code:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6}
7
8launcherIcon {
9 symbol = "code"
10}
11
12android {
13 defaultConfig {
14 applicationId = "com.vayunmathur.code"
15 }
16}
17
18// Native tree-sitter highlighter (Rust → libcode_ts.so, arm64-v8a). Built on every `code` build;
19// TreeSitterNative loads it at runtime and highlights the 10 supported languages, with the regex
20// tokenizer still covering the remaining languages. Requires the Android NDK +
21// `rustup target add aarch64-linux-android`; the pinned grammar set is locked in
22// code/src/main/rust/Cargo.lock.
23androidComponents {
24 onVariants { variant ->
25 val rustDir = layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
26 variant.sources.jniLibs?.addStaticSourceDirectory(rustDir)
27 }
28}
29rustNativeLib("code_ts", "code")
30
31// Only the classes below actually load a native library: they execute a
32// path that touches TreeSitterNative (libcode_ts via NativeLoader) —
33// directly, through treeSitterColorSpans, or through CodeEditor /
34// CodeEditorView's rememberTreeSitterSpans when a tabbed EditorScreen /
35// EditorBody / SplitEditors composition runs — or they drive GitRepo
36// (JGit) against real on-disk repositories. TreeSitterNativeTest and
37// EditorChromeLogicTest are plain JVM tests, so mixing them in one JVM
38// with the Robolectric sandbox loaders binds libcode_ts to two
39// classloaders. Quarantine the loaders and the shared-JVM polluters
40// below into testDevUnitTestNative (forkEvery = 1); the remaining
41// classes batch 20-per-JVM in testDevUnitTest, which depends on the
42// quarantine task so the usual invocation still runs everything.
43rustNativeTests {
44 nativeClasses.addAll(
45 listOf(
46 "com.vayunmathur.code.ui.CodeEditorUiTest",
47 "com.vayunmathur.code.ui.EditorChromeLogicTest",
48 "com.vayunmathur.code.ui.EditorScreenUiTest",
49 "com.vayunmathur.code.ui.Wave2TreeScreenUiTest",
50 "com.vayunmathur.code.util.GitLocalRemoteTest",
51 "com.vayunmathur.code.util.GitPushTest",
52 "com.vayunmathur.code.util.GitRepoTest",
53 "com.vayunmathur.code.util.TreeSitterNativeTest",
54 )
55 )
56 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
57 // EditorPrefs is the module's only DataStore owner (the top-level
58 // preferencesDataStore delegate for "code_editor"), and
59 // EditorViewModel init launches ~20 viewModelScope collectors that
60 // read its flows (several setters then persist through it), never
61 // cleared when the test never calls onCleared; EditorPrefs also
62 // holds the process-wide sealerForTest static that CodeTokenSealing /
63 // EditorPrefs tests swap. Persisted DataStore state (folder, session
64 // tabs, snippets, git credentials — SessionRestoreTest even cleans
65 // up explicitly "so later VMs in this process start empty") leaks
66 // into classes expecting defaults. Audit rule: any test
67 // instantiating EditorViewModel (or launching a screen that builds
68 // one), or using EditorPrefs directly, belongs here. Several of
69 // these UI classes also render the editor and would load
70 // libcode_ts anyway. All other classes batch.
71 isolatedClasses.addAll(
72 listOf(
73 "com.vayunmathur.code.data.CodeTokenSealingTest",
74 "com.vayunmathur.code.ui.EditorPagesUiTest",
75 "com.vayunmathur.code.ui.EditorScreenDialogsUiTest",
76 "com.vayunmathur.code.ui.ExperimentalAndPagesUiTest",
77 "com.vayunmathur.code.ui.GitPageUiTest",
78 "com.vayunmathur.code.ui.MainAndExpandedUiTest",
79 "com.vayunmathur.code.ui.MoreInteractionsUiTest",
80 "com.vayunmathur.code.ui.PreviewAndMinimapBehaviourTest",
81 "com.vayunmathur.code.ui.RepoAndBodyUiTest",
82 "com.vayunmathur.code.ui.SearchPreviewUiTest",
83 "com.vayunmathur.code.ui.Wave2EditorFindUiTest",
84 "com.vayunmathur.code.ui.Wave2GitToolbarUiTest",
85 "com.vayunmathur.code.ui.Wave2MoreUiTest",
86 "com.vayunmathur.code.ui.Wave3FinalPushTest",
87 "com.vayunmathur.code.util.EditorActionsTest",
88 "com.vayunmathur.code.util.EditorFileTreeOpsBehaviourTest",
89 "com.vayunmathur.code.util.EditorFileTreeOpsTest",
90 "com.vayunmathur.code.util.EditorPrefsTest",
91 "com.vayunmathur.code.util.EditorSearchOpsTest",
92 "com.vayunmathur.code.util.EditorViewModelTest",
93 "com.vayunmathur.code.util.LoadFailureTest",
94 "com.vayunmathur.code.util.SessionRestoreTest",
95 "com.vayunmathur.code.util.VmOpsTest",
96 "com.vayunmathur.code.util.Wave2VmActionsTest",
97 )
98 )
99}
100
101dependencies {
102 implementation(libs.androidx.datastore.preferences)
103 implementation(libs.jgit)
104 implementation(libs.androidx.webkit)
105}