forked from unitycatalog/unitycatalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
658 lines (606 loc) · 27.5 KB
/
build.sbt
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
import java.nio.file.Files
import java.io.File
import Tarball.createTarballSettings
import sbt.util
import sbt.Keys._
import sbtlicensereport.license.{DepModuleInfo, LicenseCategory, LicenseInfo}
import ReleaseSettings.*
import PythonClientPostBuild.*
import scala.language.implicitConversions
val orgName = "io.unitycatalog"
val artifactNamePrefix = "unitycatalog"
// Use Java 11 for two modules: clients and spark
// for better Spark compatibility
// until Spark 4 comes out with newer Java compatibility
lazy val javacRelease11 = Seq("--release", "11")
lazy val javacRelease17 = Seq("--release", "17")
lazy val scala212 = "2.12.15"
lazy val scala213 = "2.13.14"
lazy val deltaVersion = "3.2.1"
lazy val sparkVersion = "3.5.3"
lazy val commonSettings = Seq(
organization := orgName,
// Compilation configs
initialize := {
// Assert that the JVM is at least Java 17
val _ = initialize.value // ensure previous initializations are run
assert(
sys.props("java.specification.version").toDouble >= 17,
"Java 17 or above is required to run this project.")
},
Compile / compile / javacOptions ++= Seq(
"-Xlint:deprecation",
"-Xlint:unchecked",
"-g:source,lines,vars",
),
Test / javaOptions ++= Seq (
"-ea",
),
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % "2.0.13",
"org.slf4j" % "slf4j-log4j12" % "2.0.13" % Test,
"org.apache.logging.log4j" % "log4j-slf4j2-impl" % "2.23.1",
"org.apache.logging.log4j" % "log4j-api" % "2.23.1"
),
excludeDependencies ++= Seq(
ExclusionRule("org.slf4j", "slf4j-reload4j")
),
resolvers += Resolver.mavenLocal,
autoScalaLibrary := false,
crossPaths := false, // No scala cross building
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
},
// Test configs
Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-q"), Tests.Filter(name => !(name startsWith s"$orgName.server.base"))),
Test / logLevel := util.Level.Info,
Test / publishArtifact := false,
fork := true,
outputStrategy := Some(StdoutOutput),
Compile / packageBin := {
val packageFile = (Compile / packageBin).value
generateClasspathFile(
targetDir = packageFile.getParentFile,
classpath = (Runtime / dependencyClasspath).value)
packageFile
},
licenseConfigurations := Set("compile"),
licenseOverrides := {
case DepModuleInfo("io.unitycatalog", _, _) =>
LicenseInfo(LicenseCategory.Apache, "Apache 2.0", "http://www.apache.org/licenses")
case DepModuleInfo("org.hibernate.common", "hibernate-commons-annotations", _) =>
// Apache 2.0: https://mvnrepository.com/artifact/org.hibernate.common/hibernate-commons-annotations
LicenseInfo(LicenseCategory.Apache, "Apache 2.0", "http://www.apache.org/licenses")
},
licenseDepExclusions := {
// LGPL 2.1: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
// https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
// We can use and distribute the, but not modify the source code
case DepModuleInfo("org.hibernate.orm", _, _) => true
case DepModuleInfo("com.unboundid.scim2", _, _) => true
case DepModuleInfo("com.unboundid.product.scim2", _, _) => true
case DepModuleInfo("com.googlecode.aviator", _, _) => true
// Duo license:
// - Eclipse Public License 2.0
// - GNU General Public License, version 2 with the GNU Classpath Exception
// I think we're good with the classpath exception in there.
case DepModuleInfo("jakarta.transaction", "jakarta.transaction-api", _) => true
case DepModuleInfo("javax.annotation", "javax.annotation-api", _) => true
},
assembly / test := {}
)
enablePlugins(CoursierPlugin)
useCoursier := true
// Configure resolvers
resolvers ++= Seq(
"Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases/",
"Maven Central" at "https://repo1.maven.org/maven2/",
)
def javaCheckstyleSettings(configLocation: File) = Seq(
checkstyleConfigLocation := CheckstyleConfigLocation.File(configLocation.toString),
checkstyleSeverityLevel := Some(CheckstyleSeverityLevel.Error),
// (Compile / compile) := ((Compile / compile) dependsOn (Compile / checkstyle)).value,
// (Test / test) := ((Test / test) dependsOn (Test / checkstyle)).value,
)
// enforce java code style
def javafmtCheckSettings() = Seq(
(Compile / compile) := ((Compile / compile) dependsOn (Compile / javafmtAll)).value
)
lazy val controlApi = (project in file("target/control/java"))
.enablePlugins(OpenApiGeneratorPlugin)
.disablePlugins(JavaFormatterPlugin)
.settings(
name := s"$artifactNamePrefix-controlapi",
commonSettings,
skipReleaseSettings,
libraryDependencies ++= Seq(
"jakarta.annotation" % "jakarta.annotation-api" % "3.0.0" % Provided,
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonVersion,
),
(Compile / compile) := ((Compile / compile) dependsOn generate).value,
// OpenAPI generation specs
openApiInputSpec := (file(".") / "api" / "control.yaml").toString,
openApiGeneratorName := "java",
openApiOutputDir := (file("target") / "control" / "java").toString,
openApiApiPackage := s"$orgName.control.api",
openApiModelPackage := s"$orgName.control.model",
openApiAdditionalProperties := Map(
"library" -> "native",
"useJakartaEe" -> "true",
"hideGenerationTimestamp" -> "true",
"openApiNullable" -> "false"),
openApiGenerateApiTests := SettingDisabled,
openApiGenerateModelTests := SettingDisabled,
openApiGenerateApiDocumentation := SettingDisabled,
openApiGenerateModelDocumentation := SettingDisabled,
// Define the simple generate command to generate full client codes
generate := {
val _ = openApiGenerate.value
// Delete the generated build.sbt file so that it is not used for our sbt config
val buildSbtFile = file(openApiOutputDir.value) / "build.sbt"
if (buildSbtFile.exists()) {
buildSbtFile.delete()
}
}
)
lazy val client = (project in file("target/clients/java"))
.enablePlugins(OpenApiGeneratorPlugin)
.disablePlugins(JavaFormatterPlugin)
.settings(
name := s"$artifactNamePrefix-client",
commonSettings,
javaOnlyReleaseSettings,
Compile / compile / javacOptions ++= javacRelease11,
libraryDependencies ++= Seq(
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-core" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonVersion,
"org.openapitools" % "jackson-databind-nullable" % openApiToolsJacksonBindNullableVersion,
"com.google.code.findbugs" % "jsr305" % "3.0.2",
"jakarta.annotation" % "jakarta.annotation-api" % "3.0.0" % Provided,
// Test dependencies
"org.junit.jupiter" % "junit-jupiter" % "5.10.3" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"org.assertj" % "assertj-core" % "3.26.3" % Test,
),
(Compile / compile) := ((Compile / compile) dependsOn generate).value,
// OpenAPI generation specs
openApiInputSpec := (file(".") / "api" / "all.yaml").toString,
openApiGeneratorName := "java",
openApiOutputDir := (file("target") / "clients" / "java").toString,
openApiApiPackage := s"$orgName.client.api",
openApiModelPackage := s"$orgName.client.model",
openApiAdditionalProperties := Map(
"library" -> "native",
"useJakartaEe" -> "true",
"hideGenerationTimestamp" -> "true",
"openApiNullable" -> "false"),
openApiGenerateApiTests := SettingDisabled,
openApiGenerateModelTests := SettingDisabled,
openApiGenerateApiDocumentation := SettingDisabled,
openApiGenerateModelDocumentation := SettingDisabled,
// Define the simple generate command to generate full client codes
generate := {
val _ = openApiGenerate.value
// Delete the generated build.sbt file so that it is not used for our sbt config
val buildSbtFile = file(openApiOutputDir.value) / "build.sbt"
if (buildSbtFile.exists()) {
buildSbtFile.delete()
}
},
// Add VersionInfo in the same way like in server
Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "io" / "unitycatalog" / "cli" / "utils" / "VersionUtils.java"
IO.write(file,
s"""package io.unitycatalog.cli.utils;
|
|public class VersionUtils {
| public static String VERSION = "${version.value}";
|}
|""".stripMargin)
Seq(file)
}
)
lazy val prepareGeneration = taskKey[Unit]("Prepare the environment for OpenAPI code generation")
lazy val pythonClient = (project in file("clients/python"))
.enablePlugins(OpenApiGeneratorPlugin)
.settings(
name := s"$artifactNamePrefix-python-client",
commonSettings,
skipReleaseSettings,
Compile / compile := (Compile / compile).dependsOn(generate).value,
openApiInputSpec := (baseDirectory.value.getParentFile.getParentFile / "api" / "all.yaml").getAbsolutePath,
openApiGeneratorName := "python",
openApiOutputDir := (baseDirectory.value / "target").getAbsolutePath,
openApiPackageName := s"$artifactNamePrefix.client",
openApiAdditionalProperties := Map(
"packageVersion" -> s"${version.value.replace("-SNAPSHOT", ".dev0")}",
"library" -> "asyncio"
),
openApiGenerateApiTests := SettingDisabled,
openApiGenerateModelTests := SettingDisabled,
openApiGenerateApiDocumentation := SettingDisabled,
openApiGenerateModelDocumentation := SettingDisabled,
prepareGeneration := PythonClientPostBuild.prepareGeneration(streams.value.log, baseDirectory.value, openApiOutputDir.value),
generate := Def.sequential(
prepareGeneration,
openApiGenerate,
Def.task {
val log = streams.value.log
PythonClientPostBuild.processGeneratedFiles(
log,
openApiOutputDir.value,
baseDirectory.value,
)
log.info("OpenAPI Python client generation completed.")
}
).value
)
lazy val apiDocs = (project in file("api"))
.enablePlugins(OpenApiGeneratorPlugin)
.settings(
name := s"$artifactNamePrefix-docs",
skipReleaseSettings,
// OpenAPI generation specs
openApiInputSpec := (file("api") / "all.yaml").toString,
openApiGeneratorName := "markdown",
openApiOutputDir := (file("api")).toString,
// Define the simple generate command to generate markdown docs
generate := {
val _ = openApiGenerate.value
}
)
// Define the custom task key
lazy val populateTestDB = taskKey[Unit]("Run PopulateTestDatabase main class from the test folder")
lazy val server = (project in file("server"))
.dependsOn(client % "test->test")
.dependsOn(serverModels)
.settings (
name := s"$artifactNamePrefix-server",
mainClass := Some(orgName + ".server.UnityCatalogServer"),
commonSettings,
javaOnlyReleaseSettings,
javafmtCheckSettings,
javaCheckstyleSettings(file("dev") / "checkstyle-config.xml"),
Compile / compile / javacOptions ++= Seq(
"-processor",
"lombok.launch.AnnotationProcessorHider$AnnotationProcessor"
) ++ javacRelease17,
libraryDependencies ++= Seq(
"com.linecorp.armeria" % "armeria" % "1.28.4",
// Netty dependencies
"io.netty" % "netty-all" % "4.1.111.Final",
"jakarta.annotation" % "jakarta.annotation-api" % "3.0.0" % Provided,
// Jackson dependencies
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-core" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % jacksonVersion,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonVersion,
"com.google.code.findbugs" % "jsr305" % "3.0.2",
"com.h2database" % "h2" % "2.2.224",
"org.hibernate.orm" % "hibernate-core" % "6.5.0.Final",
"jakarta.activation" % "jakarta.activation-api" % "2.1.3",
"net.bytebuddy" % "byte-buddy" % "1.14.15",
"org.projectlombok" % "lombok" % "1.18.32" % Provided,
// For ALDS access
"com.azure" % "azure-identity" % "1.13.2",
"com.azure" % "azure-storage-file-datalake" % "12.20.0",
// For GCS Access
"com.google.cloud" % "google-cloud-storage" % "2.30.1",
"com.google.auth" % "google-auth-library-oauth2-http" % "1.20.0",
//For s3 access
"com.amazonaws" % "aws-java-sdk-s3" % "1.12.728",
"software.amazon.awssdk" % "sso" % "2.27.12",
"software.amazon.awssdk" % "ssooidc" % "2.27.12",
"org.apache.httpcomponents" % "httpcore" % "4.4.16",
"org.apache.httpcomponents" % "httpclient" % "4.5.14",
// Iceberg REST Catalog dependencies
"org.apache.iceberg" % "iceberg-core" % "1.5.2",
"org.apache.iceberg" % "iceberg-aws" % "1.5.2",
"org.apache.iceberg" % "iceberg-azure" % "1.5.2",
"org.apache.iceberg" % "iceberg-gcp" % "1.5.2",
"software.amazon.awssdk" % "s3" % "2.24.0",
"software.amazon.awssdk" % "sts" % "2.24.0",
"io.vertx" % "vertx-core" % "4.3.5",
"io.vertx" % "vertx-web" % "4.3.5",
"io.vertx" % "vertx-web-client" % "4.3.5",
// Auth dependencies
"com.unboundid.product.scim2" % "scim2-sdk-common" % "3.1.0",
"org.casbin" % "jcasbin" % "1.55.0",
"org.casbin" % "jdbc-adapter" % "2.7.0"
exclude("com.microsoft.sqlserver", "mssql-jdbc")
exclude("com.oracle.database.jdbc", "ojdbc6"),
"org.springframework" % "spring-expression" % "6.1.11",
"com.auth0" % "java-jwt" % "4.4.0",
"com.auth0" % "jwks-rsa" % "0.22.1",
// Test dependencies
"org.junit.jupiter" % "junit-jupiter" % "5.10.3" % Test,
"org.mockito" % "mockito-core" % "5.11.0" % Test,
"org.mockito" % "mockito-inline" % "5.2.0" % Test,
"org.mockito" % "mockito-junit-jupiter" % "5.12.0" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"com.adobe.testing" % "s3mock-junit5" % "3.9.1" % Test
exclude("ch.qos.logback", "logback-classic")
exclude("org.apache.logging.log4j", "log4j-to-slf4j"),
"javax.xml.bind" % "jaxb-api" % "2.3.1" % Test,
// CLI dependencies
"commons-cli" % "commons-cli" % "1.7.0"
),
Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "io" / "unitycatalog" / "server" / "utils" / "VersionUtils.java"
IO.write(file,
s"""package io.unitycatalog.server.utils;
|
|public class VersionUtils {
| public static String VERSION = "${version.value}";
|}
|""".stripMargin)
Seq(file)
},
populateTestDB := {
val log = streams.value.log
(Test / runMain).toTask(s" io.unitycatalog.server.utils.PopulateTestDatabase").value
},
Test / javaOptions += s"-Duser.dir=${(ThisBuild / baseDirectory).value.getAbsolutePath}"
)
lazy val serverModels = (project in file("server") / "target" / "models")
.enablePlugins(OpenApiGeneratorPlugin)
.disablePlugins(JavaFormatterPlugin)
.dependsOn(controlModels % "compile->compile")
.settings(
name := s"$artifactNamePrefix-servermodels",
commonSettings,
skipReleaseSettings,
(Compile / compile) := ((Compile / compile) dependsOn generate).value,
Compile / compile / javacOptions ++= javacRelease17,
libraryDependencies ++= Seq(
"jakarta.annotation" % "jakarta.annotation-api" % "3.0.0" % Provided,
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
),
// OpenAPI generation configs for generating model codes from the spec
openApiInputSpec := (file(".") / "api" / "all.yaml").toString,
openApiGeneratorName := "java",
openApiOutputDir := (file("server") / "target" / "models").toString,
openApiValidateSpec := SettingEnabled,
openApiGenerateMetadata := SettingDisabled,
openApiModelPackage := s"$orgName.server.model",
openApiAdditionalProperties := Map(
"library" -> "resteasy", // resteasy generates the most minimal models
"useJakartaEe" -> "true",
"hideGenerationTimestamp" -> "true"
),
openApiGlobalProperties := Map("models" -> ""),
openApiGenerateApiTests := SettingDisabled,
openApiGenerateModelTests := SettingDisabled,
openApiGenerateApiDocumentation := SettingDisabled,
openApiGenerateModelDocumentation := SettingDisabled,
// Define the simple generate command to generate model codes
generate := {
val _ = openApiGenerate.value
}
)
lazy val controlModels = (project in file("server") / "target" / "controlmodels")
.enablePlugins(OpenApiGeneratorPlugin)
.disablePlugins(JavaFormatterPlugin)
.settings(
name := s"$artifactNamePrefix-controlmodels",
commonSettings,
skipReleaseSettings,
(Compile / compile) := ((Compile / compile) dependsOn generate).value,
Compile / compile / javacOptions ++= javacRelease17,
libraryDependencies ++= Seq(
"jakarta.annotation" % "jakarta.annotation-api" % "3.0.0" % Provided,
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
),
// OpenAPI generation configs for generating model codes from the spec
openApiInputSpec := (file(".") / "api" / "control.yaml").toString,
openApiGeneratorName := "java",
openApiOutputDir := (file("server") / "target" / "controlmodels").toString,
openApiValidateSpec := SettingEnabled,
openApiGenerateMetadata := SettingDisabled,
openApiModelPackage := s"$orgName.control.model",
openApiAdditionalProperties := Map(
"library" -> "resteasy", // resteasy generates the most minimal models
"useJakartaEe" -> "true",
"hideGenerationTimestamp" -> "true"
),
openApiGlobalProperties := Map("models" -> ""),
openApiGenerateApiTests := SettingDisabled,
openApiGenerateModelTests := SettingDisabled,
openApiGenerateApiDocumentation := SettingDisabled,
openApiGenerateModelDocumentation := SettingDisabled,
// Define the simple generate command to generate model codes
generate := {
val _ = openApiGenerate.value
}
)
lazy val cli = (project in file("examples") / "cli")
.dependsOn(server % "test->test")
.dependsOn(client % "compile->compile;test->test")
.dependsOn(controlApi % "compile->compile")
.settings(
name := s"$artifactNamePrefix-cli",
mainClass := Some(orgName + ".cli.UnityCatalogCli"),
commonSettings,
skipReleaseSettings,
javafmtCheckSettings,
javaCheckstyleSettings(file("dev") / "checkstyle-config.xml"),
Compile / compile / javacOptions ++= javacRelease17,
libraryDependencies ++= Seq(
"commons-cli" % "commons-cli" % "1.7.0",
"org.json" % "json" % "20240303",
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonVersion,
"org.openapitools" % "jackson-databind-nullable" % openApiToolsJacksonBindNullableVersion,
"org.yaml" % "snakeyaml" % "2.2",
"io.delta" % "delta-kernel-api" % deltaVersion,
"io.delta" % "delta-kernel-defaults" % deltaVersion,
"io.delta" % "delta-storage" % deltaVersion,
"org.apache.hadoop" % "hadoop-client-api" % "3.4.0",
"org.apache.hadoop" % "hadoop-client-runtime" % "3.4.0",
"de.vandermeer" % "asciitable" % "0.3.2",
// for s3 access
"org.fusesource.jansi" % "jansi" % "2.4.1",
"com.amazonaws" % "aws-java-sdk-core" % "1.12.728",
"org.apache.hadoop" % "hadoop-aws" % "3.4.0",
"org.apache.hadoop" % "hadoop-azure" % "3.4.0",
"com.google.guava" % "guava" % "31.0.1-jre",
// Test dependencies
"org.junit.jupiter" % "junit-jupiter" % "5.10.3" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
),
Test / javaOptions += s"-Duser.dir=${(ThisBuild / baseDirectory).value.getAbsolutePath}",
)
/*
* This project is a combination of the server and client projects, shaded into a single JAR.
* It also includes the test classes from the server project.
* It is used for the Spark connector project(the client is required as a compile dependency,
* and the server(with tests) is required as a test dependency)
* This was necessary because Spark 3.5 has a dependency on Jackson 2.15, which conflicts with the Jackson 2.17
*/
lazy val serverShaded = (project in file("server-shaded"))
.dependsOn(server % "compile->compile, test->compile")
.settings(
name := s"$artifactNamePrefix-server-shaded",
commonSettings,
skipReleaseSettings,
Compile / packageBin := assembly.value,
assembly / mainClass := Some("io.unitycatalog.server.UnityCatalogServer"),
assembly / logLevel := Level.Warn,
assembly / test := {},
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("com.fasterxml.**" -> "shaded.@0").inAll,
ShadeRule.rename("org.antlr.**" -> "shaded.@0").inAll,
),
assemblyPackageScala / assembleArtifact := false,
assembly / fullClasspath := {
val compileClasspath = (server / Compile / fullClasspath).value
val testClasses = (server / Test / products).value
compileClasspath ++ testClasses.map(Attributed.blank)
}
)
lazy val spark = (project in file("connectors/spark"))
.dependsOn(client)
.settings(
name := s"$artifactNamePrefix-spark",
scalaVersion := scala212,
crossScalaVersions := Seq(scala212, scala213),
commonSettings,
scalaReleaseSettings,
javaOptions ++= Seq(
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
),
javaCheckstyleSettings(file("dev/checkstyle-config.xml")),
Compile / compile / javacOptions ++= javacRelease11,
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % sparkVersion % Provided,
"com.fasterxml.jackson.core" % "jackson-databind" % "2.15.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.15.0",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.15.0",
"com.fasterxml.jackson.core" % "jackson-core" % "2.15.0",
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.15.0",
"org.antlr" % "antlr4-runtime" % "4.9.3",
"org.antlr" % "antlr4" % "4.9.3",
"com.google.cloud.bigdataoss" % "util-hadoop" % "3.0.2" % Provided,
"org.apache.hadoop" % "hadoop-azure" % "3.4.0" % Provided,
),
libraryDependencies ++= Seq(
// Test dependencies
"org.junit.jupiter" % "junit-jupiter" % "5.10.3" % Test,
"org.assertj" % "assertj-core" % "3.26.3" % Test,
"org.mockito" % "mockito-core" % "5.11.0" % Test,
"org.mockito" % "mockito-inline" % "5.2.0" % Test,
"org.mockito" % "mockito-junit-jupiter" % "5.12.0" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"org.apache.hadoop" % "hadoop-client-runtime" % "3.4.0",
"io.delta" %% "delta-spark" % deltaVersion % Test,
),
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.15.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.15.0",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.15.0",
"com.fasterxml.jackson.core" % "jackson-core" % "2.15.0",
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.15.0",
"org.antlr" % "antlr4-runtime" % "4.9.3",
"org.antlr" % "antlr4" % "4.9.3",
),
Test / unmanagedJars += (serverShaded / assembly).value,
licenseDepExclusions := {
case DepModuleInfo("org.hibernate.orm", _, _) => true
case DepModuleInfo("jakarta.annotation", "jakarta.annotation-api", _) => true
case DepModuleInfo("jakarta.servlet", "jakarta.servlet-api", _) => true
case DepModuleInfo("jakarta.transaction", "jakarta.transaction-api", _) => true
case DepModuleInfo("jakarta.ws.rs", "jakarta.ws.rs-api", _) => true
case DepModuleInfo("javax.activation", "activation", _) => true
case DepModuleInfo("javax.servlet", "javax.servlet-api", _) => true
case DepModuleInfo("org.glassfish.hk2", "hk2-api", _) => true
case DepModuleInfo("org.glassfish.hk2", "hk2-locator", _) => true
case DepModuleInfo("org.glassfish.hk2", "hk2-utils", _) => true
case DepModuleInfo("org.glassfish.hk2", "osgi-resource-locator", _) => true
case DepModuleInfo("org.glassfish.hk2.external", "aopalliance-repackaged", _) => true
case DepModuleInfo("ch.qos.logback", "logback-classic", _) => true
case DepModuleInfo("ch.qos.logback", "logback-core", _) => true
case DepModuleInfo("org.apache.xbean", "xbean-asm9-shaded", _) => true
case DepModuleInfo("oro", "oro", _) => true
case DepModuleInfo("org.glassfish", "javax.json", _) => true
case DepModuleInfo("org.glassfish.hk2.external", "jakarta.inject", _) => true
case DepModuleInfo("org.antlr", "ST4", _) => true
}
)
lazy val integrationTests = (project in file("integration-tests"))
.settings(
name := s"$artifactNamePrefix-integration-tests",
commonSettings,
javaOptions ++= Seq(
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
),
skipReleaseSettings,
libraryDependencies ++= Seq(
"org.junit.jupiter" % "junit-jupiter" % "5.10.3" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"org.assertj" % "assertj-core" % "3.26.3" % Test,
"org.projectlombok" % "lombok" % "1.18.32" % Provided,
"org.apache.spark" %% "spark-sql" % "3.5.3" % Test,
"io.delta" %% "delta-spark" % "3.2.1" % Test,
"org.apache.hadoop" % "hadoop-aws" % "3.3.6" % Test,
"org.apache.hadoop" % "hadoop-azure" % "3.3.6" % Test,
"com.google.cloud.bigdataoss" % "gcs-connector" % "3.0.2" % Test classifier "shaded",
"io.unitycatalog" %% "unitycatalog-spark" % "0.2.0" % Test,
),
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.15.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.15.0",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.15.0",
"com.fasterxml.jackson.core" % "jackson-core" % "2.15.0",
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.15.0",
"org.antlr" % "antlr4-runtime" % "4.9.3",
"org.antlr" % "antlr4" % "4.9.3",
"org.apache.hadoop" % "hadoop-client-api" % "3.3.6",
),
Test / javaOptions += s"-Duser.dir=${((ThisBuild / baseDirectory).value / "integration-tests").getAbsolutePath}",
)
lazy val root = (project in file("."))
.aggregate(serverModels, client, pythonClient, server, cli, spark, controlApi, controlModels, apiDocs)
.settings(
name := s"$artifactNamePrefix",
createTarballSettings(),
commonSettings,
rootReleaseSettings
)
def generateClasspathFile(targetDir: File, classpath: Classpath): Unit = {
// Generate a classpath file with the entire runtime class path.
// This is used by the launcher scripts for launching CLI directly with JAR instead of SBT.
val classpathFile = targetDir / "classpath"
Files.write(classpathFile.toPath, classpath.files.mkString(File.pathSeparator).getBytes)
println(s"Generated classpath file '$classpathFile'")
}
val generate = taskKey[Unit]("generate code from APIs")
// Library versions
val jacksonVersion = "2.17.0"
val openApiToolsJacksonBindNullableVersion = "0.2.6"
val log4jVersion = "2.23.1"