forked from Kotlin/kotlin-jupyter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
280 lines (223 loc) · 7.75 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import com.github.jengelman.gradle.plugins.shadow.transformers.ComponentsXmlResourceTransformer
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlinx.jupyter.build.getFlag
import org.jetbrains.kotlinx.jupyter.plugin.options
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import ru.ileasile.kotlin.apache2
import ru.ileasile.kotlin.developer
import ru.ileasile.kotlin.githubRepo
plugins {
kotlin("jvm")
kotlin("jupyter.api") apply false
kotlin("plugin.serialization")
id("com.github.johnrengelman.shadow")
id("org.jlleitschuh.gradle.ktlint")
id("org.jetbrains.kotlinx.jupyter.dependencies")
id("ru.ileasile.kotlin.publisher")
id("ru.ileasile.kotlin.doc")
}
extra["isMainProject"] = true
val kotlinVersion: String by project
val kotlinxSerializationVersion: String by project
val ktlintVersion: String by project
val junitVersion: String by project
val slf4jVersion: String by project
val logbackVersion: String by project
val docsRepo: String by project
val taskOptions = project.options()
val deploy: Configuration by configurations.creating
deploy.apply {
exclude("org.jetbrains.kotlinx", "kotlinx-serialization-json-jvm")
exclude("org.jetbrains.kotlinx", "kotlinx-serialization-core-jvm")
}
fun KtlintExtension.setup() {
version.set(ktlintVersion)
enableExperimentalRules.set(true)
}
ktlint {
setup()
filter {
exclude("**/org/jetbrains/kotlinx/jupyter/repl.kt")
}
}
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
ktlint {
setup()
}
}
allprojects {
val stableKotlinLanguageLevel: String by rootProject
val jvmTarget: String by rootProject
tasks.withType<KotlinCompile> {
kotlinOptions {
apiVersion = stableKotlinLanguageLevel
languageVersion = stableKotlinLanguageLevel
this.jvmTarget = jvmTarget
}
}
tasks.withType<JavaCompile> {
sourceCompatibility = jvmTarget
targetCompatibility = jvmTarget
}
}
tasks.withType<KotlinCompile> {
val kotlinLanguageLevel: String by rootProject
kotlinOptions {
languageVersion = kotlinLanguageLevel
apiVersion = kotlinLanguageLevel
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf("-Xskip-prerelease-check")
}
}
dependencies {
// Dependency on module with compiler.
api(project(":shared-compiler"))
fun implKotlin(module: String, version: String? = kotlinVersion) = implementation(kotlin(module, version))
// Standard dependencies
implKotlin("stdlib", null)
implKotlin("reflect", null)
implKotlin("stdlib-jdk8", null)
implementation("org.jetbrains:annotations:20.1.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
// Embedded compiler and scripting dependencies
implKotlin("compiler-embeddable")
implKotlin("scripting-compiler-impl-embeddable")
implKotlin("scripting-compiler-embeddable")
implKotlin("scripting-ide-services")
implKotlin("scripting-dependencies-maven")
implKotlin("script-util")
implKotlin("scripting-common")
// Embedded version of serialization plugin for notebook code
implKotlin("serialization")
// Logging
implementation("org.slf4j:slf4j-api:$slf4jVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
// ZeroMQ library for implementing messaging protocol
implementation("org.zeromq:jeromq:0.5.2")
// Clikt library for parsing output magics
implementation("com.github.ajalt:clikt:2.8.0")
// Serialization implementation for kernel code
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
// Test dependencies: kotlin-test and Junit 5
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testImplementation("io.kotlintest:kotlintest-assertions:3.1.6")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
deploy(project(":lib"))
deploy(project(":api"))
deploy(kotlin("script-runtime", kotlinVersion))
}
tasks.register("publishToPluginPortal") {
group = "publishing"
dependsOn(":kotlin-jupyter-api-gradle-plugin:publishPlugins")
}
tasks.jar {
manifest {
attributes["Main-Class"] = taskOptions.mainClassFQN
attributes["Implementation-Version"] = project.version
}
}
tasks.shadowJar {
archiveBaseName.set(taskOptions.packageName)
archiveClassifier.set("")
mergeServiceFiles()
transform(ComponentsXmlResourceTransformer())
manifest {
attributes(tasks.jar.get().manifest.attributes)
}
}
// Workaround for https://github.com/johnrengelman/shadow/issues/651
components.withType(AdhocComponentWithVariants::class.java).forEach { c ->
c.withVariantsFromConfiguration(project.configurations.shadowRuntimeElements.get()) {
skip()
}
}
tasks.test {
val doParallelTesting = getFlag("test.parallel", true)
maxHeapSize = "2048m"
/**
* Set to true to debug classpath/shadowing issues, see testKlaxonClasspathDoesntLeak test
*/
val useShadowedJar = getFlag("test.useShadowed", false)
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
if (useShadowedJar) {
dependsOn(tasks.shadowJar.get())
classpath = files(tasks.shadowJar.get()) + classpath
}
systemProperties = mutableMapOf(
"junit.jupiter.displayname.generator.default" to "org.junit.jupiter.api.DisplayNameGenerator\$ReplaceUnderscores",
"junit.jupiter.execution.parallel.enabled" to doParallelTesting.toString() as Any,
"junit.jupiter.execution.parallel.mode.default" to "concurrent",
"junit.jupiter.execution.parallel.mode.classes.default" to "concurrent"
)
}
tasks.processResources {
dependsOn(tasks.buildProperties)
}
val createTestResources: Task by tasks.creating {
val jupyterApiVersion: String by project
inputs.property("jupyterApiVersion", jupyterApiVersion)
val outputDir = file(project.buildDir.toPath().resolve("resources").resolve("test"))
outputs.dir(outputDir)
doLast {
outputDir.mkdirs()
val propertiesFile = outputDir.resolve("PUBLISHED_JUPYTER_API_VERSION")
propertiesFile.writeText(jupyterApiVersion)
}
}
tasks.processTestResources {
dependsOn(createTestResources)
}
tasks.check {
if (!getFlag("skipReadmeCheck", false)) {
dependsOn(tasks.checkReadme)
}
}
tasks.publishDocs {
docsRepoUrl.set(docsRepo)
branchName.set("master")
username.set("robot")
email.set("robot@jetbrains.com")
}
kotlinPublications {
packageGroup = "org.jetbrains.kotlinx"
fun prop(name: String) = project.findProperty(name) as? String?
sonatypeSettings(
prop("kds.sonatype.user"),
prop("kds.sonatype.password"),
"kotlin-jupyter project, v. ${project.version}"
)
signingCredentials(
prop("kds.sign.key.id"),
prop("kds.sign.key.private"),
prop("kds.sign.key.passphrase")
)
pom {
githubRepo("Kotlin", "kotlin-jupyter")
inceptionYear.set("2021")
licenses {
apache2()
}
developers {
developer("nikitinas", "Anatoly Nikitin", "Anatoly.Nikitin@jetbrains.com")
developer("ileasile", "Ilya Muradyan", "Ilya.Muradyan@jetbrains.com")
}
}
publication {
publicationName = "kernel"
artifactId = "kotlin-jupyter-kernel"
description = "Kotlin Jupyter kernel published as artifact"
packageName = artifactId
}
}
tasks.named("publishLocal") {
dependsOn(
tasks.condaPackage,
tasks.pyPiPackage,
)
}