@@ -18,24 +18,42 @@ import sbt._
1818
1919object Dependencies {
2020
21- def sparkVersion : String = sys.props.getOrElse(" SPARK_VERSION" , " 2.4.8" )
22- private val sparkHofsVersion = " 0.4.0"
21+ val defaultSparkVersionForScala211 = " 2.4.8"
22+ val defaultSparkVersionForScala212 = " 3.3.2"
23+ val defaultSparkVersionForScala213 = " 3.4.1"
2324
24- private val scalatestVersion = " 3.0.3"
25+ private val sparkHofsVersion = " 0.4.0"
26+ private val scalatestVersion = " 3.2.14"
2527
2628 def getScalaDependency (scalaVersion : String ): ModuleID = " org.scala-lang" % " scala-library" % scalaVersion % Provided
2729
28- val SparkHatsDependencies : Seq [ModuleID ] = Seq (
29- // compile
30- " za.co.absa" %% " spark-hofs" % sparkHofsVersion,
31-
30+ def getSparkHatsDependencies (scalaVersion : String ): Seq [ModuleID ] = Seq (
3231 // provided
33- " org.apache.spark" %% " spark-core" % sparkVersion % Provided ,
34- " org.apache.spark" %% " spark-sql" % sparkVersion % Provided ,
35- " org.apache.spark" %% " spark-catalyst" % sparkVersion % Provided ,
32+ " org.apache.spark" %% " spark-core" % sparkVersion(scalaVersion) % Provided ,
33+ " org.apache.spark" %% " spark-sql" % sparkVersion(scalaVersion) % Provided ,
34+ " org.apache.spark" %% " spark-catalyst" % sparkVersion(scalaVersion) % Provided ,
3635
3736 // test
3837 " org.scalatest" %% " scalatest" % scalatestVersion % Test
3938 )
4039
40+ def getHofsDependency (scalaVersion : String ): Seq [ModuleID ] = if (scalaVersion.startsWith(" 2.11." )) {
41+ Seq (" za.co.absa" %% " spark-hofs" % sparkHofsVersion)
42+ } else {
43+ Seq .empty
44+ }
45+
46+ def sparkVersion (scalaVersion : String ): String = sys.props.getOrElse(" SPARK_VERSION" , sparkFallbackVersion(scalaVersion))
47+
48+ def sparkFallbackVersion (scalaVersion : String ): String = {
49+ if (scalaVersion.startsWith(" 2.11." )) {
50+ defaultSparkVersionForScala211
51+ } else if (scalaVersion.startsWith(" 2.12." )) {
52+ defaultSparkVersionForScala212
53+ } else if (scalaVersion.startsWith(" 2.13." )) {
54+ defaultSparkVersionForScala213
55+ } else {
56+ throw new IllegalArgumentException (s " Scala $scalaVersion not supported. " )
57+ }
58+ }
4159}
0 commit comments