forked from starlake-ai/starlake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
274 lines (230 loc) · 7.85 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
import Dependencies._
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
import sbtrelease.Version.Bump.Next
import xerial.sbt.Sonatype._
// require Java 8 for Spark 2 support
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
lazy val scala212 = "2.12.17"
ThisBuild / crossScalaVersions := List(scala212)
organization := "ai.starlake"
organizationName := "starlake"
ThisBuild / scalaVersion := scala212
organizationHomepage := Some(url("https://github.com/starlake-ai/starlake"))
resolvers ++= Resolvers.allResolvers
libraryDependencies ++= {
val (spark, jackson, esSpark, pureConfigs) = {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => (spark_3d0_forScala_2d12, jackson212ForSpark3, esSpark212, pureConfig212)
case _ => throw new Exception(s"Invalid Scala Version")
}
}
dependencies ++ spark ++ jackson ++ esSpark ++ pureConfigs ++ scalaReflection(scalaVersion.value)
}
dependencyOverrides := Seq(
"org.scala-lang" % "scala-library" % scalaVersion.value,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value
)
name := {
val sparkNameSuffix = {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => "3"
case _ => throw new Exception(s"Invalid Scala Version")
}
}
s"starlake-spark$sparkNameSuffix"
}
assembly / assemblyJarName := s"${name.value}_${scalaBinaryVersion.value}-${version.value}-assembly.jar"
Common.enableCometAliases
enablePlugins(Common.cometPlugins: _*)
Common.customSettings
// Builds a far JAR with embedded spark libraries and other provided libs.
// Can be useful for running YAML generation without having a spark distribution
commands += Command.command("assemblyWithSpark") { state =>
"""set assembly / fullClasspath := (Compile / fullClasspath).value""" :: "assembly" :: state
}
// Assembly
Test / fork := true
Test / envVars := Map("GOOGLE_CLOUD_PROJECT" -> "some-gcp-project")
Compile / assembly / artifact := {
val art: Artifact = (Compile / assembly / artifact).value
art.withClassifier(Some("assembly"))
}
addArtifact(Compile / assembly / artifact, assembly)
assembly / assemblyMergeStrategy := {
case "META-INF/services/org.apache.spark.sql.sources.DataSourceRegister" => MergeStrategy.concat
case PathList("META-INF", "services", _ @_*) => MergeStrategy.concat
case PathList("META-INF", _ @_*) => MergeStrategy.discard
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
}
// Required by the Test container framework
Test / fork := true
assembly / assemblyExcludedJars := {
val cp: Classpath = (assembly / fullClasspath).value
val sortedCp = cp.sortBy(_.data.getName)
sortedCp.foreach(x => println("->" + x.data.getName))
sortedCp filter { jar =>
val jarList = List(
"netty-buffer-",
"netty-common-",
"arrow-memory-core-",
"arrow-memory-netty-",
"arrow-format-",
"arrow-vector-",
"commons-codec-",
// "commons-compress-", // Because POI needs it
"commons-logging-",
"commons-math3-",
"flatbuffers-java-",
// "gson-", // because BigQuery needs com.google.gson.JsonParser.parseString(Ljava/lang/String;)
//"guava-", // BigQuery needs com/google/common/base/MoreObjects (guava-20)
"hadoop-client-api-",
"hadoop-client-runtime-",
"httpclient-",
"httpcore-",
"jackson-datatype-jsr310-",
"json-",
"jsr305-",
"lz4-java-",
// "protobuf-java-", // BigQuery needs com/google/protobuf/GeneratedMessageV3
"scala-compiler-",
"scala-library-",
"scala-parser-combinators_",
"scala-reflect-",
"scala-xml_",
"shapeless_",
"slf4j-api-",
"snappy-java-",
"spark-tags_",
"threeten-extra-",
"xz-",
"zstd-jni-"
)
if (jarList.exists(jar.data.getName.startsWith)) {
println("Exclude ->" + jar.data.getName)
true
}
else
false
}
}
assembly / assemblyShadeRules := Seq(
// poi needs a newer version of commons-compress (> 1.17) than the one shipped with spark 2.4.X
ShadeRule.rename("org.apache.commons.compress.**" -> "poiShade.commons.compress.@1").inAll,
// ShadeRule.rename("shapeless.**" -> "shade.@0").inAll,
//shade it or else writing to bigquery wont work because spark comes with an older version of google common.
ShadeRule.rename("com.google.common.**" -> "shade.@0").inAll,
ShadeRule.rename("com.google.gson.**" -> "shade.@0").inAll,
ShadeRule.rename("com.google.protobuf.**" -> "shade.@0").inAll
)
// Publish
publishTo := {
(
sys.env.get("GCS_BUCKET_ARTEFACTS"),
sys.env.getOrElse("RELEASE_SONATYPE", "true").toBoolean
) match {
case (None, false) =>
sonatypePublishToBundle.value
case (None, true) => sonatypePublishToBundle.value
case (Some(value), _) =>
Some(GCSPublisher.forBucket(value, AccessRights.InheritBucket))
}
}
// Disable scaladoc generation
Compile / doc / sources := Seq.empty
//Compile / packageDoc / publishArtifact := false
Compile / packageBin / publishArtifact := true
Compile / packageSrc / publishArtifact := true
// Do not disable checksum
publishLocal / checksums := Nil
// publish / checksums := Nil
// Your profile name of the sonatype account. The default is the same with the organization value
sonatypeProfileName := "ai.starlake"
// To sync with Maven central, you need to supply the following information:
publishMavenStyle := true
// Open-source license of your choice
licenses := Seq(
"Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")
)
sonatypeProjectHosting := Some(
GitHubHosting("starlake-ai", "starlake", "[email protected]")
)
// Release
releaseCrossBuild := true
releaseIgnoreUntrackedFiles := true
releaseProcess := Seq(
checkSnapshotDependencies,
inquireVersions,
runClean,
// releaseStepCommand("+test"),
setReleaseVersion,
commitReleaseVersion, // forces to push dirty files
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
releaseCommitMessage := s"Release ${ReleasePlugin.runtimeVersion.value}"
releaseVersionBump := Next
developers := List(
Developer(
id = "hayssams",
name = "Hayssam Saleh",
email = "[email protected]",
url = url("https://github.com/hayssams")
),
Developer(
id = "elarib",
name = "Abdelhamide Elarib",
email = "[email protected]",
url = url("https://github.com/elarib")
),
Developer(
id = "cchepelov",
name = "Cyrille Chepelov",
email = "[email protected]",
url = url("https://github.com/cchepelov")
),
Developer(
id = "AmineSagaama",
name = "Amine Sagaama",
email = "[email protected]",
url = url("https://github.com/AmineSagaama")
),
Developer(
id = "mhdqassir",
name = "Mohamad Kassir",
email = "[email protected]",
url = url("https://github.com/mhdkassir")
),
Developer(
id = "mmenestret",
name = "Martin Menestret",
email = "[email protected]",
url = url("https://github.com/mmenestret")
),
Developer(
id = "pchalcol",
name = "Patice Chalcol",
email = "[email protected]",
url = url("https://github.com/pchalcol")
),
Developer(
id = "zedach",
name = "Mourad Dachraoui",
email = "[email protected]",
url = url("https://github.com/zedach")
),
Developer(
id = "seyguai",
name = "Nicolas Boussuge",
email = "[email protected]",
url = url("https://github.com/seyguai")
)
)
//assembly / logLevel := Level.Debug
// addCompilerPlugin("io.tryp" % "splain" % "0.5.8" cross CrossVersion.patch)