Skip to content

Commit

Permalink
Use 2 for binarySbtVersion in 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Apr 9, 2024
1 parent 54011d5 commit 04fcad6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ def commonSettings: Seq[Setting[_]] = Def.settings(
scalacOptions := {
val old = scalacOptions.value
scalaVersion.value match {
case sv if sv.startsWith("2.10") =>
old diff List("-Xfuture", "-Ywarn-unused", "-Ywarn-unused-import")
case sv if sv.startsWith("2.11") => old ++ List("-Ywarn-unused", "-Ywarn-unused-import")
case sv if sv.startsWith("2.12") =>
old ++ List("-Ywarn-unused", "-Ywarn-unused-import", "-YdisableFlatCpCaching")
old ++ List(
"-Ywarn-unused",
"-Ywarn-unused-import",
"-Ywarn-unused:-nowarn",
)
case _ => old
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ object CrossVersionUtil {
}

def binarySbtVersion(full: String): String =
binaryVersionWithApi(full, TransitionSbtVersion)(sbtApiVersion)
sbtApiVersion(full) match {
case Some((0, minor)) if minor < 12 => full
case Some((0, minor)) => s"0.$minor"
case Some((1, minor)) => s"1.$minor"
case Some((major, _)) => major.toString
case _ => full
}

private[this] def isNewer(major: Long, minor: Long, minMajor: Long, minMinor: Long): Boolean =
major > minMajor || (major == minMajor && minor >= minMinor)
Expand Down
27 changes: 12 additions & 15 deletions core/src/test/scala/sbt/librarymanagement/CrossVersionTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,23 @@ class CrossVersionTest extends UnitSpec {
"binarySbtVersion" should "for 0.11.3 return 0.11.3" in {
binarySbtVersion("0.11.3") shouldBe "0.11.3"
}
it should "for 0.12.0-M1 return 0.12.0-M1" in {
binarySbtVersion("0.12.0-M1") shouldBe "0.12.0-M1"
it should "for 2.0.0 return 2" in {
binarySbtVersion("2.0.0") shouldBe "2"
}
it should "for 0.12.0-RC1 return 0.12" in {
binarySbtVersion("0.12.0-RC1") shouldBe "0.12"
it should "for 2.0.0-M1 return 2.0.0-M1" in {
binarySbtVersion("2.0.0-M1") shouldBe "2.0.0-M1"
}
it should "for 0.12.0 return 0.12" in {
binarySbtVersion("0.12.0") shouldBe "0.12"
it should "for 2.0.0-RC1 return 2" in {
binarySbtVersion("2.0.0-RC1") shouldBe "2"
}
it should "for 0.12.1-SNAPSHOT return 0.12" in {
binarySbtVersion("0.12.1-SNAPSHOT") shouldBe "0.12"
it should "for 2.1.0-M1 return 2" in {
binarySbtVersion("2.1.0-M1") shouldBe "2"
}
it should "for 0.12.1-RC1 return 0.12" in {
binarySbtVersion("0.12.1-RC1") shouldBe "0.12"
it should "for 2.1.0 return 2" in {
binarySbtVersion("2.1.0") shouldBe "2"
}
it should "for 0.12.1 return 0.12" in {
binarySbtVersion("0.12.1") shouldBe "0.12"
it should "for 0.13.1 return 0.13" in {
binarySbtVersion("0.13.1") shouldBe "0.13"
}
it should "for 1.0.0-M6 return 1.0.0-M6" in {
binarySbtVersion("1.0.0-M6") shouldBe "1.0.0-M6"
Expand Down Expand Up @@ -144,9 +144,6 @@ class CrossVersionTest extends UnitSpec {
it should "for 1.10.0 return 1.0" in {
binarySbtVersion("1.10.0") shouldBe "1.0"
}
it should "for 2.0.0 return 2.0" in {
binarySbtVersion("2.0.0") shouldBe "2.0"
}

"scalaApiVersion" should "for xyz return None" in {
scalaApiVersion("xyz") shouldBe None
Expand Down

0 comments on commit 04fcad6

Please sign in to comment.