summaryrefslogtreecommitdiff
path: root/modules/orgflow-ui/build.gradle.kts
blob: 493ba19fd5c954f3a5ce07bb1e3fd54f2a86bacd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import java.util.Base64

plugins {
    alias(libs.plugins.kotlin.multiplatform)
    alias(libs.plugins.android.library)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.compose.multiplatform)
}

group = "net.kukuri"
version = "0.1.0"

kotlin {
    jvm()

    androidTarget {
        compilations.all {
            kotlinOptions { jvmTarget = "17" }
        }
    }

    @OptIn(ExperimentalWasmDsl::class)
    wasmJs { browser(); binaries.executable() }

    sourceSets {
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.ui)
            implementation(compose.components.resources)
            // Calendar month/week/year grid used by the Calendar frame (2.22).
            // kizitonwose/Calendar 2.7.0 is built against kotlinx-datetime 0.6.2, but this
            // project uses 0.7.1 (where YearMonth was introduced). Gradle's default conflict
            // resolution picks 0.6.2, which has no YearMonth, so the UI fails to compile.
            // The resolutionStrategy below forces the whole graph to 0.7.1.
            implementation(libs.calendar)
            implementation(libs.datetime)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
            implementation(libs.coroutines.test)
        }
        wasmJsMain {
            resources.srcDir(layout.buildDirectory.dir("webfontExtra"))
        }
    }
}

android {
    namespace = "net.kukuri.orgflow.ui"
    compileSdk = 35
    defaultConfig { minSdk = 24 }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    lint {
        checkReleaseBuilds = false
        abortOnError = false
    }
}

// The deploy server's FTP forbids MKD, so nested composeResources never reach
// the web root. Bundle the Japanese font as a flat webfont.js served from
// memory via the fetch shim in index.html.
val generateWebFontJs by tasks.registering {
    val src = file("src/commonMain/composeResources/font/zenkakugothicnew_regular.ttf")
    val out = layout.buildDirectory.file("webfontExtra/webfont.js")
    inputs.file(src)
    outputs.file(out)
    doLast {
        val b64 = Base64.getEncoder().encodeToString(src.readBytes())
        val target = out.get().asFile
        target.parentFile.mkdirs()
        target.writeText(
            "window.__orgflowFontB64=\"" + b64 + "\";" +
                "window.__orgflowFontBlobs=(function(){" +
                "var bin=atob(window.__orgflowFontB64);" +
                "var u8=new Uint8Array(bin.length);" +
                "for(var i=0;i<bin.length;i++){u8[i]=bin.charCodeAt(i);}" +
                "return {'zenkakugothicnew_regular.ttf':u8};})();",
        )
    }
}

tasks.named("wasmJsProcessResources") {
    dependsOn(generateWebFontJs)
}