forked from windpiger/connectors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
273 lines (243 loc) · 12.7 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
/*
* Copyright (2020) The Delta Lake Project Authors.
*
* 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.
*/
parallelExecution in ThisBuild := false
scalastyleConfig in ThisBuild := baseDirectory.value / "scalastyle-config.xml"
lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")
lazy val testScalastyle = taskKey[Unit]("testScalastyle")
crossScalaVersions := Seq("2.12.8", "2.11.12")
val sparkVersion = "2.4.3"
val hadoopVersion = "2.7.2"
val hiveVersion = "2.3.3"
val deltaVersion = "0.5.0"
lazy val commonSettings = Seq(
organization := "io.delta",
scalaVersion := "2.12.8",
fork := true,
// Configurations to speed up tests and reduce memory footprint
javaOptions in Test ++= Seq(
"-Dspark.ui.enabled=false",
"-Dspark.ui.showConsoleProgress=false",
"-Dspark.databricks.delta.snapshotPartitions=2",
"-Dspark.sql.shuffle.partitions=5",
"-Ddelta.log.cacheSize=3",
"-Dspark.sql.sources.parallelPartitionDiscovery.parallelism=5",
"-Xmx1024m"
),
compileScalastyle := scalastyle.in(Compile).toTask("").value,
(compile in Compile) := ((compile in Compile) dependsOn compileScalastyle).value,
testScalastyle := scalastyle.in(Test).toTask("").value,
(test in Test) := ((test in Test) dependsOn testScalastyle).value
)
lazy val core = (project in file("core"))
.settings(
name := "delta-core-shaded",
libraryDependencies ++= Seq(
"io.delta" %% "delta-core" % deltaVersion excludeAll ExclusionRule("org.apache.hadoop"),
"org.apache.spark" %% "spark-sql" % sparkVersion excludeAll(
ExclusionRule("org.apache.hadoop"),
// Remove all dependencies used by Spark UI. Spark UI is not needed and we have disabled it.
// So these dependencies are not used any more.
ExclusionRule("com.sun.jersey"),
ExclusionRule("org.glassfish"),
ExclusionRule("org.glassfish.jersey.bundles"),
ExclusionRule("org.glassfish.jersey.media"),
ExclusionRule("org.glassfish.hk2"),
ExclusionRule("org.glassfish.jersey.bundles.repackaged"),
ExclusionRule("org.glassfish.jersey.test-framework"),
ExclusionRule("org.glassfish.hk2.external"),
ExclusionRule("org.glassfish.jersey.containers"),
ExclusionRule("org.glassfish.jersey.test-framework.providers"),
ExclusionRule("org.glassfish.jaxb"),
ExclusionRule("org.glassfish.jersey.core"),
ExclusionRule("org.glassfish.jersey"),
ExclusionRule("org.glassfish.jersey.inject"),
ExclusionRule("javax.ws.rs"),
ExclusionRule("org.xerial.snappy")
),
"org.apache.hadoop" % "hadoop-client" % hadoopVersion % "provided"
),
// Make the 'compile' invoke the 'assembly' task to generate the uber jar.
packageBin in Compile := assembly.value,
commonSettings,
assemblySettings
)
lazy val coreTest = (project in file("coreTest"))
.settings(
// Add the uber jar as unmanaged library so that we don't bring in the transitive dependencies
unmanagedJars in Compile += (packageBin in(core, Compile, packageBin)).value,
// Only dependency not in the uber jar
libraryDependencies ++= Seq("org.apache.hadoop" % "hadoop-client" % hadoopVersion excludeAll
ExclusionRule("org.slf4j", "slf4j-log4j12"),
"org.xerial.snappy" % "snappy-java" % "1.1.7.3"
),
autoScalaLibrary := false,
// Ensure that the uber jar is compiled before compiling this project
(compile in Compile) := ((compile in Compile) dependsOn (packageBin in (core, Compile, packageBin))).value,
// Make 'test' invoke 'runMain'
test in Test := (runMain in Runtime).toTask(" test.Test").value,
commonSettings
)
lazy val assemblySettings = Seq(
test in assembly := {},
assemblyMergeStrategy in assembly := {
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case "log4j.properties" => MergeStrategy.discard
case m if m.toLowerCase.startsWith("meta-inf/services/") => MergeStrategy.filterDistinctLines
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
},
assemblyJarName in assembly := s"${name.value}-assembly_${scalaBinaryVersion.value}-${version.value}.jar",
assemblyShadeRules in assembly :=
(if (scalaBinaryVersion.value == "2.11") Seq(
// json4s cannot be shaded when using Scala 2.11
ShadeRule.rename("org.json4s.**" -> "@0").inAll
) else Nil) ++ Seq(
/*
All org.apache.* before shading:
arrow, avro, commons, curator, ivy, jute, log4j, orc, oro, parquet, spark, xbean, zookeeper
*/
ShadeRule.rename("org.apache.commons.lang3.time.**" -> "shadedelta.@0").inAll,
// Packages to exclude from shading because they are not happy when shaded
ShadeRule.rename("javax.**" -> "@0").inAll,
ShadeRule.rename("com.sun.**" -> "@0").inAll,
ShadeRule.rename("com.fasterxml.**" -> "@0").inAll, // Scala reflect trigger via catalyst fails when package changed
ShadeRule.rename("org.apache.hadoop.**" -> "@0").inAll, // Do not change any references to hadoop classes as they will be provided
ShadeRule.rename("org.apache.spark.**" -> "@0").inAll, // Scala package object does not resolve correctly when package changed
ShadeRule.rename("org.apache.log4j.**" -> "@0").inAll, // Initialization via reflection fails when package changed
ShadeRule.rename("org.slf4j.**" -> "@0").inAll, // Initialization via reflection fails when package changed
ShadeRule.rename("org.apache.commons.**" -> "@0").inAll, // Initialization via reflection fails when package changed
ShadeRule.rename("org.xerial.snappy.**" -> "@0").inAll, // Snappy fails to resolve native code when package changed
ShadeRule.rename("com.databricks.**" -> "@0").inAll, // Scala package object does not resolve correctly when package changed
// Shade everything else
ShadeRule.rename("com.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("org.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("io.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("net.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("avro.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("codegen.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("jersey.**" -> "shadedelta.@0").inAll,
ShadeRule.rename("javassist.**" -> "shadedelta.@0").inAll,
/*
All top level dirs left in the jar after shading:
aix, assets, com, darwin, delta, fr, include, javax, linux, org, scala, shaded, shadedelta, win
*/
// Remove things we know are not needed
ShadeRule.zap("py4j**").inAll,
ShadeRule.zap("webapps**").inAll,
ShadeRule.zap("delta**").inAll
),
logLevel in assembly := Level.Info
)
lazy val hive = (project in file("hive")) settings (
name := "hive-delta",
commonSettings,
unmanagedJars in Compile += (packageBin in(core, Compile, packageBin)).value,
autoScalaLibrary := false,
// Ensures that the connector core jar is compiled before compiling this project
(compile in Compile) := ((compile in Compile) dependsOn (packageBin in (core, Compile, packageBin))).value,
// Minimal dependencies to compile the codes. This project doesn't run any tests so we don't need
// any runtime dependencies.
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-client" % hadoopVersion % "provided",
"org.apache.hive" % "hive-exec" % hiveVersion % "provided" excludeAll(
ExclusionRule(organization = "org.apache.spark"),
ExclusionRule(organization = "org.apache.parquet"),
ExclusionRule("org.pentaho", "pentaho-aggdesigner-algorithm"),
ExclusionRule(organization = "com.google.protobuf")
),
"org.apache.hive" % "hive-cli" % hiveVersion % "test" excludeAll(
ExclusionRule(organization = "org.apache.spark"),
ExclusionRule(organization = "org.apache.parquet"),
ExclusionRule("ch.qos.logback", "logback-classic"),
ExclusionRule("org.pentaho", "pentaho-aggdesigner-algorithm"),
ExclusionRule(organization = "com.google.protobuf")
),
"org.apache.spark" %% "spark-core" % sparkVersion % "test" classifier "tests",
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"io.delta" %% "delta-core" % deltaVersion % "test"
)
)
lazy val hiveMR = (project in file("hive-mr")) dependsOn(hive % "test->test") settings (
name := "hive-mr",
commonSettings,
unmanagedJars in Compile += (packageBin in(core, Compile, packageBin)).value,
autoScalaLibrary := false,
// Ensures that the connector core jar is compiled before compiling this project
(compile in Compile) := ((compile in Compile) dependsOn (packageBin in (core, Compile, packageBin))).value,
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-client" % hadoopVersion % "provided",
"org.apache.hive" % "hive-exec" % hiveVersion % "provided" excludeAll(
ExclusionRule(organization = "org.apache.spark"),
ExclusionRule(organization = "org.apache.parquet"),
ExclusionRule("org.pentaho", "pentaho-aggdesigner-algorithm")
),
"org.apache.hadoop" % "hadoop-common" % hadoopVersion % "test" classifier "tests",
"org.apache.hadoop" % "hadoop-mapreduce-client-hs" % hadoopVersion % "test",
"org.apache.hadoop" % "hadoop-mapreduce-client-jobclient" % hadoopVersion % "test" classifier "tests",
"org.apache.hadoop" % "hadoop-yarn-server-tests" % hadoopVersion % "test" classifier "tests",
"org.apache.hive" % "hive-cli" % hiveVersion % "test" excludeAll(
ExclusionRule(organization = "org.apache.spark"),
ExclusionRule(organization = "org.apache.parquet"),
ExclusionRule("ch.qos.logback", "logback-classic"),
ExclusionRule("org.pentaho", "pentaho-aggdesigner-algorithm")
),
// TODO Figure out how this fixes some bad dependency
"org.apache.spark" %% "spark-core" % sparkVersion % "test" classifier "tests",
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"io.delta" %% "delta-core" % deltaVersion % "test" excludeAll ExclusionRule("org.apache.hadoop")
)
)
lazy val hiveTez = (project in file("hive-tez")) dependsOn(hive % "test->test") settings (
name := "hive-tez",
commonSettings,
unmanagedJars in Compile += (packageBin in(core, Compile, packageBin)).value,
autoScalaLibrary := false,
// Ensures that the connector core jar is compiled before compiling this project
(compile in Compile) := ((compile in Compile) dependsOn (packageBin in (core, Compile, packageBin))).value,
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-client" % hadoopVersion % "provided" excludeAll (
ExclusionRule(organization = "com.google.protobuf")
),
"com.google.protobuf" % "protobuf-java" % "2.5.0",
"org.apache.hive" % "hive-exec" % hiveVersion % "provided" excludeAll(
ExclusionRule(organization = "org.apache.spark"),
ExclusionRule(organization = "org.apache.parquet"),
ExclusionRule("org.pentaho", "pentaho-aggdesigner-algorithm"),
ExclusionRule(organization = "com.google.protobuf")
),
"org.apache.hadoop" % "hadoop-common" % hadoopVersion % "test" classifier "tests",
"org.apache.hadoop" % "hadoop-mapreduce-client-hs" % hadoopVersion % "test",
"org.apache.hadoop" % "hadoop-mapreduce-client-jobclient" % hadoopVersion % "test" classifier "tests",
"org.apache.hadoop" % "hadoop-yarn-server-tests" % hadoopVersion % "test" classifier "tests",
"org.apache.hive" % "hive-cli" % hiveVersion % "test" excludeAll(
ExclusionRule(organization = "org.apache.spark"),
ExclusionRule(organization = "org.apache.parquet"),
ExclusionRule("ch.qos.logback", "logback-classic"),
ExclusionRule("org.pentaho", "pentaho-aggdesigner-algorithm"),
ExclusionRule(organization = "com.google.protobuf")
),
"org.apache.hadoop" % "hadoop-yarn-common" % hadoopVersion % "test",
"org.apache.hadoop" % "hadoop-yarn-api" % hadoopVersion % "test",
"org.apache.tez" % "tez-mapreduce" % "0.8.4" % "test",
"org.apache.tez" % "tez-dag" % "0.8.4" % "test",
"org.apache.tez" % "tez-tests" % "0.8.4" % "test" classifier "tests",
// TODO Figure out how this fixes some bad dependency
"org.apache.spark" %% "spark-core" % sparkVersion % "test" classifier "tests",
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"io.delta" %% "delta-core" % deltaVersion % "test" excludeAll ExclusionRule("org.apache.hadoop")
)
)