-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.sbt
115 lines (105 loc) · 4.34 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
val scala211 = "2.11.12"
val scala212 = "2.12.15"
val scala213 = "2.13.8"
val sparkVersion = "2.3.4"
// addDependencyTreePlugin
ThisBuild / organization := "com.target"
enablePlugins(GitVersioning)
ThisBuild / git.useGitDescribe := true
ThisBuild / versionScheme := Some("early-semver")
// sbt auto-reload on changes
Global / onChangedBuildSource := ReloadOnSourceChanges
// Enforces scalastyle checks
val compileScalastyle = TaskKey[Unit]("compileScalastyle")
val generateTestData = TaskKey[Unit]("generateTestData")
val circeVersion = SettingKey[String]("circeVersion")
val circeYamlVersion = SettingKey[String]("circeYamlVersion")
/////////////
// Publishing
/////////////
githubOwner := "target"
githubRepository := "data-validator"
// this unfortunately must be set strangely because GitHub requires a token for pulling packages
// and sbt-github-packages does not allow the user to configure the resolver not to be used.
// https://github.com/djspiewak/sbt-github-packages/issues/28
githubTokenSource := (TokenSource.Environment("GITHUB_TOKEN") ||
TokenSource.GitConfig("github.token") ||
TokenSource.Environment("SHELL")) // it's safe to assume this exists and is not unique
publishTo := githubPublishTo.value
lazy val commonSettings: SettingsDefinition = Def.settings(
name := "data-validator",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "com.target.data_validator",
libraryDependencies ++= Seq(
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"com.github.scopt" %% "scopt" % "4.1.0",
"com.sun.mail" % "javax.mail" % "1.6.2",
"com.lihaoyi" %% "scalatags" % "0.11.1",
"io.circe" %% "circe-yaml" % circeYamlVersion.value,
"io.circe" %% "circe-core" % circeVersion.value,
"io.circe" %% "circe-generic" % circeVersion.value,
"io.circe" %% "circe-parser" % circeVersion.value,
// "org.apache.spark" %% "spark-sql" % sparkVersion % Provided,
"org.scalatest" %% "scalatest" % "3.2.13" % Test
),
(Test / fork) := true,
javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:+CMSClassUnloadingEnabled"),
(Test / parallelExecution) := false,
// required for unit tests, but not set in some environments
(Test / envVars) ++= Map(
"JAVA_HOME" ->
Option(System.getenv("JAVA_HOME"))
.getOrElse(System.getProperty("java.home"))
),
(assembly / mainClass) := Some("com.target.data_validator.Main"),
scalastyleFailOnWarning := true,
scalastyleFailOnError := true,
compileScalastyle := (Compile / scalastyle).toTask("").value,
(Compile / compile) := ((Compile / compile) dependsOn compileScalastyle).value,
(Compile / run) := Defaults
.runTask(Compile / fullClasspath, Compile / run / mainClass, Compile / run / runner)
.evaluated,
/////////////
// Publishing
/////////////
githubOwner := "target",
githubRepository := "data-validator",
// this unfortunately must be set strangely because GitHub requires a token for pulling packages
// and sbt-github-packages does not allow the user to configure the resolver not to be used.
// https://github.com/djspiewak/sbt-github-packages/issues/28
githubTokenSource := (TokenSource.Environment("GITHUB_TOKEN") ||
TokenSource.GitConfig("github.token") ||
TokenSource.Environment("SHELL")), // it's safe to assume this exists and is not unique
publishTo := githubPublishTo.value
)
lazy val root = (projectMatrix in file("."))
.enablePlugins(BuildInfoPlugin)
.settings(commonSettings)
.jvmPlatform(
scalaVersions = Seq(scala211),
settings = Seq(
circeVersion := "0.11.2",
circeYamlVersion := "0.10.1",
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.3.4" % Provided,
(Compile / runMain) := Defaults.runMainTask(Compile / fullClasspath, Compile / run / runner).evaluated,
generateTestData := {
(Compile / runMain).toTask(" com.target.data_validator.GenTestData").value
}
)
)
.jvmPlatform(
scalaVersions = Seq(scala212),
settings = Seq(
circeVersion := "0.14.2",
circeYamlVersion := "0.14.1",
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.4.8" % Provided
)
)
.jvmPlatform(
scalaVersions = Seq(scala213),
settings = Seq(
circeVersion := "0.14.2",
circeYamlVersion := "0.14.1",
libraryDependencies += "org.apache.spark" %% "spark-sql" % "3.2.1" % Provided
)
)