From e16fc54b1c0069df84a5d545ed0f4db1ce93e9a5 Mon Sep 17 00:00:00 2001 From: Elouan Appere Date: Thu, 5 Dec 2024 17:09:27 +0100 Subject: [PATCH] Backport build system fixes from upstream #1361 --- build.sbt | 15 +++++++++++---- project/Dependencies.scala | 13 +++++++++++++ project/Versions.scala | 12 ++---------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/build.sbt b/build.sbt index 5b7455036..7321278b1 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,8 @@ import sbt.{Compile, moduleFilter, _} import sbtassembly.AssemblyPlugin.autoImport.assembly lazy val scala212 = "2.12.11" -lazy val supportedScalaVersions = List(scala212) +lazy val scala213 = "2.13.11" +lazy val supportedScalaVersions = List(scala212, scala213) // factor out common settings ThisBuild / scalaVersion := scala212 @@ -60,9 +61,10 @@ lazy val commonSettings = Seq( fork := true, parallelExecution := true, testForkedParallel := false, - testOptions += Tests.Argument(TestFrameworks.JUnit, "-v") + testOptions += Tests.Argument(TestFrameworks.JUnit, "-v"), ) + val annotationProcessor = Seq( "-processor", "com.datastax.oss.driver.internal.mapper.processor.MapperProcessor" ) @@ -70,6 +72,7 @@ val annotationProcessor = Seq( def scalacVersionDependantOptions(scalaBinary: String): Seq[String] = scalaBinary match { case "2.11" => Seq() case "2.12" => Seq("-no-java-comments") //Scala Bug on inner classes, CassandraJavaUtil, + case "2.13" => Seq("-no-java-comments") //Scala Bug on inner classes, CassandraJavaUtil, } lazy val root = (project in file(".")) @@ -81,6 +84,7 @@ lazy val root = (project in file(".")) publish / skip := true ) + lazy val connector = (project in file("connector")) .configs(IntegrationTest) .settings(Defaults.itSettings: _*) //This and above enables the "it" suite @@ -105,6 +109,7 @@ lazy val connector = (project in file("connector")) Global / concurrentRestrictions := Seq(Tags.limitAll(Testing.parallelTasks)), libraryDependencies ++= Dependencies.Spark.dependencies + ++ Dependencies.Compatibility.dependencies(scalaVersion.value) ++ Dependencies.TestConnector.dependencies ++ Dependencies.Jetty.dependencies, @@ -121,7 +126,8 @@ lazy val testSupport = (project in file("test-support")) .settings( crossScalaVersions := supportedScalaVersions, name := "spark-cassandra-connector-test-support", - libraryDependencies ++= Dependencies.TestSupport.dependencies + libraryDependencies ++= Dependencies.Compatibility.dependencies(scalaVersion.value) + ++ Dependencies.TestSupport.dependencies ) lazy val driver = (project in file("driver")) @@ -131,7 +137,8 @@ lazy val driver = (project in file("driver")) crossScalaVersions := supportedScalaVersions, name := "spark-cassandra-connector-driver", assembly /test := {}, - libraryDependencies ++= Dependencies.Driver.dependencies + libraryDependencies ++= Dependencies.Compatibility.dependencies(scalaVersion.value) + ++ Dependencies.Driver.dependencies ++ Dependencies.TestDriver.dependencies :+ ("org.scala-lang" % "scala-reflect" % scalaVersion.value) ) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c8cb14ee7..d6d43598e 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -79,9 +79,22 @@ object Dependencies val commonsLang3 = "org.apache.commons" % "commons-lang3" % Versions.CommonsLang3 val paranamer = "com.thoughtworks.paranamer" % "paranamer" % Versions.Paranamer + val dependencies = Seq(driverCore, driverMapper, commonsLang3, paranamer) } + object Compatibility { + val scalaCompat = "org.scala-lang.modules" %% "scala-collection-compat" % Versions.ScalaCompat + val parallelCollections = "org.scala-lang.modules" %% "scala-parallel-collections" % Versions.ParallelCollections + + def dependencies(version: String): Seq[ModuleID] = { + CrossVersion.partialVersion(version) match { + case Some((2, scalaMajor)) if scalaMajor == 13 => Seq(scalaCompat, parallelCollections) + case _ => Seq(scalaCompat) + } + } + } + object TestDriver { val dependencies = Seq( TestCommon.scalaTest % "test", diff --git a/project/Versions.scala b/project/Versions.scala index 9004a8cdc..878bf2259 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -25,14 +25,6 @@ object Versions { val SparkJetty = "9.3.27.v20190418" val SolrJ = "8.3.0" - /* - val status = (versionInReapply: String, binaryInReapply: String) => - println(s""" - | Scala: $versionInReapply - | Scala Binary: $binaryInReapply - | Java: target=$JDK user=${Properties.javaVersion} - | Cassandra version for testing: ${Testing.cassandraTestVersion} [can be overridden by specifying '-Dtest.cassandra.version='] - """.stripMargin) - - */ + val ScalaCompat = "2.11.0" + val ParallelCollections = "1.0.4" }