diff --git a/README.md b/README.md index 51cf180ef..01f89755b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,13 @@ It provides functionality for computing and pushing control metrics to the API l For more information, see the [Vocabulary section](#Vocabulary) or `agent/README.md` for more technical documentation. +#### Spark 2.4 support +Because there are some java level incompatibilities between Spark 2.4 and Spark 3.x whe build on Java 11+, we have to +drop support for Spark 2.4. If you need the agent to work with Spark 2.4 follow these steps: +* Switch to Java 8 +* In `'build.sbt'` change the matrix rows, to be Spark 2.4 and Scala 2.11 for modules _agent_ and _model_ +* Build these two modules and use them in your project + ### Server `server/` An API under construction that communicates with the Agent and with the persistent storage. It also provides measure configuration to the agent. diff --git a/build.sbt b/build.sbt index b3edec56c..41072cf5a 100644 --- a/build.sbt +++ b/build.sbt @@ -14,40 +14,25 @@ * 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.asString // default version TODO 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 -lazy val commonSettings = Seq( - scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-Xfatal-warnings"), - Test / parallelExecution := false, - jacocoExcludes := 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 + 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 } enablePlugins(FlywayPlugin) @@ -58,86 +43,72 @@ 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( + Setup.commonSettings ++ Seq( name := "atum-server", - libraryDependencies ++= Dependencies.serverDependencies ++ testDependencies, - javacOptions ++= Seq("-source", "11", "-target", "11", "-Xlint"), - scalacOptions ++= Seq("-release", "11", "-Ymacro-annotations"), + javacOptions ++= Setup.serverAndDbJavacOptions, 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)) + .addSingleScalaBuild(Setup.serverAndDbScalaVersion, 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")) + .disablePlugins(sbtassembly.AssemblyPlugin) .settings( - commonSettings ++ Seq( + Setup.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) + .addSparkCrossBuild(SparkVersionAxis(spark3), Setup.clientSupportedScalaVersions, Dependencies.agentDependencies) .dependsOn(model) +/** + * Module `model` is the data model for data exchange with server + */ lazy val model = (projectMatrix in file("model")) + .disablePlugins(sbtassembly.AssemblyPlugin) .settings( - commonSettings ++ Seq( + Setup.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) + .addScalaCrossBuild(Setup.clientSupportedScalaVersions, Dependencies.modelDependencies) +/** + * Module `database` is the source of database structures of the service + */ lazy val database = (projectMatrix in file("database")) + .disablePlugins(sbtassembly.AssemblyPlugin) .settings( - commonSettings ++ Seq( + Setup.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.serverAndDbJavacOptions, test := {} ): _* ) - .jvmPlatform(scalaVersions = Seq(Versions.serviceScalaVersion)) + .addSingleScalaBuild(Setup.serverAndDbScalaVersion, 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.serverAndDbScalaVersion.asString) / Test / test).value } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index ab23dd30c..4bb377157 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,21 +13,15 @@ * limitations under the License. */ -import sbt._ +import sbt.* +import za.co.absa.commons.version.{Component, Version} object Dependencies { object Versions { - val spark2 = "2.4.8" + val spark2 = "2.4.7" val spark3 = "3.3.2" - val scala211 = "2.11.12" - val scala212 = "2.12.18" - val scala213 = "2.13.11" - - val serviceScalaVersion: String = scala213 - val clientSupportedScalaVersions: Seq[String] = Seq(scala211, scala212, scala213) - val scalatest = "3.2.15" val scalaMockito = "1.17.12" val scalaLangJava8Compat = "1.0.2" @@ -54,6 +48,19 @@ object Dependencies { val json4s_spark2 = "3.5.3" val json4s_spark3 = "3.7.0-M11" + def json4s(scalaVersion: Version): String = { + // TODO done this impractical way until https://github.com/AbsaOSS/commons/issues/134 + val maj2 = Component("2") + val min11 = Component("11") + val min12 = Component("12") + val min13 = Component("13") + scalaVersion.components match { + case Seq(`maj2`, `min11`, _) => json4s_spark2 + case Seq(`maj2`, `min12`, _) => json4s_spark3 + case Seq(`maj2`, `min13`, _) => json4s_spark3 + case _ => throw new IllegalArgumentException("Only Scala 2.11, 2.12, and 2.13 are currently supported.") + } + } val logback = "1.2.3" @@ -72,41 +79,23 @@ object Dependencies { val awssdk = "2.23.15" val scalaNameof = "4.0.0" - } - - - private def truncateVersion(version: String, parts: Int): String = { - version.split("\\.").take(parts).mkString(".") - } - def getVersionUpToMinor(version: String): String = { - truncateVersion(version, 2) - } + val absaCommons = "2.0.0" - def getVersionUpToMajor(version: String): String = { - truncateVersion(version, 1) - } + def truncateVersion(version: String, parts: Int): String = { + version.split("\\.").take(parts).mkString(".") + } - // this is just for the compile-depended printing task - def sparkVersionForScala(scalaVersion: String): String = { - truncateVersion(scalaVersion, 2) match { - case "2.11" => Versions.spark2 - case "2.12" => Versions.spark3 - case "2.13" => Versions.spark3 - case _ => throw new IllegalArgumentException("Only Scala 2.11, 2.12, and 2.13 are currently supported.") + def getVersionUpToMinor(version: String): String = { + truncateVersion(version, 2) } - } - def json4sVersionForScala(scalaVersion: String): String = { - truncateVersion(scalaVersion, 2) match { - case "2.11" => Versions.json4s_spark2 - case "2.12" => Versions.json4s_spark3 - case "2.13" => Versions.json4s_spark3 - case _ => throw new IllegalArgumentException("Only Scala 2.11, 2.12, and 2.13 are currently supported.") + def getVersionUpToMajor(version: String): String = { + truncateVersion(version, 1) } } - def testDependencies: Seq[ModuleID] = { + private def testDependencies: Seq[ModuleID] = { lazy val scalatest = "org.scalatest" %% "scalatest" % Versions.scalatest % Test lazy val mockito = "org.mockito" %% "mockito-scala" % Versions.scalaMockito % Test @@ -116,8 +105,8 @@ object Dependencies { ) } - def jsonSerdeDependencies: Seq[ModuleID] = { - val json4sVersion = json4sVersionForScala(Versions.scala212) + private def jsonSerdeDependencies(scalaVersion: Version): Seq[ModuleID] = { + val json4sVersion = Versions.json4s(scalaVersion) lazy val jacksonModuleScala = "com.fasterxml.jackson.module" %% "jackson-module-scala" % Versions.jacksonModuleScala @@ -209,12 +198,13 @@ object Dependencies { zioTestSbt, zioTestJunit, sbtJunitInterface - ) + ) ++ + testDependencies } - def agentDependencies(sparkVersion: String, scalaVersion: String): Seq[ModuleID] = { - val sparkMinorVersion = getVersionUpToMinor(sparkVersion) - val scalaMinorVersion = getVersionUpToMinor(scalaVersion) + def agentDependencies(sparkVersion: String, scalaVersion: Version): Seq[ModuleID] = { + val sparkMinorVersion = Versions.getVersionUpToMinor(sparkVersion) + val scalaMinorVersion = Versions.getVersionUpToMinor(scalaVersion.asString) lazy val sparkCore = "org.apache.spark" %% "spark-core" % sparkVersion % Provided lazy val sparkSql = "org.apache.spark" %% "spark-sql" % sparkVersion % Provided @@ -238,14 +228,20 @@ object Dependencies { sttp, logback, nameOf - ) + ) ++ + testDependencies } - def modelDependencies(scalaVersion: String): Seq[ModuleID] = { + def modelDependencies(scalaVersion: Version): Seq[ModuleID] = { lazy val specs2core = "org.specs2" %% "specs2-core" % Versions.specs2 % Test lazy val typeSafeConfig = "com.typesafe" % "config" % Versions.typesafeConfig - Seq(specs2core, typeSafeConfig) + Seq( + specs2core, + typeSafeConfig + ) ++ + testDependencies ++ + jsonSerdeDependencies(scalaVersion) } def databaseDependencies: Seq[ModuleID] = { diff --git a/project/JacocoSetup.scala b/project/JacocoSetup.scala index 04363fbc4..53774bc6f 100644 --- a/project/JacocoSetup.scala +++ b/project/JacocoSetup.scala @@ -15,6 +15,7 @@ import com.github.sbt.jacoco.JacocoKeys.JacocoReportFormats import com.github.sbt.jacoco.report.JacocoReportSettings +import za.co.absa.commons.version.Version import java.time.format.DateTimeFormatter import java.time.{ZoneId, ZonedDateTime} @@ -25,16 +26,17 @@ object JacocoSetup { formats = Seq(JacocoReportFormats.HTML, JacocoReportFormats.XML) ) - def jacocoSettings(sparkVersion: String, scalaVersion: String, moduleName: String): JacocoReportSettings = { + private def now: String = { val utcDateTime = ZonedDateTime.now.withZoneSameInstant(ZoneId.of("UTC")) - val now = s"as of ${DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm Z z").format(utcDateTime)}" - jacocoReportCommonSettings.withTitle(s"Jacoco Report on `$moduleName` for spark:$sparkVersion - scala:$scalaVersion [$now]") + s"as of ${DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm Z z").format(utcDateTime)}" } - def jacocoSettings(scalaVersion: String, moduleName: String): JacocoReportSettings = { - val utcDateTime = ZonedDateTime.now.withZoneSameInstant(ZoneId.of("UTC")) - val now = s"as of ${DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm Z z").format(utcDateTime)}" - jacocoReportCommonSettings.withTitle(s"Jacoco Report on `$moduleName` for scala:$scalaVersion [$now]") + def jacocoSettings(sparkVersion: String, scalaVersion: Version, moduleName: String): JacocoReportSettings = { + jacocoReportCommonSettings.withTitle(s"Jacoco Report on `$moduleName` for spark:$sparkVersion - scala:${scalaVersion.asString} [$now]") + } + + def jacocoSettings(scalaVersion: Version, moduleName: String): JacocoReportSettings = { + jacocoReportCommonSettings.withTitle(s"Jacoco Report on `$moduleName` for scala:${scalaVersion.asString} [$now]") } def jacocoProjectExcludes(): Seq[String] = { diff --git a/project/Setup.scala b/project/Setup.scala new file mode 100644 index 000000000..235adc4bb --- /dev/null +++ b/project/Setup.scala @@ -0,0 +1,66 @@ +/* + * 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. + */ + +import com.github.sbt.jacoco.JacocoKeys.jacocoExcludes +import sbt.* +import sbt.Keys.* +import sbtassembly.AssemblyKeys.assemblyMergeStrategy +import sbtassembly.AssemblyPlugin.autoImport.{MergeStrategy, assembly} +import sbtassembly.PathList +import za.co.absa.commons.version.Version + + +object Setup { + //supported Scala versions + val scala211: Version = Version.asSemVer("2.11.12") + val scala212: Version = Version.asSemVer("2.12.18") + val scala213: Version = Version.asSemVer("2.13.11") + + lazy val commonSettings: Seq[SettingsDefinition] = Seq( + scalacOptions ++= Setup.commonScalacOptions, + Test / parallelExecution := false, + jacocoExcludes := JacocoSetup.jacocoProjectExcludes(), + ) + + val serverAndDbScalaVersion: Version = scala213 //covers REST server and database modules + val clientSupportedScalaVersions: Seq[Version] = Seq(scala212, scala213) + + val commonScalacOptions: Seq[String] = Seq("-unchecked", "-deprecation", "-feature", "-Xfatal-warnings") + + val serverAndDbJavacOptions: Seq[String] = Seq("-source", "11", "-target", "11", "-Xlint") + val serverAndDbScalacOptions: Seq[String] = Seq("-release", "11", "-Ymacro-annotations") + + val clientJavacOptions: Seq[String] = Seq("-source", "1.8", "-target", "1.8", "-Xlint") + def clientScalacOptions(scalaVersion: Version): Seq[String] = { + if (scalaVersion >= scala213) { + Seq("-release", "8", "-Ymacro-annotations") + } else { + Seq("-target", "8", "-release", "8") + } + } + + val serverMergeStrategy = assembly / assemblyMergeStrategy := { + case PathList("META-INF", "services") => 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") => MergeStrategy.discard + case PathList("module-info.class") => MergeStrategy.discard + case "application.conf" => MergeStrategy.concat + case "reference.conf" => MergeStrategy.concat + case _ => MergeStrategy.first + } +} diff --git a/project/SparkVersionAxis.scala b/project/SparkVersionAxis.scala deleted file mode 100644 index 8cd9ecc5f..000000000 --- a/project/SparkVersionAxis.scala +++ /dev/null @@ -1,56 +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. - */ - -import sbt.{Def, VirtualAxis} -import sbt.Keys.{libraryDependencies, moduleName, name} -import sbt.internal.ProjectMatrix -import Dependencies.agentDependencies -import JacocoSetup.{jacocoProjectExcludes, jacocoSettings} -import com.github.sbt.jacoco.JacocoKeys.{jacocoExcludes, jacocoReportSettings} - -case class SparkVersionAxis(sparkVersion: String) extends sbt.VirtualAxis.WeakAxis { - - val sparkVersionMajor: String = Dependencies.getVersionUpToMajor(sparkVersion) - override val directorySuffix = s"-spark$sparkVersionMajor" - override val idSuffix: String = directorySuffix.replaceAll("""\W+""", "_") -} - -object SparkVersionAxis { - private def camelCaseToLowerDashCase(origName: String): String = { - origName - .replaceAll("([A-Z])", "-$1") - .toLowerCase() - } - - implicit class ProjectExtension(val projectMatrix: ProjectMatrix) extends AnyVal { - - def sparkRow(sparkAxis: SparkVersionAxis, scalaVersions: Seq[String], settings: Def.SettingsDefinition*): ProjectMatrix = { - val sparkVersion = sparkAxis.sparkVersion - scalaVersions.foldLeft(projectMatrix)((currentProjectMatrix, scalaVersion) => - currentProjectMatrix.customRow( - scalaVersions = Seq(scalaVersion), - axisValues = Seq(sparkAxis, VirtualAxis.jvm), - _.settings( - moduleName := camelCaseToLowerDashCase(name.value + sparkAxis.directorySuffix), - libraryDependencies ++= agentDependencies(sparkAxis.sparkVersion, scalaVersion), - jacocoReportSettings := jacocoSettings(sparkVersion, scalaVersion, "atum-agent"), - jacocoExcludes := jacocoProjectExcludes() - ).settings(settings: _*) - ) - ) - } - } -} - diff --git a/project/VersionAxes.scala b/project/VersionAxes.scala new file mode 100644 index 000000000..a52aec46c --- /dev/null +++ b/project/VersionAxes.scala @@ -0,0 +1,100 @@ +/* + * 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. + */ + +import sbt.{Def, ModuleID, VirtualAxis, *} +import sbt.Keys.* +import sbt.internal.ProjectMatrix +import JacocoSetup.jacocoSettings +import com.github.sbt.jacoco.JacocoKeys.jacocoReportSettings +import za.co.absa.commons.version.Version + + +object VersionAxes { + + lazy val printVersionInfo = taskKey[Unit]("Print main component versions atum-service is being built for.") + + case class SparkVersionAxis(sparkVersion: String) extends sbt.VirtualAxis.WeakAxis { + + val sparkVersionMajor: String = Dependencies.Versions.getVersionUpToMajor(sparkVersion) + override val directorySuffix = s"-spark$sparkVersionMajor" + override val idSuffix: String = directorySuffix.replaceAll("""\W+""", "_") + } + + private def camelCaseToLowerDashCase(origName: String): String = { + origName + .replaceAll("([A-Z])", "-$1") + .toLowerCase() + } + + implicit class ProjectExtension(val projectMatrix: ProjectMatrix) extends AnyVal { + + def addSparkCrossBuild(sparkAxis: SparkVersionAxis, + scalaVersions: Seq[Version], + dependenciesFnc: (String, Version) => Seq[ModuleID], + settings: Def.SettingsDefinition*): ProjectMatrix = { + val sparkVersion = sparkAxis.sparkVersion + scalaVersions.foldLeft(projectMatrix) { case (currentProjectMatrix, scalaVersion) => + currentProjectMatrix.customRow( + scalaVersions = Seq(scalaVersion.asString), + axisValues = Seq(sparkAxis, VirtualAxis.jvm), + _.settings( + moduleName := camelCaseToLowerDashCase(name.value + sparkAxis.directorySuffix), + scalacOptions ++= Setup.clientScalacOptions(scalaVersion), + libraryDependencies ++= dependenciesFnc(sparkVersion, scalaVersion), + printVersionInfo := streams.value.log.info(s"Building ${name.value} with Spark $sparkVersion, Scala ${scalaVersion.asString}"), + (Compile / compile) := ((Compile / compile) dependsOn printVersionInfo).value, + jacocoReportSettings := jacocoSettings(sparkVersion, scalaVersion, name.value), + ).settings(settings *) + ) + } + } + + def addScalaCrossBuild(scalaVersions: Seq[Version], + dependenciesFnc: Version => Seq[ModuleID], + settings: Def.SettingsDefinition*): ProjectMatrix = { + scalaVersions.foldLeft(projectMatrix)((currentProjectMatrix, scalaVersion) => + currentProjectMatrix.customRow( + scalaVersions = Seq(scalaVersion.asString), + axisValues = Seq(VirtualAxis.jvm), + _.settings( + scalacOptions ++= Setup.clientScalacOptions(scalaVersion), + libraryDependencies ++= dependenciesFnc(scalaVersion), + printVersionInfo := streams.value.log.info(s"Building ${name.value} with Scala ${scalaVersion.asString}"), + (Compile / compile) := ((Compile / compile) dependsOn printVersionInfo).value, + jacocoReportSettings := jacocoSettings(scalaVersion, name.value), + ).settings(settings *) + ) + ) + } + + def addSingleScalaBuild(scalaVersion: Version, + dependenciesFnc: => Seq[ModuleID], + settings: Def.SettingsDefinition*): ProjectMatrix = { + projectMatrix.customRow( + scalaVersions = Seq(scalaVersion.asString), + axisValues = Seq(VirtualAxis.jvm), + _.settings( + libraryDependencies ++= dependenciesFnc, + scalacOptions ++= Setup.serverAndDbScalacOptions, + printVersionInfo := streams.value.log.info(s"Building ${name.value} with Scala ${scalaVersion.asString}"), + (Compile / compile) := ((Compile / compile) dependsOn printVersionInfo).value, + jacocoReportSettings := jacocoSettings(scalaVersion, name.value), + ).settings(settings *) + ) + } + + } +} + diff --git a/project/build.sbt b/project/build.sbt new file mode 100644 index 000000000..37c016fae --- /dev/null +++ b/project/build.sbt @@ -0,0 +1,23 @@ +/* + * 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. + */ + +import sbt.* + +// This has to be placed here, as we are importing the library into the project classes, not the code. +// And it cannot reference the .scala files in the `project` directory. +libraryDependencies ++= Seq( + "za.co.absa.commons" %% "commons" % "2.0.0", +) diff --git a/project/plugins.sbt b/project/plugins.sbt index 321d068ee..801174158 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -17,7 +17,7 @@ addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.4") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.7.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") -addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.1") +addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.0") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") @@ -27,7 +27,7 @@ addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "7.4.0") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") // Plugins to build the server module as a jar file -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0") // sbt-jacoco dependency downloading lazy val ow2Version = "9.5" diff --git a/publish.sbt b/publish.sbt index 7399d85ce..486192d52 100644 --- a/publish.sbt +++ b/publish.sbt @@ -14,6 +14,11 @@ * limitations under the License. */ +ThisBuild / organization := "za.co.absa.atum-service" +sonatypeProfileName := "za.co.absa" + +publish / skip := true //skipping publishing of the root of the project, publishing only some submodules + ThisBuild / scmInfo := Some( ScmInfo( browseUrl = url("https://github.com/AbsaOSS/atum-service/tree/master"),