-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#193: Drop support of Spark 2.4 #196
Changes from 2 commits
b79f87a
3993207
b3a4599
45d2c79
31aa99f
979afdc
909874d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,41 +14,39 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import Dependencies._ | ||
import JacocoSetup._ | ||
import sbt.Keys.name | ||
import sbt.* | ||
import Dependencies.* | ||
import Dependencies.Versions.spark3 | ||
import VersionAxes.* | ||
|
||
ThisBuild / organization := "za.co.absa.atum-service" | ||
sonatypeProfileName := "za.co.absa" | ||
|
||
ThisBuild / scalaVersion := Versions.scala213 // default version | ||
ThisBuild / scalaVersion := Setup.scala213 // default version | ||
|
||
ThisBuild / versionScheme := Some("early-semver") | ||
|
||
Global / onChangedBuildSource := ReloadOnSourceChanges | ||
|
||
publish / skip := true | ||
|
||
lazy val printSparkScalaVersion = taskKey[Unit]("Print Spark and Scala versions for atum-service is being built for.") | ||
lazy val printScalaVersion = taskKey[Unit]("Print Scala versions for atum-service is being built for.") | ||
initialize := { | ||
val _ = initialize.value // Ensure previous initializations are run | ||
|
||
val requiredJavaVersion = VersionNumber("17") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is currently not applied, but in general, can you explain the intended requirement for Java 17? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hope the explanation above make it cleared. This would be removed for sure (or maybe used in the information 🤔 ) |
||
val current = VersionNumber(sys.props("java.specification.version")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming to something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If code kept, will rename. |
||
// Assert that the JVM meets the minimum required version, for example, Java 17 | ||
//assert(specVersion.toDouble >= 17, "Java 17 or above is required to run this project.") | ||
println(s"Running on Java version $current") | ||
} | ||
|
||
lazy val commonSettings = Seq( | ||
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-Xfatal-warnings"), | ||
scalacOptions ++= Setup.commonScalacOptions, | ||
Test / parallelExecution := false, | ||
jacocoExcludes := jacocoProjectExcludes() | ||
jacocoExcludes := JacocoSetup.jacocoProjectExcludes() | ||
) | ||
|
||
val serverMergeStrategy = assembly / assemblyMergeStrategy := { | ||
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.filterDistinctLines | ||
case PathList("META-INF", "maven", "org.webjars", "swagger-ui", "pom.properties") => MergeStrategy.singleOrError | ||
case PathList("META-INF", "resources", "webjars", "swagger-ui", _*) => MergeStrategy.singleOrError | ||
case PathList("META-INF", _*) => MergeStrategy.discard | ||
case PathList("META-INF", "versions", "9", xs@_*) => MergeStrategy.discard | ||
case PathList("module-info.class") => MergeStrategy.discard | ||
case "application.conf" => MergeStrategy.concat | ||
case "reference.conf" => MergeStrategy.concat | ||
case _ => MergeStrategy.first | ||
} | ||
|
||
enablePlugins(FlywayPlugin) | ||
flywayUrl := FlywayConfiguration.flywayUrl | ||
|
@@ -58,86 +56,68 @@ flywayLocations := FlywayConfiguration.flywayLocations | |
flywaySqlMigrationSuffixes := FlywayConfiguration.flywaySqlMigrationSuffixes | ||
libraryDependencies ++= flywayDependencies | ||
|
||
/** | ||
* Module `server` is the service application that collects and stores measured data And upo request retrives them | ||
*/ | ||
lazy val server = (projectMatrix in file("server")) | ||
.settings( | ||
commonSettings ++ Seq( | ||
name := "atum-server", | ||
libraryDependencies ++= Dependencies.serverDependencies ++ testDependencies, | ||
javacOptions ++= Seq("-source", "11", "-target", "11", "-Xlint"), | ||
scalacOptions ++= Seq("-release", "11", "-Ymacro-annotations"), | ||
javacOptions ++= Setup.serviceJavacOptions, | ||
Compile / packageBin / publishArtifact := false, | ||
printScalaVersion := { | ||
val log = streams.value.log | ||
log.info(s"Building ${name.value} with Scala ${scalaVersion.value}") | ||
}, | ||
(Compile / compile) := ((Compile / compile) dependsOn printScalaVersion).value, | ||
packageBin := (Compile / assembly).value, | ||
artifactPath / (Compile / packageBin) := baseDirectory.value / s"target/${name.value}-${version.value}.jar", | ||
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), | ||
jacocoReportSettings := jacocoSettings(scalaVersion.value, "atum-server"), | ||
serverMergeStrategy | ||
Setup.serverMergeStrategy | ||
): _* | ||
) | ||
.enablePlugins(AssemblyPlugin) | ||
.enablePlugins(AutomateHeaderPlugin) | ||
.jvmPlatform(scalaVersions = Seq(Versions.serviceScalaVersion)) | ||
.singleRow(Setup.serviceScalaVersion, Dependencies.serverDependencies) | ||
.dependsOn(model) | ||
|
||
/** | ||
* Module `agent` is the library to be plugged into the Spark application to measure the data and send it to the server | ||
*/ | ||
lazy val agent = (projectMatrix in file("agent")) | ||
.settings( | ||
commonSettings ++ Seq( | ||
name := "atum-agent", | ||
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint"), | ||
libraryDependencies ++= jsonSerdeDependencies ++ testDependencies ++ Dependencies.agentDependencies( | ||
if (scalaVersion.value == Versions.scala211) Versions.spark2 else Versions.spark3, | ||
scalaVersion.value | ||
), | ||
printSparkScalaVersion := { | ||
val log = streams.value.log | ||
val sparkVer = sparkVersionForScala(scalaVersion.value) | ||
log.info(s"Building ${name.value} with Spark $sparkVer, Scala ${scalaVersion.value}") | ||
}, | ||
(Compile / compile) := ((Compile / compile) dependsOn printSparkScalaVersion).value, | ||
jacocoReportSettings := jacocoSettings(scalaVersion.value, "atum-agent") | ||
javacOptions ++= Setup.clientJavacOptions | ||
): _* | ||
) | ||
.jvmPlatform(scalaVersions = Versions.clientSupportedScalaVersions) | ||
.sparkRow(SparkVersionAxis(spark3), Setup.clientSupportedScalaVersions, Dependencies.agentDependencies) | ||
.dependsOn(model) | ||
|
||
/** | ||
* Module `mode` is the data model for data exchange with server | ||
benedeki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
lazy val model = (projectMatrix in file("model")) | ||
.settings( | ||
commonSettings ++ Seq( | ||
name := "atum-model", | ||
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint"), | ||
libraryDependencies ++= jsonSerdeDependencies ++ testDependencies ++ Dependencies.modelDependencies(scalaVersion.value), | ||
printScalaVersion := { | ||
val log = streams.value.log | ||
log.info(s"Building ${name.value} with Scala ${scalaVersion.value}") | ||
}, | ||
(Compile / compile) := ((Compile / compile) dependsOn printScalaVersion).value, | ||
jacocoReportSettings := jacocoSettings(scalaVersion.value, "atum-agent: model") | ||
javacOptions ++= Setup.clientJavacOptions, | ||
): _* | ||
) | ||
.jvmPlatform(scalaVersions = Versions.clientSupportedScalaVersions) | ||
.scalasRow(Setup.clientSupportedScalaVersions, Dependencies.modelDependencies) | ||
|
||
/** | ||
* Module `database` is the source of database structures of the service | ||
*/ | ||
lazy val database = (projectMatrix in file("database")) | ||
.settings( | ||
commonSettings ++ Seq( | ||
name := "atum-database", | ||
printScalaVersion := { | ||
val log = streams.value.log | ||
log.info(s"Building ${name.value} with Scala ${scalaVersion.value}") | ||
}, | ||
libraryDependencies ++= Dependencies.databaseDependencies, | ||
(Compile / compile) := ((Compile / compile) dependsOn printScalaVersion).value, | ||
javacOptions ++= Setup.serviceJavacOptions, | ||
test := {} | ||
): _* | ||
) | ||
.jvmPlatform(scalaVersions = Seq(Versions.serviceScalaVersion)) | ||
.singleRow(Setup.serviceScalaVersion, Dependencies.databaseDependencies) | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
lazy val dbTest = taskKey[Unit]("Launch DB tests") | ||
|
||
dbTest := { | ||
println("Running DB tests") | ||
(database.jvm(Versions.serviceScalaVersion) / Test / test).value | ||
(database.jvm(Setup.serviceScalaVersion) / Test / test).value | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import sbt.Keys.javacOptions | ||
import sbt.TaskKey | ||
import sbtassembly.AssemblyKeys.assemblyMergeStrategy | ||
import sbtassembly.AssemblyPlugin.autoImport | ||
import sbtassembly.AssemblyPlugin.autoImport.{MergeStrategy, assembly} | ||
import sbtassembly.PathList | ||
|
||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
benedeki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* 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. | ||
*/ | ||
lsulak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
object Setup { | ||
|
||
//supported Scala versions | ||
// val scala212 = Version.asSemVer("2.12.18") TODO | ||
lsulak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// val scala213 = Version.asSemVer("2.13.11") | ||
val scala212 = "2.12.18" | ||
val scala213 = "2.13.11" | ||
|
||
val serviceScalaVersion: String = scala213 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could align the naming as we sometimes use server and sometimes service. I would suggest to use server everywhere given it's a name of the module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, the original idea had been) (discussed bakc than with @lsulak ) that: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, I comprehend the logic behind it. However, without prior knowledge, it might not be immediately clear. Hence, I would suggest being more descriptive, for instance, using a name like "serverAndDatabaseScalaVersion". |
||
val clientSupportedScalaVersions: Seq[String] = Seq(scala212, scala213) | ||
|
||
val commonScalacOptions: Seq[String] = Seq("-unchecked", "-deprecation", "-feature", "-Xfatal-warnings") | ||
|
||
val serviceJavacOptions: Seq[String] = Seq("-source", "11", "-target", "11", "-Xlint") | ||
val serviceScalacOptions: Seq[String] = Seq("-release", "11", "-Ymacro-annotations") | ||
|
||
val clientJavacOptions: Seq[String] = Seq("-source", "1.8", "-target", "1.8", "-Xlint") | ||
def clientScalacOptions(scalaVersion: String): Seq[String] = { | ||
if (scalaVersion == scala213) { | ||
Seq("-release", "8", "-Ymacro-annotations") | ||
} else { | ||
Seq("-target", "8", "-release", "8") | ||
} | ||
} | ||
// val clientScalacOptions: Seq[String] = Seq("-Ymacro-annotations") | ||
lsulak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
val serverMergeStrategy = assembly / assemblyMergeStrategy := { | ||
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.filterDistinctLines | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. xs is an alias, it's not needed here as we do not reference the alias and could be removed and the _* expands the elements of the list |
||
case PathList("META-INF", "maven", "org.webjars", "swagger-ui", "pom.properties") => MergeStrategy.singleOrError | ||
case PathList("META-INF", "resources", "webjars", "swagger-ui", _*) => MergeStrategy.singleOrError | ||
case PathList("META-INF", _*) => MergeStrategy.discard | ||
case PathList("META-INF", "versions", "9", xs@_*) => MergeStrategy.discard | ||
case PathList("module-info.class") => MergeStrategy.discard | ||
case "application.conf" => MergeStrategy.concat | ||
case "reference.conf" => MergeStrategy.concat | ||
case _ => MergeStrategy.first | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the assignment necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I don't know. This code block is a remnant of my tries to keep Spakr 2.4 support. And I found it interesting, so kept it for now, with the intention to ask you what you think to have that information (of the active Java version) there.
Just forgot to comment accordingly.
So what do you think, should we keep the info (with the commented out cod removed)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's useful to have a log statement with the Java version in use. See an alternative implementation below.