/
build.gradle.kts
196 lines (165 loc) · 6.42 KB
/
build.gradle.kts
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
* Copyright (c) 2021. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
import java.time.LocalDateTime
plugins {
kotlin("multiplatform")
`maven-publish`
signing
id("org.jetbrains.dokka")
}
val publicVersion: String = "3.2.0"
val currentYear: Int = LocalDateTime.now().getYear()
tasks.dokkaHtml {
moduleName.set("Lets-Plot-Kotlin v$publicVersion")
outputDirectory.set(File("$projectDir/../docs/api-reference"))
pluginsMapConfiguration.set(mapOf("org.jetbrains.dokka.base.DokkaBase" to """{ "footerMessage": "Copyright © 2019-$currentYear JetBrains s.r.o." }"""))
dokkaSourceSets {
configureEach {
skipDeprecated.set(true)
}
}
}
@Suppress("PropertyName")
val kotlinLogging_version: String by project
@Suppress("PropertyName")
val lets_plot_version: String by project
val datetime_version: String by project
kotlin {
jvm()
js(BOTH) {
browser()
}
sourceSets {
commonMain {
dependencies {
implementation("io.github.microutils:kotlin-logging:$kotlinLogging_version")
api("org.jetbrains.lets-plot:base-portable:$lets_plot_version")
api("org.jetbrains.lets-plot:plot-base-portable:$lets_plot_version")
api("org.jetbrains.lets-plot:plot-common-portable:$lets_plot_version")
api("org.jetbrains.lets-plot:plot-builder-portable:$lets_plot_version")
api("org.jetbrains.lets-plot:plot-config-portable:$lets_plot_version")
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$datetime_version")
}
}
val jvmMain by getting {
dependencies {
api("org.jetbrains.lets-plot:lets-plot-common:$lets_plot_version")
// Use "-jvm" variant to work around the issue where LPK JS (IR) artefact becomes dependent on
// the "kotlinx-datetime".
// See also:
// https://youtrack.jetbrains.com/issue/KT-52812/JSIR-compiler-error-Could-not-find-orgjetbrainskotlinxkotlinx-datetime-in-USERLibraryApplication-Supportkotlindaemon
compileOnly("org.jetbrains.kotlinx:kotlinx-datetime-jvm:$datetime_version")
compileOnly("org.jetbrains.lets-plot:lets-plot-batik:$lets_plot_version")
compileOnly("org.jetbrains.lets-plot:lets-plot-jfx:$lets_plot_version")
compileOnly("org.jetbrains.lets-plot:lets-plot-image-export:$lets_plot_version")
}
}
}
}
val artifactBaseName = "lets-plot-kotlin"
val artifactGroupId = project.group as String
val artifactVersion = project.version as String
val jarJavaDocs by tasks.creating(Jar::class) {
archiveClassifier.set("javadoc")
group = "lets plot"
from("$rootDir/README.md")
}
afterEvaluate {
publishing {
publications {
// Build artifact "lets-plot-kotlin-kernel" with no dependencies in POM.
create<MavenPublication>("letsPlotKotlinKernel") {
artifactId = "$artifactBaseName-kernel"
val jvmJar: Task by tasks
val jvmSourcesJar: Task by tasks
artifact(jvmJar)
artifact(jvmSourcesJar)
pom {
name.set("Lets-Plot Kotlin API (for Jupyter Kotlin Kernel)")
description.set("Lets-Plot Kotlin API without dependencies.")
}
}
}
publications.forEach {
with(it as MavenPublication) {
groupId = artifactGroupId
version = artifactVersion
if (!artifactId.startsWith(artifactBaseName)) {
// Default multiplatform artifacts: rename.
artifactId = artifactId.replace(project.name, artifactBaseName)
pom {
name.set("Lets-Plot Kotlin API")
description.set("Lets-Plot Kotlin API.")
}
}
// Add "javadocs" to each publication or Maven won't publish it.
artifact(jarJavaDocs)
pom {
url.set("https://github.com/JetBrains/lets-plot-kotlin")
licenses {
license {
name.set("MIT")
url.set("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/LICENSE")
}
}
developers {
developer {
id.set("jetbrains")
name.set("JetBrains")
email.set("lets-plot@jetbrains.com")
}
}
scm {
url.set("https://github.com/JetBrains/lets-plot-kotlin")
}
}
// Sign all publications.
signing.sign(it)
}
}
repositories {
maven {
val sonatypeUrl: String by extra
url = uri(sonatypeUrl)
val buildSettings: Map<String, Any?> by project
@Suppress("UNCHECKED_CAST")
val sonatype = (buildSettings["sonatype"] as? Map<String, String?>) ?: emptyMap()
credentials {
username = sonatype["username"]
password = sonatype["password"]
}
}
mavenLocal {
val localMavenRepository: String by project
url = uri(localMavenRepository)
}
}
}
}
tasks {
// Store versions in properties to later access at runtime.
val saveVersions by creating {
doLast {
File("${projectDir}/src/jvmMain/resources/letsPlotKotlinAPI/", "version.properties").writeText(
"""
lets_plot.version=$lets_plot_version
lets_plot_kotlin_api.version=${project.version}
""".trimIndent()
)
}
}
//compileKotlin.dependsOn += saveVersions
val jvmMainClasses by getting {
dependsOn += saveVersions
}
}
//task printIt {
// print("${project.name}: ${uri(project.localMavenRepository)}")
//}