aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
blob: 4f83c4b7b5af4b0aabeddd1cb44cb21a3bc3596b (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
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.3.2"))
    implementation(npm("style-loader", "1.0.1"))
    implementation(npm("less", "3.10.3"))
    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", "5.0.2"))
    implementation(npm("url-loader", "3.0.0"))
    implementation(npm("jquery", "^3.5.0"))
    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 {
    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"
        )
        multiplatform {
            val js by creating {
                includes = listOf("Module.md")
                reportUndocumented = false
            }
        }
    }
}