From cdf18c2c5073b4b339178aa0ccfa8cb20844a93d Mon Sep 17 00:00:00 2001 From: Ladislav Sulak Date: Tue, 17 Oct 2023 14:37:15 +0200 Subject: [PATCH] #77: post-review changes - making Server only in Scala 2.12, but agent (and model) in 2.11, 2.12, and 2.13 --- build.sbt | 18 ++++--------- project/Dependencies.scala | 4 ++- .../atum/web/dao/InMemoryApiModelDao.scala | 6 ++--- .../dao/JavaConvertersWrapper.scala | 25 ------------------- .../atum/web/dao/JavaConvertersWrapper.scala | 25 ------------------- 5 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 server/src/main/scala_2.12-/za.co.absa.atum.web/dao/JavaConvertersWrapper.scala delete mode 100644 server/src/main/scala_2.13+/za/co/absa/atum/web/dao/JavaConvertersWrapper.scala diff --git a/build.sbt b/build.sbt index 74c4c281e..61642e242 100644 --- a/build.sbt +++ b/build.sbt @@ -24,7 +24,6 @@ ThisBuild / organization := "za.co.absa" ThisBuild / name := "atum-service" ThisBuild / scalaVersion := Versions.scala212 // default version -ThisBuild / crossScalaVersions := Versions.supportedScalaVersions ThisBuild / versionScheme := Some("early-semver") @@ -58,6 +57,7 @@ lazy val root = (projectMatrix in file(".")) name := "atum-service-root", javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint"), publish / skip := true, + crossScalaVersions := Nil, mergeStrategy ) @@ -68,15 +68,7 @@ lazy val server = (projectMatrix in file("server")) libraryDependencies ++= Dependencies.serverDependencies, Compile / packageBin / publishArtifact := false, (Compile / compile) := ((Compile / compile) dependsOn printSparkScalaVersion).value, - Compile / unmanagedSourceDirectories += { - val sourceDir = (Compile / sourceDirectory).value - if (scalaVersion.value.startsWith("2.13")) { - sourceDir / "scala_2.13+" - } - else { - sourceDir / "scala_2.12-" - } - }, + crossScalaVersions := Seq(Versions.serverScalaVersion), packageBin := (Compile / assembly).value, artifactPath / (Compile / packageBin) := baseDirectory.value / s"target/${name.value}-${version.value}.war", webappWebInfClasses := true, @@ -91,7 +83,7 @@ lazy val server = (projectMatrix in file("server")) .enablePlugins(AssemblyPlugin) .enablePlugins(TomcatPlugin) .enablePlugins(AutomateHeaderPlugin) - .jvmPlatform(scalaVersions = Versions.supportedScalaVersions) + .jvmPlatform(scalaVersions = Seq(Versions.serverScalaVersion)) .dependsOn(model) lazy val agent = (projectMatrix in file("agent")) @@ -112,7 +104,7 @@ lazy val agent = (projectMatrix in file("agent")) ) .sparkRow(SparkVersionAxis(Versions.spark2), scalaVersions = Seq(Versions.scala211, Versions.scala212)) .sparkRow(SparkVersionAxis(Versions.spark3), scalaVersions = Seq(Versions.scala212, Versions.scala213)) - .jvmPlatform(scalaVersions = Versions.supportedScalaVersions) + .jvmPlatform(scalaVersions = Versions.agentSupportedScalaVersions) .dependsOn(model) lazy val model = (projectMatrix in file("model")) @@ -127,4 +119,4 @@ lazy val model = (projectMatrix in file("model")) jacocoReportSettings := jacocoSettings(scalaVersion.value, "atum-agent: model"), jacocoExcludes := jacocoProjectExcludes() ) - .jvmPlatform(scalaVersions = Versions.supportedScalaVersions) + .jvmPlatform(scalaVersions = Versions.agentSupportedScalaVersions) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c6df4c569..cea4d9b8d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -25,7 +25,9 @@ object Dependencies { val scala211 = "2.11.12" val scala212 = "2.12.18" val scala213 = "2.13.11" - val supportedScalaVersions: Seq[String] = Seq(scala211, scala212, scala213) + + val serverScalaVersion: String = scala212 + val agentSupportedScalaVersions: Seq[String] = Seq(scala211, scala212, scala213) val scalatest = "3.2.15" val scalaMockito = "1.17.12" diff --git a/server/src/main/scala/za/co/absa/atum/web/dao/InMemoryApiModelDao.scala b/server/src/main/scala/za/co/absa/atum/web/dao/InMemoryApiModelDao.scala index 402974d98..118a95859 100644 --- a/server/src/main/scala/za/co/absa/atum/web/dao/InMemoryApiModelDao.scala +++ b/server/src/main/scala/za/co/absa/atum/web/dao/InMemoryApiModelDao.scala @@ -24,7 +24,7 @@ import java.util.UUID import java.util.concurrent.{ConcurrentHashMap, ConcurrentMap} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future - +import scala.collection.JavaConverters._ object InMemoryApiModelDao { @@ -39,12 +39,12 @@ object InMemoryApiModelDao { } -class InMemoryApiModelDao[T <: BaseApiModel] extends ApiModelDao[T] with JavaConvertersWrapper { +class InMemoryApiModelDao[T <: BaseApiModel] extends ApiModelDao[T] { private val inmemory: ConcurrentMap[UUID, T] = new ConcurrentHashMap[UUID, T]() def getList(limit: Int, offset: Int, filter: T => Boolean): Future[List[T]] = Future { - asScala(inmemory.values) + inmemory.values.asScala .filter(filter) .slice(offset, offset + limit).toList // limiting, todo pagination or similar } diff --git a/server/src/main/scala_2.12-/za.co.absa.atum.web/dao/JavaConvertersWrapper.scala b/server/src/main/scala_2.12-/za.co.absa.atum.web/dao/JavaConvertersWrapper.scala deleted file mode 100644 index 93529c8a5..000000000 --- a/server/src/main/scala_2.12-/za.co.absa.atum.web/dao/JavaConvertersWrapper.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2021 ABSA Group Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package za.co.absa.atum.web.dao - -import scala.collection.JavaConverters.iterableAsScalaIterableConverter - -trait JavaConvertersWrapper { - def asScala[T](item: java.lang.Iterable[T]): Iterable[T] = { - item.asScala - } -} diff --git a/server/src/main/scala_2.13+/za/co/absa/atum/web/dao/JavaConvertersWrapper.scala b/server/src/main/scala_2.13+/za/co/absa/atum/web/dao/JavaConvertersWrapper.scala deleted file mode 100644 index 4d23c2494..000000000 --- a/server/src/main/scala_2.13+/za/co/absa/atum/web/dao/JavaConvertersWrapper.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2021 ABSA Group Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package za.co.absa.atum.web.dao - -import scala.jdk.CollectionConverters.IterableHasAsScala - -trait JavaConvertersWrapper { - def asScala[T](item: java.lang.Iterable[T]): Iterable[T] = { - item.asScala - } -}