forked from unitycatalog/unitycatalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
305 lines (271 loc) · 11.9 KB
/
build.sbt
File metadata and controls
305 lines (271 loc) · 11.9 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
import java.nio.file.Files
import java.io.File
import Tarball.createTarballSettings
import sbt.util
import sbtlicensereport.license.{LicenseInfo, LicenseCategory, DepModuleInfo}
import ReleaseSettings._
import scala.language.implicitConversions
val orgName = "io.unitycatalog"
val artifactNamePrefix = "unitycatalog"
lazy val commonSettings = Seq(
organization := orgName,
// Compilation configs
initialize := {
// Assert that the JVM is at least Java 11
val _ = initialize.value // ensure previous initializations are run
assert(
sys.props("java.specification.version").toDouble >= 11,
"Java 11 or above is required to run this project.")
},
Compile / compile / javacOptions ++= Seq(
"-Xlint:deprecation",
"-Xlint:unchecked",
"-source", "1.8",
"-target", "1.8",
"-g:source,lines,vars"
),
resolvers += Resolver.mavenLocal,
autoScalaLibrary := false,
crossPaths := false, // No scala cross building
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => 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
},
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
// 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
},
)
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,
)
lazy val client = (project in file("clients/java"))
.enablePlugins(OpenApiGeneratorPlugin)
.disablePlugins(JavaFormatterPlugin)
.settings(
name := s"$artifactNamePrefix-client",
commonSettings,
javaOnlyReleaseSettings,
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
"junit" % "junit" % "4.13.2" % Test,
"org.junit.jupiter" % "junit-jupiter" % "5.9.2" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"org.assertj" % "assertj-core" % "3.25.1" % Test,
),
// OpenAPI generation specs
openApiInputSpec := (file(".") / "api" / "all.yaml").toString,
openApiGeneratorName := "java",
openApiOutputDir := (file("clients") / "java").toString,
openApiApiPackage := s"$orgName.client.api",
openApiModelPackage := s"$orgName.client.model",
openApiAdditionalProperties := Map(
"library" -> "native",
"useJakartaEe" -> "true",
"hideGenerationTimestamp" -> "true"),
openApiGenerateApiTests := SettingDisabled,
openApiGenerateModelTests := SettingDisabled,
openApiGenerateApiDocumentation := SettingDisabled,
openApiGenerateModelDocumentation := SettingDisabled,
// Define the simple generate command to generate full client codes
generate := {
val _ = openApiGenerate.value
}
)
lazy val apiDocs = (project in file("api"))
.enablePlugins(OpenApiGeneratorPlugin)
.settings(
name := s"$artifactNamePrefix-docs",
// 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")
.enablePlugins(OpenApiGeneratorPlugin)
.settings (
name := s"$artifactNamePrefix-server",
commonSettings,
javaOnlyReleaseSettings,
javaCheckstyleSettings(file("dev") / "checkstyle-config.xml"),
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.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",
"org.openapitools" % "jackson-databind-nullable" % openApiToolsJacksonBindNullableVersion,
// logging
"org.apache.logging.log4j" % "log4j-api" % log4jVersion,
"org.apache.logging.log4j" % "log4j-core" % log4jVersion,
"org.apache.logging.log4j" % "log4j-slf4j-impl" % log4jVersion,
"jakarta.activation" % "jakarta.activation-api" % "2.1.3",
"net.bytebuddy" % "byte-buddy" % "1.14.15",
"org.projectlombok" % "lombok" % "1.18.32" % "provided",
//For s3 access
"com.amazonaws" % "aws-java-sdk-s3" % "1.12.728",
"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",
"io.vertx" % "vertx-core" % "4.3.5",
"io.vertx" % "vertx-web" % "4.3.5",
"io.vertx" % "vertx-web-client" % "4.3.5",
// Test dependencies
"junit" % "junit" % "4.13.2" % Test,
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
),
Compile / compile / javacOptions ++= Seq(
"-processor",
"lombok.launch.AnnotationProcessorHider$AnnotationProcessor"
),
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)
},
// OpenAPI generation configs for generating model codes from the spec
openApiInputSpec := (file(".") / "api" / "all.yaml").toString,
openApiGeneratorName := "java",
openApiOutputDir := file("server").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
},
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 cli = (project in file("examples") / "cli")
.dependsOn(server % "compile->compile;test->test")
.dependsOn(client % "compile->compile;test->test")
.settings(
name := s"$artifactNamePrefix-cli",
mainClass := Some(orgName + ".cli.UnityCatalogCli"),
commonSettings,
skipReleaseSettings,
javaCheckstyleSettings(file("dev") / "checkstyle-config.xml"),
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",
// logging
"org.apache.logging.log4j" % "log4j-api" % log4jVersion,
"org.apache.logging.log4j" % "log4j-core" % log4jVersion,
"org.apache.logging.log4j" % "log4j-slf4j-impl" % log4jVersion,
"io.delta" % "delta-kernel-api" % "3.2.0",
"io.delta" % "delta-kernel-defaults" % "3.2.0",
"io.delta" % "delta-storage" % "3.2.0",
"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",
"com.google.guava" % "guava" % "31.0.1-jre",
// Test dependencies
"junit" % "junit" % "4.13.2" % Test,
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
)
)
lazy val root = (project in file("."))
.aggregate(client, server, cli)
.settings(
name := s"$artifactNamePrefix",
createTarballSettings(),
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"