-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsettings.gradle.kts
More file actions
329 lines (277 loc) · 11 KB
/
settings.gradle.kts
File metadata and controls
329 lines (277 loc) · 11 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
/*
* Copyright (C) 2022 Dremio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Locale
import java.util.Properties
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
throw GradleException("Build requires Java 11")
}
val baseVersion = file("version.txt").readText().trim()
pluginManagement {
repositories {
mavenCentral() // prefer Maven Central, in case Gradle's repo has issues
gradlePluginPortal()
if (System.getProperty("withMavenLocal").toBoolean()) {
mavenLocal()
}
}
}
plugins { id("com.gradle.develocity") version ("4.4.1") }
develocity {
if (System.getenv("CI") != null) {
buildScan {
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
// Add some potentially interesting information from the environment
listOf(
"GITHUB_ACTION_REPOSITORY",
"GITHUB_ACTOR",
"GITHUB_BASE_REF",
"GITHUB_HEAD_REF",
"GITHUB_JOB",
"GITHUB_REF",
"GITHUB_REPOSITORY",
"GITHUB_RUN_ID",
"GITHUB_RUN_NUMBER",
"GITHUB_SHA",
"GITHUB_WORKFLOW",
)
.forEach { e ->
val v = System.getenv(e)
if (v != null) {
value(e, v)
}
}
val ghUrl = System.getenv("GITHUB_SERVER_URL")
if (ghUrl != null) {
val ghRepo = System.getenv("GITHUB_REPOSITORY")
val ghRunId = System.getenv("GITHUB_RUN_ID")
link("Summary", "$ghUrl/$ghRepo/actions/runs/$ghRunId")
link("PRs", "$ghUrl/$ghRepo/pulls")
}
}
} else {
buildScan { publishing { onlyIf { gradle.startParameter.isBuildScan } } }
}
}
rootProject.name = "NesQuEIT"
gradle.beforeProject {
version = baseVersion
group = "org.projectnessie.integrations-tools-tests"
}
val ideSyncActive =
System.getProperty("idea.sync.active").toBoolean() ||
System.getProperty("eclipse.product") != null ||
gradle.startParameter.taskNames.any { it.startsWith("eclipse") }
// Make nessie.integrationsTesting.*SourceTree absolute paths
fun projectCanonicalPath(sub: String): File {
val property = "nessie.integrationsTesting.${sub}SourceTree"
val projectDir =
rootProject.projectDir.resolve(System.getProperty(property, "./included-builds/$sub"))
val canonicalDir = projectDir.canonicalFile
if (ideSyncActive) {
val additionalPropertiesDir = file("$canonicalDir/build")
additionalPropertiesDir.mkdirs()
val additionalPropertiesFile = file("$additionalPropertiesDir/additional-build.properties")
val additionalProperties = Properties()
additionalProperties.putAll(
System.getProperties().filter { e -> e.key.toString().startsWith("nessie.") }
)
additionalPropertiesFile.writer().use { writer ->
additionalProperties.store(writer, "Generated")
}
}
return canonicalDir
}
val frameworksVersions = loadProperties(file("frameworks-versions.properties"))
val nessieMajorVersion = majorVersion(System.getProperty("nessie.versionNessie", "999.99"))
val icebergMajorVersion = majorVersion(System.getProperty("nessie.versionIceberg", "999.99"))
val includeNessieBuild = System.getProperty("nessie.versionNessie") == null
val includeIcebergBuild = System.getProperty("nessie.versionIceberg") == null
val sparkVersions = frameworksVersions["sparkVersions"].toString().split(",").map { it.trim() }
val sparkRestrictionsForNessie = versionConstraints("spark", "nessie", nessieMajorVersion)
val sparkRestrictionsForIceberg = versionConstraints("spark", "iceberg", icebergMajorVersion)
val sparkRestrictions = versionRestrictions(sparkRestrictionsForNessie, sparkRestrictionsForIceberg)
updateDefaultVersion(sparkRestrictions, "spark")
// The Iceberg build works only against one Scala version. So if the Iceberg build is included,
// we have to restrict the integration tests to the same Scala version.
val scalaVersion = System.getProperty("scalaVersion", "2.12")!!
val scalaRestrictionsForSourceBuild = if (includeIcebergBuild) setOf(scalaVersion) else setOf()
val scalaRestrictionsForNessie = versionConstraints("scala", "nessie", nessieMajorVersion)
val scalaRestrictionsForIceberg = versionConstraints("scala", "iceberg", icebergMajorVersion)
val scalaRestrictions =
versionRestrictions(
versionRestrictions(scalaRestrictionsForNessie, scalaRestrictionsForIceberg),
scalaRestrictionsForSourceBuild,
)
updateDefaultVersion(scalaRestrictions, "scala")
// Iceberg source builds require Flink artifacts. But there are no Flink artifacts for Scala 2.13
// at the moment, so exclude everything of Flink when using an Iceberg source build and Scala 2.13.
val flinkVersions =
if (includeIcebergBuild && scalaVersion != "2.12") listOf()
else frameworksVersions["flinkVersions"].toString().split(",").map { it.trim() }
val flinkRestrictions = versionConstraints("flink", "iceberg", icebergMajorVersion)
updateDefaultVersion(flinkRestrictions, "flink")
val prestoVersions = frameworksVersions["prestoVersions"].toString().split(",").map { it.trim() }
val prestoRestrictions = versionConstraints("presto", "iceberg", icebergMajorVersion)
updateDefaultVersion(prestoRestrictions, "presto")
val nessieSourceDir = projectCanonicalPath("nessie")
val icebergSourceDir = projectCanonicalPath("iceberg")
file("build").mkdirs()
file("build/frameworks-versions-effective.properties").writer().use {
frameworksVersions.store(it, "Effective frameworks-versions.properties")
}
System.err.println(
"""
Nessie major version: $nessieMajorVersion (included: $includeNessieBuild)
Iceberg major version: $icebergMajorVersion (included: $includeIcebergBuild)
Spark restrictions: $sparkRestrictions
via Nessie: $sparkRestrictionsForNessie
via Iceberg: $sparkRestrictionsForIceberg
Scala restrictions: $scalaRestrictions
via Nessie: $scalaRestrictionsForNessie
via Iceberg: $scalaRestrictionsForIceberg
for Source build: $scalaRestrictionsForSourceBuild
Flink restrictions: $flinkRestrictions
Presto restrictions: $prestoRestrictions
"""
.trimIndent()
)
fun updateDefaultVersion(restrictions: Set<String>, project: String) {
if (restrictions.isNotEmpty()) {
val ver = restrictions.first()
if (
frameworksVersions.containsKey(
"version${project.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.ROOT) else it.toString() }}-$ver"
)
) {
frameworksVersions["${project}DefaultVersion"] = ver
}
}
}
/**
* Combines two sets of version restrictions. An empty set means "do not care", so the "other" one
* will be returned. If both sets are not empty, the common set will be returned.
*/
fun versionRestrictions(
currentRestrictions: Set<String>,
intersectRestrictions: Set<String>,
): Set<String> {
if (currentRestrictions.isEmpty()) {
return intersectRestrictions
}
if (intersectRestrictions.isEmpty()) {
return currentRestrictions
}
return currentRestrictions.intersect(intersectRestrictions)
}
fun restrictedVersion(restrictions: Set<String>, majorVersion: String): Boolean =
restrictions.isNotEmpty() && !restrictions.contains(majorVersion)
fun versionConstraints(
restricted: String,
restricting: String,
restrictingMajorVersion: String,
): Set<String> =
frameworksVersions
.getProperty("constraints.${restricted}Versions.$restricting-$restrictingMajorVersion", "")
.split(",")
.map { it.trim() }
.filter { it.isNotEmpty() }
.toSet()
fun majorVersion(version: String): String {
val elems = version.split(".")
return "${elems[0]}.${elems[1]}"
}
fun loadProperties(file: File): Properties {
val props = Properties()
file.reader().use { reader -> props.load(reader) }
return props
}
if (includeNessieBuild) {
logger.lifecycle("Including 'Nessie' from $nessieSourceDir")
includeBuild(nessieSourceDir) { name = "nessie" }
}
System.setProperty("defaultFlinkVersions", flinkRestrictions.first())
System.setProperty("knownFlinkVersions", flinkRestrictions.joinToString(","))
System.setProperty("flinkVersions", flinkRestrictions.joinToString(","))
System.setProperty("defaultSparkVersions", sparkRestrictions.first())
System.setProperty("knownSparkVersions", sparkRestrictions.joinToString(","))
System.setProperty("sparkVersions", sparkRestrictions.joinToString(","))
if (includeIcebergBuild) {
logger.lifecycle("Including 'Iceberg' from $icebergSourceDir")
includeBuild(icebergSourceDir) { name = "iceberg" }
}
if (includeNessieBuild) {
logger.lifecycle("Including 'Nessie-Iceberg' from $nessieSourceDir/nessie-iceberg")
includeBuild("$nessieSourceDir/nessie-iceberg") { name = "nessie-iceberg" }
}
include("nqeit-nessie-common")
include("nqeit-iceberg-flink-extension")
include("nqeit-iceberg-spark-extension")
include("nqeit-presto-extension")
include("nqeit-iceberg-dremio-extension")
fun includeProject(artifactId: String, projectDir: File) {
include(artifactId)
val p = project(":$artifactId")
p.projectDir = projectDir
}
include("nqeit-iceberg-dremio")
for (sparkVersion in sparkVersions) {
if (restrictedVersion(sparkRestrictions, sparkVersion)) {
continue
}
val scalaVersions =
frameworksVersions["sparkVersion-${sparkVersion}-scalaVersions"].toString().split(",").map {
it.trim()
}
for (scalaVersion in scalaVersions) {
if (restrictedVersion(scalaRestrictions, scalaVersion)) {
continue
}
includeProject("nqeit-iceberg-spark-${sparkVersion}_$scalaVersion", file("nqeit-iceberg-spark"))
}
}
for (flinkVersion in flinkVersions) {
if (restrictedVersion(flinkRestrictions, flinkVersion)) {
continue
}
includeProject("nqeit-iceberg-flink-$flinkVersion", file("nqeit-iceberg-flink"))
}
for (prestoVersion in prestoVersions) {
if (restrictedVersion(prestoRestrictions, prestoVersion)) {
continue
}
includeProject("nqeit-presto-$prestoVersion", file("nqeit-presto"))
}
for (crossEngineSetup in
frameworksVersions["crossEngineSetups"].toString().split(",").map { it.trim() }) {
val sparkMajor = frameworksVersions["crossEngine.$crossEngineSetup.sparkMajorVersion"] as String
val scalaMajor = frameworksVersions["crossEngine.$crossEngineSetup.scalaMajorVersion"] as String
val flinkMajor = frameworksVersions["crossEngine.$crossEngineSetup.flinkMajorVersion"] as String
if (
restrictedVersion(sparkRestrictions, sparkMajor) ||
restrictedVersion(scalaRestrictions, scalaMajor) ||
restrictedVersion(flinkRestrictions, flinkMajor)
) {
continue
}
includeProject(
"nqeit-cross-engine-$sparkMajor-$scalaMajor-$flinkMajor",
file("nqeit-cross-engine"),
)
if (ideSyncActive) {
break
}
}