Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mslabek committed Oct 3, 2024
1 parent ae4b664 commit 65235e1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
46 changes: 14 additions & 32 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import sbt.Keys._
import sbtassembly.AssemblyPlugin.autoImport.assembly
import sbtassembly.{MergeStrategy, PathList}
import utils.{codeVersion, forScalaVersion}

val scala212V = "2.12.10"
val scala213V = "2.13.12"

lazy val supportedScalaVersions = List(scala212V, scala213V)

lazy val defaultScalaV = sys.env.get("NUSSKNACKER_SCALA_VERSION") match {
case None | Some("2.12") => scala212V
case Some("2.13") => scala213V
case Some(unsupported) => throw new IllegalArgumentException(s"Nu doesn't support $unsupported Scala version")
}
ThisBuild / scalaVersion := scala212V

val scalaCollectionsCompatV = "2.9.0"

Expand All @@ -26,23 +22,28 @@ val sttpV = "3.8.11"
val kafkaV = "3.3.1"
val testContainersScalaV = "0.41.0"

ThisBuild / version := "1.0-nu1.18.0-SNAPSHOT"

// todo: for now we should regularly bump the version until we start publish single "latest" -SNAPSHOT version
val defaultNussknackerV = "1.18.0-staging-2024-09-24-20698-40fc17dbe-SNAPSHOT"

val nussknackerV = {
val v = sys.env
// todo: for now we should regularly bump the version until we start publish single "latest" -SNAPSHOT version
val defaultNussknackerV = "1.18.0-staging-2024-09-24-20698-40fc17dbe-SNAPSHOT"
val v = sys.env
.get("NUSSKNACKER_VERSION")
.filterNot(_.isBlank)
.getOrElse(defaultNussknackerV)
println(s"Nussknacker version: $v")
v
}

val baseVersion = "1.0"
ThisBuild / version := codeVersion(baseVersion, nussknackerV)

lazy val root = (project in file("."))
.enablePlugins(FormatStagedScalaFilesPlugin)
.aggregate(modules: _*)
.aggregate(
flink116KafkaComponents,
flink116ManagerCompat,
flink116ModelCompat,
commonTest
)
.settings(commonSettings)
.settings(
Seq(
Expand All @@ -52,17 +53,6 @@ lazy val root = (project in file("."))
)
)

def forScalaVersion[T](version: String)(provide: PartialFunction[(Int, Int), T]): T = {
CrossVersion.partialVersion(version) match {
case Some((major, minor)) if provide.isDefinedAt((major.toInt, minor.toInt)) =>
provide((major.toInt, minor.toInt))
case Some(_) =>
throw new IllegalArgumentException(s"Scala version $version is not handled")
case None =>
throw new IllegalArgumentException(s"Invalid Scala version $version")
}
}

lazy val commonSettings = Seq(
organization := "pl.touk.nussknacker.flinkcompatibility",
resolvers ++= Seq(
Expand All @@ -73,7 +63,6 @@ lazy val commonSettings = Seq(
.getOrElse("nexus", "https://nexus.touk.pl/nexus/content/groups/public")
),
publish / skip := true,
scalaVersion := defaultScalaV,
crossScalaVersions := supportedScalaVersions,
scalacOptions := Seq(
"-unchecked",
Expand Down Expand Up @@ -290,10 +279,3 @@ def nussknackerAssemblyStrategy: String => MergeStrategy = {

case x => MergeStrategy.defaultMergeStrategy(x)
}

lazy val modules: List[ProjectReference] = List[ProjectReference](
flink116KafkaComponents,
flink116ManagerCompat,
flink116ModelCompat,
commonTest
)
17 changes: 16 additions & 1 deletion project/utils.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sbt.{Def, Inc, Result, SettingKey, Task, TaskKey, Value}
import sbt.{CrossVersion, Def, Inc, Result, SettingKey, Task, TaskKey, Value}

object utils {

Expand Down Expand Up @@ -56,4 +56,19 @@ object utils {

}

def forScalaVersion[T](version: String)(provide: PartialFunction[(Int, Int), T]): T = {
CrossVersion.partialVersion(version) match {
case Some((major, minor)) if provide.isDefinedAt((major.toInt, minor.toInt)) =>
provide((major.toInt, minor.toInt))
case Some(_) =>
throw new IllegalArgumentException(s"Scala version $version is not handled")
case None =>
throw new IllegalArgumentException(s"Invalid Scala version $version")
}
}

def codeVersion(flinkCompatibilityVersion: String, nussknackerV: String): String = {
s"$flinkCompatibilityVersion-nu$nussknackerV"
}

}

0 comments on commit 65235e1

Please sign in to comment.