diff --git a/build.sbt b/build.sbt index c9ab64c9..839e11b5 100644 --- a/build.sbt +++ b/build.sbt @@ -20,17 +20,25 @@ import Dependencies.* import Dependencies.Versions.spark3 import VersionAxes.* +ThisBuild / scalaVersion := Setup.scala213.asString + ThisBuild / versionScheme := Some("early-semver") Global / onChangedBuildSource := ReloadOnSourceChanges +val limitedProject: Boolean = Setup.currentJava < Setup.recommendedJava + initialize := { val _ = initialize.value // Ensure previous initializations are run - val requiredJavaVersion = VersionNumber("11") - val currentJavaVersion = VersionNumber(sys.props("java.specification.version")) - println(s"Running on Java version $currentJavaVersion, required is at least version $requiredJavaVersion") - //this routine can be used to assert the required Java version + assert(Setup.currentJava >= Setup.requiredJava, + s"Running on Java version ${Setup.currentJava}, required is at least version ${Setup.requiredJava}, recommended is ${Setup.recommendedJava}") + + if (limitedProject) { + val log = Keys.sLog.value + log.warn(s"Some nodules will not be loaded, because they require at least Java ${Setup.recommendedJava} while Java ${Setup.currentJava} has been found") + log.warn("""Affected modules are: "atum-server", "atum-database"""") + } } enablePlugins(FlywayPlugin) @@ -45,23 +53,31 @@ 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( - Setup.commonSettings ++ Seq( - name := "atum-server", - javacOptions ++= Setup.serverAndDbJavacOptions, - Compile / packageBin / publishArtifact := false, - packageBin := (Compile / assembly).value, - artifactPath / (Compile / packageBin) := baseDirectory.value / s"target/${name.value}-${version.value}.jar", - testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), - Setup.serverMergeStrategy, - publish / skip := true - ): _* - ) - .enablePlugins(AssemblyPlugin) - .enablePlugins(AutomateHeaderPlugin) - .addSingleScalaBuild(Setup.serverAndDbScalaVersion, Dependencies.serverDependencies) - .dependsOn(model) +lazy val server = { + val server = (projectMatrix in file("server")) + .settings( + Setup.commonSettings ++ Seq( + name := "atum-server", + javacOptions ++= Setup.serverAndDbJavacOptions, + Compile / packageBin / publishArtifact := false, + packageBin := (Compile / assembly).value, + artifactPath / (Compile / packageBin) := baseDirectory.value / s"target/${name.value}-${version.value}.jar", + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), + Setup.serverMergeStrategy, + publish / skip := true + ): _* + ) + .enablePlugins(AssemblyPlugin) + .enablePlugins(AutomateHeaderPlugin) + .addSingleScalaBuild(Setup.serverAndDbScalaVersion, Dependencies.serverDependencies) + .dependsOn(model) + + if (limitedProject) { + null // if value other then null is returned, the condition doesn't seem to work. + } else { + server + } +} /** * Module `agent` is the library to be plugged into the Spark application to measure the data and send it to the server @@ -93,16 +109,23 @@ lazy val model = (projectMatrix in file("model")) /** * Module `database` is the source of database structures of the service */ -lazy val database = (projectMatrix in file("database")) - .disablePlugins(sbtassembly.AssemblyPlugin) - .settings( - Setup.commonSettings ++ Seq( - name := "atum-database", - javacOptions ++= Setup.serverAndDbJavacOptions, - publish / skip := true - ): _* - ) - .addSingleScalaBuild(Setup.serverAndDbScalaVersion, Dependencies.databaseDependencies) +lazy val database = { + val database = (projectMatrix in file("database")) + .disablePlugins(sbtassembly.AssemblyPlugin) + .settings( + Setup.commonSettings ++ Seq( + name := "atum-database", + javacOptions ++= Setup.serverAndDbJavacOptions, + publish / skip := true + ): _* + ) + .addSingleScalaBuild(Setup.serverAndDbScalaVersion, Dependencies.databaseDependencies) + if (limitedProject) { + null // if value other then null is returned, the condition doesn't seem to work. + } else { + database + } +} /** * Module `reader` is the library to be plugged into application which wants to easily read the measured data stored on diff --git a/project/Setup.scala b/project/Setup.scala index 14c3f892..c1027058 100644 --- a/project/Setup.scala +++ b/project/Setup.scala @@ -24,6 +24,11 @@ import za.co.absa.commons.version.Version object Setup { + //supprtted Java versions + val requiredJava: Double = "1.8".toDouble + val recommendedJava: Double = "11".toDouble + val currentJava: Double = sys.props("java.specification.version").toDouble + //supported Scala versions val scala211: Version = Version.asSemVer("2.11.12") val scala212: Version = Version.asSemVer("2.12.18")