11name := " data-validator"
22organization := " com.target"
33
4- scalaVersion := " 2.11.12 "
4+ val sparkVersion = settingKey[ String ]( " Spark version " )
55
6- val sparkVersion = " 2.3.4"
6+ sparkVersion := System .getProperty( " sparkVersion " , " 2.3.4" )
77
8- val circeVersion = " 0.11.2"
8+ scalaVersion := {
9+ if (sparkVersion.value > " 3.0" ) {
10+ " 2.12.19"
11+ } else {
12+ " 2.11.12"
13+ }
14+ }
15+
16+ val sparkValidationVersion = settingKey[String ](" Version of package" )
17+
18+ sparkValidationVersion := " 0.15.0"
19+
20+ version := sparkVersion.value + " _" + sparkValidationVersion.value
21+
22+ val circeVersion = settingKey[String ](" Circe version" )
23+ val circeYamlVersion = settingKey[String ](" Circe YAML version" )
24+
25+ circeVersion := {
26+ if (sparkVersion.value > " 3.0" ) {
27+ " 0.14.6"
28+ } else {
29+ " 0.11.2"
30+ }
31+ }
32+
33+ circeYamlVersion := {
34+ if (sparkVersion.value > " 3.0" ) {
35+ " 0.15.1"
36+ } else {
37+ " 0.10.1"
38+ }
39+ }
940
1041// addDependencyTreePlugin
1142enablePlugins(GitVersioning )
@@ -35,18 +66,28 @@ libraryDependencies ++= Seq(
3566 " com.github.scopt" %% " scopt" % " 4.1.0" ,
3667 " com.sun.mail" % " javax.mail" % " 1.6.2" ,
3768 " com.lihaoyi" %% " scalatags" % " 0.12.0" ,
38- " io.circe" %% " circe-yaml" % " 0.10.1 " ,
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 ,
69+ " io.circe" %% " circe-yaml" % circeYamlVersion.value ,
70+ " io.circe" %% " circe-core" % circeVersion.value ,
71+ " io.circe" %% " circe-generic" % circeVersion.value ,
72+ " io.circe" %% " circe-parser" % circeVersion.value ,
73+ " org.apache.spark" %% " spark-sql" % sparkVersion.value % Provided ,
4374 " junit" % " junit" % " 4.13.2" % Test ,
44- " org.scalatest" %% " scalatest" % " 3.2.15 " % Test ,
75+ " org.scalatest" %% " scalatest" % " 3.2.18 " % Test ,
4576 " com.github.sbt" % " junit-interface" % " 0.13.3" % Test exclude (" junit" , " junit-dep" )
4677)
4778
4879Test / fork := true
49- javaOptions ++= Seq (" -Xms512M" , " -Xmx2048M" , " -XX:+CMSClassUnloadingEnabled" )
80+ javaOptions ++= (if (sparkVersion.value > " 3.0" && System .getenv(" MODERN_JAVA" ) == " TRUE" ) {
81+ // For modern Java we need to open up a lot of config options.
82+ Seq (" -Xms4048M" , " -Xmx4048M" ,
83+ // these were added in JDK 11 and newer, apparently.
84+ " -Dio.netty.tryReflectionSetAccessible=true" ,
85+ " --add-opens=java.base/java.lang=ALL-UNNAMED" ,
86+ " --add-opens=java.base/java.io=ALL-UNNAMED" ,
87+ " --add-opens=java.base/sun.nio.ch=ALL-UNNAMED" )
88+ } else {
89+ Seq (" -Xms4048M" , " -Xmx4048M" )
90+ })
5091Test / parallelExecution := false
5192// required for unit tests, but not set in some environments
5293Test / envVars ++= Map (
@@ -57,6 +98,11 @@ Test / envVars ++= Map(
5798
5899assembly / mainClass := Some (" com.target.data_validator.Main" )
59100
101+ assembly / assemblyShadeRules := Seq (
102+ ShadeRule .rename(" shapeless.**" -> " new_shapeless.@1" ).inAll,
103+ ShadeRule .rename(" cats.kernel.**" -> s " new_cats.kernel.@1 " ).inAll
104+ )
105+
60106// Enforces scalastyle checks
61107val compileScalastyle = TaskKey [Unit ](" compileScalastyle" )
62108scalastyleFailOnWarning := true
@@ -75,6 +121,6 @@ compileScalastyle := (Compile / scalastyle).toTask("").value
75121
76122(Compile / runMain) := Defaults .runMainTask(Compile / fullClasspath, Compile / run / runner).evaluated
77123TaskKey [Unit ](" generateTestData" ) := {
78- libraryDependencies += " org.apache.spark" %% " spark-sql" % sparkVersion
124+ libraryDependencies += " org.apache.spark" %% " spark-sql" % sparkVersion.value
79125 (Compile / runMain).toTask(" com.target.data_validator.GenTestData" ).value
80126}
0 commit comments