-
Notifications
You must be signed in to change notification settings - Fork 66
/
build.gradle.kts
258 lines (227 loc) · 8.21 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.gmazzo.buildconfig.BuildConfigExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlinx.dataframe.AnyFrame
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.api.filter
import org.jetbrains.kotlinx.dataframe.api.print
import org.jetbrains.kotlinx.dataframe.api.select
import org.jetbrains.kotlinx.dataframe.io.readJson
import org.jetbrains.kotlinx.publisher.apache2
import org.jetbrains.kotlinx.publisher.developer
import org.jetbrains.kotlinx.publisher.githubRepo
import org.jlleitschuh.gradle.ktlint.KtlintExtension
plugins {
with(libs.plugins) {
alias(kotlin.jvm)
alias(publisher)
alias(serialization) apply false
alias(jupyter.api) apply false
alias(dokka)
alias(kover)
alias(ktlint)
alias(korro) apply false
alias(docProcessor) apply false
alias(simpleGit) apply false
alias(dependencyVersions)
alias(buildconfig) apply false
// dependence on our own plugin
alias(dataframe) apply false
alias(ksp) apply false
}
}
val jupyterApiTCRepo: String by project
val projectName: String by project
repositories {
mavenLocal()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
maven(jupyterApiTCRepo)
}
configurations {
testImplementation.get().extendsFrom(compileOnly.get())
}
dependencies {
api(project(":core"))
api(project(":dataframe-arrow"))
api(project(":dataframe-excel"))
api(project(":dataframe-openapi"))
api(project(":dataframe-jdbc"))
// TODO enable when it leaves the experimental phase
// api(project(":dataframe-csv"))
kover(project(":core"))
kover(project(":dataframe-arrow"))
kover(project(":dataframe-excel"))
kover(project(":dataframe-openapi"))
kover(project(":dataframe-jdbc"))
kover(project(":dataframe-csv"))
kover(project(":plugins:kotlin-dataframe"))
}
enum class Version : Comparable<Version> {
SNAPSHOT,
DEV,
ALPHA,
BETA,
RC,
STABLE,
}
fun String.findVersion(): Version {
val version = this.lowercase()
return when {
"snapshot" in version -> Version.SNAPSHOT
"dev" in version -> Version.DEV
"alpha" in version -> Version.ALPHA
"beta" in version -> Version.BETA
"rc" in version -> Version.RC
else -> Version.STABLE
}
}
// these names of outdated dependencies will not show up in the table output
val dependencyUpdateExclusions = listOf(
// TODO Requires more work to be updated to 1.7.0+, https://github.com/Kotlin/dataframe/issues/594
libs.plugins.kover.get().pluginId,
// TODO 5.8.0 is not possible due to https://github.com/Kotlin/dataframe/issues/595
libs.kotestAssertions.get().name,
// Can't be updated to 7.4.0+ due to Java 8 compatibility
libs.android.gradle.api.get().group,
// Directly dependent on the Gradle version
"org.gradle.kotlin.kotlin-dsl",
// Can't be updated to 2.1.0+ due to Java 8 compatibility
libs.plugins.simpleGit.get().pluginId,
)
// run `./gradlew dependencyUpdates` to check for updates
tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
checkForGradleUpdate = true
outputFormatter = "json,html"
revision = "milestone"
rejectVersionIf {
val current = currentVersion.findVersion()
val candidate = candidate.version.findVersion()
candidate < current
}
doLast {
val outputFile = layout.buildDirectory
.file("../$outputDir/$reportfileName.json")
.get().asFile
when (val outDatedDependencies = DataFrame.readJson(outputFile)["outdated"]["dependencies"][0]) {
is AnyFrame -> {
val df = outDatedDependencies.select {
cols("group", "name", "version") and {
"available"["milestone"] named "newVersion"
}
}.filter { "name"() !in dependencyUpdateExclusions && "group"() !in dependencyUpdateExclusions }
logger.warn("Outdated dependencies found:")
df.print(
rowsLimit = Int.MAX_VALUE,
valueLimit = Int.MAX_VALUE,
borders = true,
title = true,
alignLeft = true,
)
}
else -> logger.info("No outdated dependencies found")
}
}
}
kotlin.jvmToolchain(11)
allprojects {
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
// Attempts to configure ktlint for each sub-project that uses the plugin
afterEvaluate {
try {
configure<KtlintExtension> {
version = "1.4.1"
// rules are set up through .editorconfig
}
} catch (_: UnknownDomainObjectException) {
logger.warn("Could not set ktlint config on :${this.name}")
}
// set the java toolchain version to 11 for all subprojects for CI stability
extensions.findByType<KotlinJvmProjectExtension>()?.jvmToolchain(11)
// Attempts to configure buildConfig for each sub-project that uses it
try {
configure<BuildConfigExtension> {
packageName = "org.jetbrains.kotlinx.dataframe"
className = "BuildConfig"
buildConfigField("VERSION", "${project.version}")
buildConfigField("DEBUG", findProperty("kotlin.dataframe.debug")?.toString()?.toBoolean() ?: false)
}
} catch (_: UnknownDomainObjectException) {
logger.warn("Could not set buildConfig on :${this.name}")
}
}
}
group = "org.jetbrains.kotlinx"
fun detectVersion(): String {
val buildNumber = rootProject.findProperty("build.number") as String?
val versionProp = property("version") as String
return if (hasProperty("release")) {
versionProp
} else if (buildNumber != null) {
if (rootProject.findProperty("build.number.detection") == "true") {
"$versionProp-dev-$buildNumber"
} else {
error("use build.number + build.number.detection = true or release build")
}
} else {
"$versionProp-dev"
}
}
val detectVersionForTC by tasks.registering {
doLast {
println("##teamcity[buildNumber '$version']")
}
}
version = detectVersion()
println("Current DataFrame version: $version")
subprojects {
this.version = rootProject.version
}
kotlinPublications {
fairDokkaJars = false
sonatypeSettings(
project.findProperty("kds.sonatype.user") as String?,
project.findProperty("kds.sonatype.password") as String?,
"dataframe project, v. ${project.version}",
)
signingCredentials(
project.findProperty("kds.sign.key.id") as String?,
project.findProperty("kds.sign.key.private") as String?,
project.findProperty("kds.sign.key.passphrase") as String?,
)
pom {
githubRepo("Kotlin", "dataframe")
inceptionYear = "2021"
licenses {
apache2()
}
developers {
developer("koperagen", "Nikita Klimenko", "nikita.klimenko@jetbrains.com")
developer("Jolanrensen", "Jolan Rensen", "jolan.rensen@jetbrains.com")
developer("zaleslaw", "Aleksei Zinovev", "aleksei.zinovev@jetbrains.com")
developer("ermolenkodev", "Nikita Ermolenko", "nikita.ermolenko@jetbrains.com")
developer("nikitinas", "Anatoly Nikitin", "anatoly.nikitin@jetbrains.com")
}
}
publication {
publicationName = "api"
artifactId = projectName
description = "Data processing in Kotlin"
packageName = artifactId
}
localRepositories {
maven {
url = project.file(layout.buildDirectory.dir("maven")).toURI()
}
}
}