-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sbt
164 lines (150 loc) · 4.92 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
import sbt.internal.ProjectMatrix
val scalaVer = "3.3.1"
ThisBuild / scalaVersion := scalaVer
ThisBuild / semanticdbEnabled := true
ThisBuild / scalacOptions ++= List(
"-Wunused:imports"
)
val munit = "org.scalameta" %% "munit" % "0.7.29"
val inputDirectory = Def.settingKey[File]("")
def sparkSqlDep(ver: String) =
("org.apache.spark" %% "spark-sql" % ver).cross(CrossVersion.for3Use2_13)
// See https://github.com/apache/spark/blob/v3.3.2/launcher/src/main/java/org/apache/spark/launcher/JavaModuleOptions.java
val unnamedJavaOptions = List(
"-XX:+IgnoreUnrecognizedVMOptions",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.base/java.net=ALL-UNNAMED",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.util.concurrent=ALL-UNNAMED",
"--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.cs=ALL-UNNAMED",
"--add-opens=java.base/sun.security.action=ALL-UNNAMED",
"--add-opens=java.base/sun.util.calendar=ALL-UNNAMED",
"--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED"
)
lazy val root = (project in file("."))
.aggregate(udf)
.aggregate(encoders)
.aggregate(examples.projectRefs: _*)
.settings(
publishSettings,
publish / skip := true
)
lazy val encoders = (project in file("encoders"))
.settings(
name := "spark-scala3-encoders",
libraryDependencies ++= Seq(
sparkSqlDep(sparkVersions.head.sparkVersion),
munit % Test
),
Test / fork := true,
Test / javaOptions ++= unnamedJavaOptions
// Test / javaOptions += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=1044"
)
.settings(publishSettings)
lazy val udf = (project in file("udf"))
.in(file("udf"))
.settings(
name := "spark-scala3-udf",
libraryDependencies ++= Seq(
sparkSqlDep(sparkVersions.head.sparkVersion),
munit % Test
),
Test / fork := true,
Test / javaOptions ++= unnamedJavaOptions
)
.settings(publishSettings)
.dependsOn(encoders)
lazy val examples =
sparkVersionMatrix(
projectMatrix in file("examples")
)
.enablePlugins(BuildInfoPlugin)
.settings(
publish / skip := true,
inputDirectory.withRank(
KeyRanks.Invisible
) := (ThisBuild / baseDirectory).value / "examples" / "input",
buildInfoKeys := Seq[BuildInfoKey](inputDirectory),
run / fork := true,
run / javaOptions ++= unnamedJavaOptions
)
addCommandAlias(
"latestExample",
s"${examples.finder(sparkVersions.head, VirtualAxis.jvm)(scalaVer).id}"
)
// Spark versions to check. Always most recent first.
lazy val sparkVersions = List(
SparkVersionAxis("_spark35_", "spark350", "3.5.0"),
SparkVersionAxis("_spark34_", "spark341", "3.4.1"),
SparkVersionAxis("_spark33_", "spark333", "3.3.3")
)
lazy val runAllMains = taskKey[Unit]("Run all mains")
runAllMains := Def.sequential {
examples.allProjects().map(_._1).map { project =>
Def.taskDyn {
val mainClasses = (project / Compile / discoveredMainClasses).value
Def.sequential {
mainClasses.map { mainClass =>
(project / Compile / runMain).toTask(" " + mainClass)
}
}
}
}
}.value
def sparkVersionMatrix(
projectRoot: ProjectMatrix
): ProjectMatrix = {
sparkVersions.foldLeft(projectRoot) { case (acc, axis) =>
acc.customRow(
scalaVersions = Seq(scalaVer),
axisValues = Seq(axis, VirtualAxis.jvm),
_.settings(
moduleName := name.value + axis.idSuffix,
publish / skip := true,
libraryDependencies += sparkSqlDep(axis.sparkVersion)
).dependsOn(encoders, udf)
)
}
}
import xerial.sbt.Sonatype._
lazy val publishSettings = Def.settings(
licenses := Seq(
"APL2" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")
),
organization := "io.github.vincenzobaz",
homepage := Some(url("https://github.com/vincenzobaz/spark-scala3")),
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
sonatypeCredentialHost := "s01.oss.sonatype.org",
publishTo := sonatypePublishToBundle.value,
developers := List(
Developer(
"vincenzobaz",
"Vincenzo Bazzucchi",
url("https://github.com/vincenzobaz/")
),
Developer(
"adpi2",
"Adrien Piquerez",
url("https://github.com/adpi2")
),
Developer(
"michael72",
"Michael Schulte",
url("https://github.com/michael72")
)
),
sonatypeProjectHosting := Some(
GitHubHosting("vincenzobaz", name.value, "[email protected]")
),
versionScheme := Some("early-semver"),
versionPolicyIntention := Compatibility.None
)