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

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

build.gradle.kts55 lines · 2.6 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 `:<module>:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6}
7
8launcherIcon {
9 symbol = "picture_as_pdf"
10}
11
12android {
13 defaultConfig {
14 applicationId = "com.vayunmathur.pdf"
15 }
16 // The wire parser logs via android.util.Log on its clamp/desync/non-affine paths, and the
17 // structural rasterizer tests drive drawSafePage through a spy android.graphics.Canvas. Both
18 // need the stub android.jar to return defaults instead of throwing "not mocked" (same as
19 // :cast, :maps). Robolectric-run tests are unaffected: they replace android.jar outright.
20 testOptions.unitTests.isReturnDefaultValues = true
21 // Robolectric reads the merged manifest and resources through the AGP-generated
22 // com/android/tools/test_config.properties, which only exists when this is on.
23 testOptions.unitTests.isIncludeAndroidResources = true
24}
25
26androidComponents {
27 onVariants { variant ->
28 val rustDir = layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
29 variant.sources.jniLibs?.addStaticSourceDirectory(rustDir)
30 // Note: if cargoBuild fails, stale .so could be packaged (audit #16). We rely on
31 // cargoBuild task's outputs.file check and the fact that RustNative.kt's per-ABI Exec
32 // task validates inputs/outputs. A doFirst delete of stale .so was considered but
33 // addStaticSourceDirectory vs addGeneratedSourceDirectory migration is tracked separately.
34 // For now, ensure cargoNdkBuild task deletes stale outputs on failure via its own doFirst/doLast
35 // in RustNative.kt (see that file for stale .so cleanup logic that should be added there).
36 }
37}
38
39// Native memory-safe PDF renderer (Rust + lopdf). See pdf/src/main/rust/.
40rustNativeLib("pdf_render", "pdf")
41
42dependencies {
43 implementation(libs.androidx.camera.core)
44 implementation(libs.androidx.camera.camera2)
45 implementation(libs.androidx.camera.lifecycle)
46 implementation(libs.androidx.camera.view)
47 implementation(project(":library:image"))
48 implementation(project(":library:ocr"))
49
50 // drawSafePage paints straight onto an android.graphics.Canvas via Typeface/Paint/Matrix,
51 // none of which the unit-test stub android.jar implements — Typeface.create returns null, so
52 // every Text primitive throws before it reaches the render-mode-3 paint guard. Robolectric
53 // supplies a real Skia-backed graphics stack so those tests can assert actual pixels.
54 testImplementation(libs.robolectric)
55}