aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
blob: 05c6df5f9c031e1e579ea3aac4d0ad55c59789de (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
buildscript {
    extra.set("production", (findProperty("prod") ?: findProperty("production") ?: "false") == "true")
}

plugins {
    val kotlinVersion: String by System.getProperties()
    id("kotlinx-serialization") version kotlinVersion
    kotlin("js")
    id("maven-publish")
    val dokkaVersion: String by System.getProperties()
    id("org.jetbrains.dokka") version dokkaVersion
}

repositories()

// Versions
val kotlinVersion: String by System.getProperties()
val serializationVersion: String by project
val coroutinesVersion: String by project
val snabbdomKotlinVersion: String by project
val navigoKotlinVersion: String by project
val jqueryKotlinVersion: String by project

// Custom Properties
val webDir = file("src/main/web")

kotlin {
    kotlinJsTargets()
}

dependencies {
    implementation(kotlin("stdlib-js"))
    api(project(":kvision-modules:kvision-common-types"))
    api("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion")
    api("com.github.snabbdom:snabbdom-kotlin:$snabbdomKotlinVersion")
    api("pl.treksoft:navigo-kotlin:$navigoKotlinVersion")
    api("pl.treksoft:jquery-kotlin:$jqueryKotlinVersion")
    implementation(npm("css-loader", "^3.5.2"))
    implementation(npm("style-loader", "^1.1.4"))
    implementation(npm("less", "^3.11.1"))
    implementation(npm("less-loader", "^5.0.0"))
    implementation(npm("imports-loader", "^0.8.0"))
    implementation(npm("uglifyjs-webpack-plugin", "^2.2.0"))
    implementation(npm("file-loader", "^6.0.0"))
    implementation(npm("url-loader", "^4.1.0"))
    implementation(npm("jquery", "^3.4.1"))
    implementation(npm("fecha", "^4.2.0"))
    implementation(npm("snabbdom", "^0.7.4"))
    implementation(npm("snabbdom-virtualize", "^0.7.0"))
    implementation(npm("jquery-resizable-dom", "^0.35.0"))
    implementation(npm("navigo", "^7.1.2"))
    testImplementation(kotlin("test-js"))
}

val sourcesJar by tasks.registering(Jar::class) {
    archiveClassifier.set("sources")
    from(kotlin.sourceSets.main.get().kotlin)
}

publishing {
    publications {
        create<MavenPublication>("kotlin") {
            from(components["kotlin"])
            artifact(tasks["sourcesJar"])
            pom {
                defaultPom()
            }
        }
    }
}

setupPublication()

fun copyResources() {
    copy {
        from("$buildDir/processedResources/Js/main")
        into("${rootProject.buildDir}/js/packages/kvision/kotlin")
    }
    copy {
        from("$buildDir/processedResources/Js/main")
        into("${rootProject.buildDir}/js/packages/kvision/kotlin-dce")
    }
}

tasks {
    /*
    // Forcing specific npm package versions (not required at the moment but commented for future use)
    withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask> {
        doLast {
            yarnLock.parentFile.resolve("package.json").apply {
                writeText(readText().replace(
                    "\"dependencies\": {},",
                    "\"dependencies\": {},\n  \"resolutions\": { \"jquery\": \"3.4.1\" },"
                ))
            }
            org.jetbrains.kotlin.gradle.targets.js.yarn.YarnWorkspaces()
                .yarnExec(project, yarnLock.parentFile, "Relaunching Yarn to fix resolutions")
        }
    }
    */
    getByName("JsJar", Jar::class) {
        from("${project.buildDir}/js/packages/kvision/package.json")
    }
    getByName("compileTestKotlinJs") {
        doLast {
            copyResources()
        }
    }
    getByName("processDceKotlinJs") {
        doLast {
            copyResources()
        }
    }
    val dokka by getting(org.jetbrains.dokka.gradle.DokkaTask::class) {
        outputFormat = "html"
        outputDirectory = "$buildDir/kdoc"
        subProjects = listOf(
            "kvision-bootstrap",
            "kvision-bootstrap-css",
            "kvision-bootstrap-datetime",
            "kvision-bootstrap-dialog",
            "kvision-bootstrap-select",
            "kvision-bootstrap-select-remote",
            "kvision-bootstrap-spinner",
            "kvision-bootstrap-typeahead",
            "kvision-bootstrap-typeahead-remote",
            "kvision-bootstrap-upload",
            "kvision-common-annotations",
            "kvision-common-remote",
            "kvision-common-types",
            "kvision-chart",
            "kvision-cordova",
            "kvision-datacontainer",
            "kvision-electron",
            "kvision-event-flow",
            "kvision-fontawesome",
            "kvision-handlebars",
            "kvision-i18n",
            "kvision-maps",
            "kvision-moment",
            "kvision-pace",
            "kvision-redux",
            "kvision-redux-kotlin",
            "kvision-richtext",
            "kvision-tabulator",
            "kvision-tabulator-remote",
            "kvision-server-javalin",
            "kvision-server-vertx",
            "kvision-toast"
        )
        multiplatform {
            val js by creating {
                includes = listOf("Module.md")
                reportUndocumented = false
            }
        }
    }
}