-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
347 lines (289 loc) · 10.3 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
347 lines (289 loc) · 10.3 KB
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
import io.github.devcrocod.korro.KorroTask
import org.gradle.jvm.tasks.Jar
import org.intellij.lang.annotations.Language
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
with(convention.plugins) {
alias(kotlinJvm8)
alias(buildConfig)
alias(kodex)
}
with(libs.plugins) {
alias(publisher)
alias(serialization)
alias(korro)
alias(binary.compatibility.validator)
alias(kotlinx.benchmark)
// generates keywords using the :generator module
alias(keywordGenerator)
}
idea
}
group = "org.jetbrains.kotlinx"
kotlin.sourceSets {
main {
kotlin.srcDir("src/generated-dataschema-accessors/main/kotlin/")
}
test {
kotlin.srcDir("src/generated-dataschema-accessors/test/kotlin/")
}
}
sourceSets {
// Gradle creates configurations and compilation task for each source set
create("samples") {
kotlin.srcDir("src/test/kotlin")
}
}
// Separate source set for Java 16+ language-specific tests (e.g., Java Records)
val testJava16 by sourceSets.creating {
java.srcDir("src/testJava16/java")
kotlin.srcDir("src/testJava16/kotlin")
compileClasspath += sourceSets.main.get().output + configurations.testCompileClasspath.get()
runtimeClasspath += output + compileClasspath + configurations.testRuntimeClasspath.get()
}
dependencies {
val kotlinCompilerPluginClasspathSamples by configurations.getting
api(libs.kotlin.reflect)
implementation(libs.kotlin.stdlib)
kotlinCompilerPluginClasspathSamples(projects.plugins.expressionsConverter)
api(libs.commonsCsv)
implementation(libs.commonsIo)
implementation(libs.fastDoubleParser)
implementation(libs.tika)
api(libs.kotlin.datetimeJvm)
implementation(libs.kotlinpoet)
implementation(libs.sl4j)
implementation(libs.kotlinLogging)
testImplementation(libs.junit)
testImplementation(libs.kotestAssertions) {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
// kotest shouldBe forcefully escapes newlines when content is identical except additional newlines
// which makes diff very hard to perceive. CodeGenerationTests.kt suffers from it a lot. using assertEquals there for working diff.
testImplementation(kotlin("test"))
testImplementation(libs.kotlinx.benchmark.runtime)
testImplementation(libs.kotlin.scriptingJvm)
testImplementation(libs.jsoup)
testImplementation(libs.sl4jsimple)
testImplementation(libs.serialization.core)
testImplementation(libs.serialization.json)
// for checking results
testImplementation(libs.commonsStatisticsDescriptive)
// for samples.api
testImplementation(projects.dataframeCsv)
testImplementation(projects.dataframeJson)
testImplementation(projects.dataframeArrow)
testImplementation(projects.dataframeExcel)
// testImplementation(projects.dataframeGeo)
testImplementation(projects.dataframeJdbc)
testImplementation(libs.h2db)
testImplementation(projects.dataframeOpenapiGenerator)
}
// Configure testJava16 dependencies to extend from test
configurations {
val testJava16Implementation by getting {
extendsFrom(configurations.testImplementation.get())
}
val testJava16RuntimeOnly by getting {
extendsFrom(configurations.testRuntimeOnly.get())
}
}
// Configure testJava16 sources to use Java 16+
tasks.named<JavaCompile>("compileTestJava16Java") {
sourceCompatibility = JavaVersion.VERSION_16.toString()
targetCompatibility = JavaVersion.VERSION_16.toString()
options.release.set(16)
}
tasks.named<KotlinCompile>("compileTestJava16Kotlin") {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_16
freeCompilerArgs.add("-Xjdk-release=16")
}
}
benchmark {
targets {
register("test")
}
configurations {
register("sort") {
include("SortingBenchmark")
}
}
}
val samplesImplementation by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}
val compileSamplesKotlin = tasks.named<KotlinCompile>("compileSamplesKotlin") {
tasks.named<KotlinCompile>("compileTestKotlin").get().let {
friendPaths.from(it.friendPaths)
libraries.from(it.libraries)
}
source(sourceSets["test"].kotlin)
destinationDirectory = layout.buildDirectory.dir("classes/testWithOutputs/kotlin")
}
val clearTestResults by tasks.registering(Delete::class, fun Delete.() {
delete(layout.buildDirectory.dir("dataframes"))
delete(layout.buildDirectory.dir("korroOutputLines"))
})
val samplesTest = tasks.register<Test>("samplesTest") {
group = "Verification"
description = "Runs all samples that are used in the documentation, but modified to save their outputs to a file."
dependsOn(compileSamplesKotlin)
dependsOn(clearTestResults)
outputs.upToDateWhen { false }
environment("DATAFRAME_SAVE_OUTPUTS", "")
filter {
includeTestsMatching("org.jetbrains.kotlinx.dataframe.samples.api.*")
}
ignoreFailures = true
testClassesDirs = fileTree("${layout.buildDirectory.get().asFile.path}/classes/testWithOutputs/kotlin")
classpath =
files("${layout.buildDirectory.get().asFile.path}/classes/testWithOutputs/kotlin") +
configurations["samplesRuntimeClasspath"] +
sourceSets["main"].runtimeClasspath
}
val clearSamplesOutputs by tasks.registering {
group = "documentation"
doFirst {
delete {
val generatedSnippets = fileTree(file("../docs/StardustDocs/resources/snippets"))
.exclude("**/manual/**", "**/kdocs/**")
delete(generatedSnippets)
}
}
}
val copySamplesOutputs = tasks.register<JavaExec>("copySamplesOutputs") {
group = "documentation"
mainClass = "org.jetbrains.kotlinx.dataframe.explainer.SampleAggregatorKt"
dependsOn(clearSamplesOutputs)
dependsOn(samplesTest)
classpath = sourceSets.test.get().runtimeClasspath
}
tasks.withType<KorroTask> {
dependsOn(copySamplesOutputs)
}
korro {
docs = fileTree(rootProject.rootDir) {
include("docs/StardustDocs/topics/*.md")
include("docs/StardustDocs/topics/concepts/*.md")
}
samples = fileTree(project.projectDir) {
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/*.kt")
}
outputs = fileTree(project.layout.buildDirectory) {
include("korroOutputLines/*")
}
groupSamples {
beforeSample = "<tab title=\"NAME\">\n"
afterSample = "\n</tab>"
funSuffix("_properties") {
replaceText("NAME", "Properties")
}
funSuffix("_strings") {
replaceText("NAME", "Strings")
}
beforeGroup = "<tabs>\n"
afterGroup = "</tabs>"
}
}
// generateLibrariesJson makes sure a META-INF/kotlin-jupyter-libraries/libraries.json file is generated
// This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook.
val generatedJupyterResourcesDir = layout.buildDirectory.dir("generated/jupyter")
val generateLibrariesJson by tasks.registering {
val outDir = generatedJupyterResourcesDir.get().asFile.resolve("META-INF/kotlin-jupyter-libraries")
val outFile = outDir.resolve("libraries.json")
outputs.file(outFile)
inputs.property("version", project.version)
doLast {
outDir.mkdirs()
@Language("json")
val content =
"""
{
"descriptors": [
{
"init": [
"USE { dependencies(\"org.jetbrains.kotlinx:dataframe-jupyter:${project.version}\") }"
]
}
]
}
""".trimIndent()
outFile.delete()
outFile.writeText(content)
logger.lifecycle("generated META-INF/kotlin-jupyter-libraries/libraries.json for :core")
}
}
// If `includeCoreLibrariesJson` is set, modify the processResources task such that it includes
// a META-INF libraries.json file.
// This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook.
// This is usually only done when publishing.
tasks.processResources {
if (project.hasProperty("includeCoreLibrariesJson")) {
dependsOn(generateLibrariesJson)
from(generatedJupyterResourcesDir) {
into("") // keep META-INF/... structure as generated
}
doLast {
logger.lifecycle("$this includes generated META-INF/kotlin-jupyter-libraries/libraries.json")
}
}
}
tasks.withType<Jar> {
mustRunAfter(tasks.generateKeywordsSrc)
}
tasks.processKDocsMain {
dependsOn(tasks.generateKeywordsSrc, tasks.generateBuildConfigClasses)
}
tasks.runKtlintFormatOverMainSourceSet {
dependsOn(tasks.generateKeywordsSrc)
}
tasks.runKtlintFormatOverTestSourceSet {
dependsOn(tasks.generateKeywordsSrc)
}
tasks.runKtlintFormatOverGeneratedMainSourcesSourceSet {
dependsOn(tasks.generateKeywordsSrc)
}
tasks.runKtlintCheckOverMainSourceSet {
dependsOn(tasks.generateKeywordsSrc)
}
tasks.runKtlintCheckOverTestSourceSet {
dependsOn(tasks.generateKeywordsSrc)
}
tasks.runKtlintCheckOverGeneratedMainSourcesSourceSet {
dependsOn(tasks.generateKeywordsSrc)
}
tasks.withType<KotlinCompile> {
compilerOptions {
optIn.addAll("kotlin.RequiresOptIn")
freeCompilerArgs.addAll("-Xinline-classes")
freeCompilerArgs.addAll("-jvm-default=no-compatibility")
}
}
tasks.test {
maxHeapSize = "1g"
// Arrow's off-heap allocator needs deep reflection into java.nio.
jvmArgs("--add-opens", "java.base/java.nio=ALL-UNNAMED")
}
// Test task for Java 16+ language-specific tests
val testJava16Task = tasks.register<Test>("testJava16") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
testClassesDirs = testJava16.output.classesDirs
classpath = testJava16.runtimeClasspath
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
maxHeapSize = "2048m"
}
tasks.check {
dependsOn(testJava16Task)
}
kotlinPublications {
publication {
publicationName = "core"
artifactId = "dataframe-core"
description = "Dataframe core API"
packageName = artifactId
}
}