1
- name := " data-validator"
2
- organization := " com.target"
3
-
4
- scalaVersion := " 2.11.12"
5
-
6
- val sparkVersion = " 2.3.1"
7
-
8
1
val circeVersion = " 0.10.0"
9
2
10
- // addDependencyTreePlugin
3
+ val scala211 = " 2.11.12"
4
+ val scala212 = " 2.12.15"
5
+ val scala213 = " 2.13.8"
6
+
7
+ ThisBuild / organization := " com.target"
11
8
enablePlugins(GitVersioning )
12
- git.useGitDescribe := true
9
+ ThisBuild / git.useGitDescribe := true
13
10
ThisBuild / versionScheme := Some (" early-semver" )
14
11
12
+ // sbt auto-reload on changes
13
+ Global / onChangedBuildSource := ReloadOnSourceChanges
14
+
15
+ // Enforces scalastyle checks
16
+ val compileScalastyle = TaskKey [Unit ](" compileScalastyle" )
17
+ val generateTestData = TaskKey [Unit ](" generateTestData" )
18
+
15
19
// ///////////
16
20
// Publishing
17
21
// ///////////
@@ -23,59 +27,77 @@ githubRepository := "data-validator"
23
27
githubTokenSource := (TokenSource .Environment (" GITHUB_TOKEN" ) ||
24
28
TokenSource .GitConfig (" github.token" ) ||
25
29
TokenSource .Environment (" SHELL" )) // it's safe to assume this exists and is not unique
26
-
27
30
publishTo := githubPublishTo.value
28
31
29
- enablePlugins(BuildInfoPlugin )
30
- buildInfoKeys := Seq [BuildInfoKey ](name, version, scalaVersion, sbtVersion)
31
- buildInfoPackage := " com.target.data_validator"
32
+ lazy val commonSettings : SettingsDefinition = Def .settings(
33
+ name := " data-validator" ,
34
+ buildInfoKeys := Seq [BuildInfoKey ](name, version, scalaVersion, sbtVersion),
35
+ buildInfoPackage := " com.target.data_validator" ,
36
+ libraryDependencies ++= Seq (
37
+ " com.typesafe.scala-logging" %% " scala-logging" % " 3.8.0" ,
38
+ " com.github.scopt" %% " scopt" % " 3.7.0" ,
39
+ " com.sun.mail" % " javax.mail" % " 1.6.2" ,
40
+ " com.lihaoyi" %% " scalatags" % " 0.6.7" ,
41
+ " io.circe" %% " circe-yaml" % " 0.9.0" ,
42
+ " io.circe" %% " circe-core" % circeVersion,
43
+ " io.circe" %% " circe-generic" % circeVersion,
44
+ " io.circe" %% " circe-parser" % circeVersion,
45
+ // "org.apache.spark" %% "spark-sql" % sparkVersion % Provided,
46
+ " org.scalatest" %% " scalatest" % " 3.0.5" % Test ,
47
+ " junit" % " junit" % " 4.12" % Test ,
48
+ " com.novocode" % " junit-interface" % " 0.11" % Test exclude (" junit" , " junit-dep" )
49
+ ),
50
+ (Test / fork) := true ,
51
+ javaOptions ++= Seq (" -Xms512M" , " -Xmx2048M" , " -XX:+CMSClassUnloadingEnabled" ),
52
+ (Test / parallelExecution) := false ,
32
53
33
- libraryDependencies ++= Seq (
34
- " com.typesafe.scala-logging" %% " scala-logging" % " 3.8.0" ,
35
- " com.github.scopt" %% " scopt" % " 3.7.0" ,
36
- " com.sun.mail" % " javax.mail" % " 1.6.2" ,
37
- " com.lihaoyi" %% " scalatags" % " 0.6.7" ,
38
- " io.circe" %% " circe-yaml" % " 0.9.0" ,
39
- " io.circe" %% " circe-core" % circeVersion,
40
- " io.circe" %% " circe-generic" % circeVersion,
41
- " io.circe" %% " circe-parser" % circeVersion,
42
- " org.apache.spark" %% " spark-sql" % sparkVersion % Provided ,
43
-
44
- " org.scalatest" %% " scalatest" % " 3.0.5" % Test ,
45
- " junit" % " junit" % " 4.12" % Test ,
46
- " com.novocode" % " junit-interface" % " 0.11" % Test exclude (" junit" , " junit-dep" )
47
- )
54
+ // required for unit tests, but not set in some environments
55
+ (Test / envVars) ++= Map (
56
+ " JAVA_HOME" ->
57
+ Option (System .getenv(" JAVA_HOME" ))
58
+ .getOrElse(System .getProperty(" java.home" ))
59
+ ),
60
+ (assembly / mainClass) := Some (" com.target.data_validator.Main" ),
61
+ scalastyleFailOnWarning := true ,
62
+ scalastyleFailOnError := true ,
63
+ compileScalastyle := (Compile / scalastyle).toTask(" " ).value,
64
+ (Compile / compile) := ((Compile / compile) dependsOn compileScalastyle).value,
65
+ (Compile / run) := Defaults
66
+ .runTask(Compile / fullClasspath, Compile / run / mainClass, Compile / run / runner)
67
+ .evaluated,
48
68
49
- Test / fork := true
50
- javaOptions ++= Seq (" -Xms512M" , " -Xmx2048M" , " -XX:+CMSClassUnloadingEnabled" )
51
- Test / parallelExecution := false
52
- // required for unit tests, but not set in some environments
53
- Test / envVars ++= Map (
54
- " JAVA_HOME" ->
55
- Option (System .getenv(" JAVA_HOME" ))
56
- .getOrElse(System .getProperty(" java.home" ))
69
+ // ///////////
70
+ // Publishing
71
+ // ///////////
72
+ githubOwner := " target" ,
73
+ githubRepository := " data-validator" ,
74
+ // this unfortunately must be set strangely because GitHub requires a token for pulling packages
75
+ // and sbt-github-packages does not allow the user to configure the resolver not to be used.
76
+ // https://github.com/djspiewak/sbt-github-packages/issues/28
77
+ githubTokenSource := (TokenSource .Environment (" GITHUB_TOKEN" ) ||
78
+ TokenSource .GitConfig (" github.token" ) ||
79
+ TokenSource .Environment (" SHELL" )), // it's safe to assume this exists and is not unique
80
+ publishTo := githubPublishTo.value
57
81
)
58
82
59
- assembly / mainClass := Some (" com.target.data_validator.Main" )
60
-
61
- // Enforces scalastyle checks
62
- val compileScalastyle = TaskKey [Unit ](" compileScalastyle" )
63
- scalastyleFailOnWarning := true
64
- scalastyleFailOnError := true
65
-
66
- compileScalastyle := (Compile / scalastyle).toTask(" " ).value
67
- (Compile / compile) := ((Compile / compile) dependsOn compileScalastyle).value
68
-
69
- (Compile / run) := Defaults
70
- .runTask(
71
- Compile / fullClasspath,
72
- Compile / run / mainClass,
73
- Compile / run / runner
83
+ lazy val root = (projectMatrix in file(" ." ))
84
+ .enablePlugins(BuildInfoPlugin )
85
+ .settings(commonSettings)
86
+ .jvmPlatform(
87
+ scalaVersions = Seq (scala211),
88
+ settings = Seq (
89
+ libraryDependencies += " org.apache.spark" %% " spark-sql" % " 2.3.4" % Provided ,
90
+ (Compile / runMain) := Defaults .runMainTask(Compile / fullClasspath, Compile / run / runner).evaluated,
91
+ generateTestData := {
92
+ (Compile / runMain).toTask(" com.target.data_validator.GenTestData" ).value
93
+ }
94
+ )
95
+ )
96
+ .jvmPlatform(
97
+ scalaVersions = Seq (scala212),
98
+ settings = Seq (libraryDependencies += " org.apache.spark" %% " spark-sql" % " 2.4.8" % Provided )
99
+ )
100
+ .jvmPlatform(
101
+ scalaVersions = Seq (scala213),
102
+ settings = Seq (libraryDependencies += " org.apache.spark" %% " spark-sql" % " 3.2.1" % Provided )
74
103
)
75
- .evaluated
76
-
77
- (Compile / runMain) := Defaults .runMainTask(Compile / fullClasspath, Compile / run / runner).evaluated
78
- TaskKey [Unit ](" generateTestData" ) := {
79
- libraryDependencies += " org.apache.spark" %% " spark-sql" % sparkVersion
80
- (Compile / runMain).toTask(" com.target.data_validator.GenTestData" ).value
81
- }
0 commit comments