Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
310 lines (273 loc) · 10.5 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
310 lines (273 loc) · 10.5 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
import io.github.devcrocod.korro.KorroGenerateTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.kotlin.dsl.libs
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Files
import kotlin.io.path.div
import kotlin.io.path.name
plugins {
with(conventions.plugins.dfbuild) {
alias(kotlinJvm11)
alias(ktlint)
}
with(libs.plugins) {
alias(korro)
alias(dataframe.compiler.plugin)
}
}
val dependentProjects = with(projects) {
listOf(
core,
dataframeArrow,
dataframeExcel,
dataframeJdbc,
dataframeCsv,
dataframeJson,
dataframeOpenapi,
dataframeOpenapiGenerator,
)
}.map { project(it.path) }
tasks.withType<KotlinCompile> {
dependentProjects.forEach {
dependsOn("${it.path}:jar")
}
}
tasks.withType<KotlinCompile>().configureEach {
friendPaths.from(project(projects.core.path).projectDir)
}
// get the output of the instrumentedJars configuration, aka the jar-files of the compiled modules
// all modules with jar-task have this artifact in the DataFrame project
val dependentProjectJarPaths = dependentProjects.map {
it.configurations
.getByName("instrumentedJars")
.artifacts.single()
.file.absolutePath
.replace(File.separatorChar, '/')
}
dependencies {
runtimeOnly(projects.dataframe) // Must depend on jars for the compiler plugin to work!
implementation(files(dependentProjectJarPaths))
// include api() dependencies from dependent projects, as they are not included in the jars
dependentProjects.forEach {
it.configurations.getByName("api").dependencies.forEach { dep ->
if (dep is ExternalModuleDependency) {
implementation("${dep.group}:${dep.name}:${dep.version ?: "+"}")
}
}
}
testImplementation(libs.junit)
testImplementation(libs.kotestAssertions) {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
testImplementation(libs.kandy) {
exclude("org.jetbrains.kotlinx", "dataframe")
}
testImplementation(libs.kandy.samples.utils) {
exclude("org.jetbrains.kotlinx", "dataframe")
}
testImplementation(libs.konsist)
testImplementation(libs.kotlin.datetimeJvm)
testImplementation(libs.poi)
testImplementation(libs.arrow.vector)
testImplementation(libs.hikaricp)
}
// Running tests creates korro output lines!
tasks.withType<KorroGenerateTask>().configureEach {
dependsOn(tasks.test)
}
korro {
// TODO(#898)
// Should work without "missing" errors
// after migration all test sample to :samples module
behavior {
ignoreMissing = true
}
docs {
from(
fileTree(rootProject.file("docs/StardustDocs/topics")) {
include("DataSchema-Data-Classes-Generation.md")
include("read.md")
include("readSqlFromCustomDatabase.md")
include("write.md")
include("rename.md")
include("require.md")
include("format.md")
include("parse.md")
include("toHTML.md")
include("guides/*.md")
include("concepts/*.md")
include("io/*.md")
include("schemas/*.md")
include("operations/utils/*.md")
include("operations/multiple/*.md")
include("operations/column/*.md")
include("collectionsInterop/*.md")
include("dataSources/*.md")
include("dataSources/sql/*.md")
include("readSqlDatabases.md")
include("info/*.md")
include("columnArithmetics.md")
include("convert.md")
include("convertTo.md")
include("ColumnSelectors.md")
include("append.md")
include("appendNulls.md")
include("create.md")
include("createColumn.md")
include("createDataFrame.md")
include("concat.md")
include("cast.md")
include("concatDf.md")
include("groupBy.md")
include("inferType.md")
include("map.md")
include("merge.md")
include("iterate.md")
include("pivot.md")
include("countDistinct.md")
include("fill.md")
include("drop.md")
include("duplicate.md")
include("filter.md")
include("getColumn.md")
include("getRow.md")
include("toList.md")
include("count.md")
include("valueCounts.md")
include("sliceRows.md")
include("head.md")
include("sum.md")
include("mean.md")
include("std.md")
include("cumSum.md")
include("median.md")
include("percentile.md")
include("split.md")
include("MigrationTo_1_0.md")
include("single.md")
include("indexing.md")
include("unfold.md")
include("replace.md")
include("reorder.md")
include("values.md")
include("operations.md")
},
)
baseDir = rootProject.file("docs/StardustDocs/topics")
}
samples {
from(
fileTree(project.projectDir) {
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/utils/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/multiple/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/render/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/collectionsInterop/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/column/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/info/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/guides/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/concepts/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/io/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/io/jdbc/*.kt")
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/schemas/*.kt")
},
)
outputs.from(
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")
}
funSuffix("_kotlin") {
replaceText("NAME", "Kotlin")
}
funSuffix("_java") {
replaceText("NAME", "Java")
}
beforeGroup = "<tabs>\n"
afterGroup = "</tabs>"
}
}
tasks.test {
maxHeapSize = "4g"
jvmArgs = listOf("--add-opens", "java.base/java.nio=ALL-UNNAMED")
}
val resourcesDir = rootProject.file("docs/StardustDocs/resources")
val mdFile = rootProject.file("docs/StardustDocs/topics/_shadow_resources.md")
tasks.register("updateShadowResources") {
group = "documentation"
description = "Updates _shadow_resources.md with resource tags for all files in resources directory"
val ignore = listOf(".DS_Store")
doLast {
val resourceFiles = Files.walk(resourcesDir.toPath())
.filter { Files.isRegularFile(it) && it.name !in ignore }
.sorted()
.toList()
val content = resourceFiles.joinToString("\n") { file ->
"""<resource src="${file.name}"></resource>"""
}
mdFile.writeText(content)
}
}
// datasets from the root `data/` folder that are used in the docs
val docsDatasets = listOf(
"movies.csv",
"jetbrains_repositories.csv",
"titanic.csv",
)
tasks.register<Copy>("syncDocsDatasets") {
group = "documentation"
description = "Copies datasets used in the docs from data/ to docs/StardustDocs/resources/datasets"
from(rootProject.file("data")) {
include(docsDatasets)
}
into(resourcesDir.toPath() / "datasets")
}
// region fail fast source dependency on :core
val coreProjectPath = projects.core.path
val compilerPluginClasspaths = configurations.matching {
it.name in setOf("compileClasspath", "testCompileClasspath")
}
val configurationsThatAffectCompilerPluginResolve = setOf("api", "implementation", "compileOnly", "compileOnlyApi")
fun Configuration.coreDependencyPath(visited: MutableSet<Configuration> = mutableSetOf()): List<String>? {
if (!visited.add(this)) return null
dependencies.filterIsInstance<ProjectDependency>().forEach { dependency ->
if (dependency.path == coreProjectPath) return listOf(coreProjectPath)
rootProject.project(dependency.path).configurations
.filter { it.name in configurationsThatAffectCompilerPluginResolve }
.forEach { configuration ->
configuration.coreDependencyPath(visited)?.let {
return listOf("${dependency.path}:${configuration.name}") + it
}
}
}
extendsFrom.forEach { configuration ->
configuration.coreDependencyPath(visited)?.let {
return listOf("${project.path}:${configuration.name}") + it
}
}
return null
}
gradle.projectsEvaluated {
compilerPluginClasspaths.forEach {
val dependencyPath = it.coreDependencyPath()
require(dependencyPath == null) {
val fullDependencyPath = listOf("${project.path}:${it.name}") + dependencyPath.orEmpty()
"Module ${project.path} with DataFrame compiler plugin cannot use source dependency $coreProjectPath " +
"on $it. Dependency path: ${fullDependencyPath.joinToString(" -> ")}. " +
"Depend on the prebuilt instrumentedJars artifact instead."
}
}
}
// endregion