forked from hablapps/doric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
216 lines (198 loc) · 6.61 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
import scala.language.postfixOps
//import sbt.Compile
val stableVersion = "0.0.7"
val sparkDefaultShortVersion = "3.4"
val spark30Version = "3.0.3"
val spark31Version = "3.1.3"
val spark32Version = "3.2.3"
val spark33Version = "3.3.2"
val spark34Version = "3.4.0"
val versionRegex = """^(.*)\.(.*)\.(.*)$""".r
val versionRegexShort = """^(.*)\.(.*)$""".r
val scala212 = "2.12.18"
val scala213 = "2.13.8"
val parserSparkVersion: String => String = {
case versionRegexShort("3", "0") => spark30Version
case versionRegexShort("3", "1") => spark31Version
case versionRegexShort("3", "2") => spark32Version
case versionRegexShort("3", "3") => spark33Version
case versionRegexShort("3", "4") => spark34Version
case versionRegex(a, b, c) => s"$a.$b.$c"
}
val long2ShortVersion: String => String = { case versionRegex(a, b, _) =>
s"$a.$b"
}
val scalaVersionSelect: String => List[String] = {
case versionRegex("3", "0", _) => List(scala212)
case versionRegex("3", "1", _) => List(scala212)
case versionRegex("3", "2", _) => List(scala212, scala213)
case versionRegex("3", "3", _) => List(scala212, scala213)
case versionRegex("3", "4", _) => List(scala212, scala213)
}
ThisBuild / organization := "org.hablapps"
ThisBuild / homepage := Some(url("https://github.com/hablapps/doric"))
ThisBuild / licenses := List(
"Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")
)
ThisBuild / developers := List(
Developer(
"AlfonsoRR",
"Alfonso Roa",
"@saco_pepe",
url("https://github.com/alfonsorr")
),
Developer(
"eruizalo",
"Eduardo Ruiz",
"",
url("https://github.com/eruizalo")
)
)
val sparkVersion = settingKey[String]("Spark version")
Global / sparkVersion :=
parserSparkVersion(
System.getProperty("sparkVersion", sparkDefaultShortVersion)
)
Global / scalaVersion := scalaVersionSelect(sparkVersion.value).head
Global / publish / skip := true
Global / publishArtifact := false
// scaladoc settings
Compile / doc / scalacOptions ++= Seq("-groups")
// test suite settings
Test / fork := true
javaOptions ++= Seq(
"-Xms512M",
"-Xmx2048M",
"-XX:MaxPermSize=2048M",
"-XX:+CMSClassUnloadingEnabled"
)
// Show runtime of tests
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oD")
scmInfo := Some(
ScmInfo(
url("https://github.com/hablapps/doric"),
"[email protected]:hablapps/doric.git"
)
)
updateOptions := updateOptions.value.withLatestSnapshots(false)
val configSpark = Seq(
sparkVersion := parserSparkVersion(
System.getProperty("sparkVersion", sparkDefaultShortVersion)
)
)
val scalaOptionsCommon = Seq(
"-encoding",
"utf8", // Option and arguments on same line
"-Xfatal-warnings", // New lines for each options
"-deprecation",
"-unchecked",
"-language:implicitConversions",
"-language:higherKinds",
"-language:existentials",
"-language:postfixOps",
"-Ywarn-numeric-widen"
)
lazy val core = project
.in(file("core"))
.settings(
configSpark,
name := "doric_" + long2ShortVersion(sparkVersion.value),
run / fork := true,
publish / skip := false,
publishArtifact := true,
scalaVersion := scalaVersionSelect(sparkVersion.value).head,
crossScalaVersions := scalaVersionSelect(sparkVersion.value),
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % sparkVersion.value % "provided", // scala-steward:off
"org.typelevel" %% "cats-core" % "2.10.0",
"com.lihaoyi" %% "sourcecode" % "0.3.1",
"com.chuusai" %% "shapeless" % "2.3.10",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0",
"com.github.mrpowers" %% "spark-fast-tests" % "1.3.0" % "test",
"org.scalatest" %% "scalatest" % "3.2.17" % "test"
),
// docs
run / fork := true,
Compile / doc / autoAPIMappings := true,
Compile / doc / scalacOptions ++= Seq(
"-groups",
"-implicits",
"-skip-packages",
"org.apache.spark"
),
Compile / unmanagedSourceDirectories ++= {
(sparkVersion.value match {
case versionRegex(mayor, minor, _) =>
(Compile / sourceDirectory).value ** s"*spark_*$mayor.$minor*" / "scala" get
}) ++
(scalaVersion.value match {
case versionRegex(mayor, minor, _) =>
(Compile / sourceDirectory).value ** s"*scala_*$mayor.$minor*" / "scala" get
})
},
Test / unmanagedSourceDirectories ++= {
(sparkVersion.value match {
case versionRegex(mayor, minor, _) =>
(Test / sourceDirectory).value ** s"*spark_*$mayor.$minor*" / "scala" get
}) ++
(scalaVersion.value match {
case versionRegex(mayor, minor, _) =>
(Test / sourceDirectory).value ** s"*scala_*$mayor.$minor*" / "scala" get
})
},
scalacOptions ++= {
scalaOptionsCommon ++ {
if (scalaVersion.value.startsWith("2.13"))
Seq.empty
else
Seq("-Ypartial-unification")
}
}
)
val plugins = parserSparkVersion(
System.getProperty("sparkVersion", sparkDefaultShortVersion)
) match {
case versionRegex("2", "4", _) => List.empty[Plugins]
case _ => List(MdocPlugin)
}
lazy val docs = project
.in(file("docs"))
.dependsOn(core)
.settings(
configSpark,
run / fork := true,
publish / skip := true,
publishArtifact := false,
run / javaOptions += "-XX:MaxJavaStackTraceDepth=10",
scalaVersion := scalaVersionSelect(sparkVersion.value).head,
mdocIn := baseDirectory.value / "docs",
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % sparkVersion.value
),
mdocVariables := Map(
// VERSION is not working well? 0.0.0+1-6f46b6de-SNAPSHOT
// ^^^^^
"VERSION" -> version.value,
"STABLE_VERSION" -> stableVersion,
"SPARK_VERSION" -> sparkVersion.value,
"SPARK_SHORT_VERSION" -> long2ShortVersion(sparkVersion.value)
.replace(".", "-"),
"SCALA_SHORT_VERSION" -> long2ShortVersion(scalaVersion.value)
),
mdocExtraArguments := Seq(
"--clean-target"
),
scalacOptions ++= {
scalaOptionsCommon ++ {
if (scalaVersion.value.startsWith("2.13"))
Seq.empty
else
Seq("-Ypartial-unification")
}
}
)
.enablePlugins(plugins *)
// Scoverage settings
Global / coverageEnabled := false
Global / coverageFailOnMinimum := false
Global / coverageHighlighting := true