Skip to content

Commit eaead4f

Browse files
committed
sbt-dotty: Fix minimum sbt version check
This fixes #5671. Also bump the minimum version to 1.2.7 due to scalaCompilerBridgeBinaryJar usage, etc.
1 parent 33c0ce0 commit eaead4f

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package dotty.tools.sbtplugin
22

33
import sbt._
44
import sbt.Keys._
5-
import sbt.librarymanagement._
5+
import sbt.librarymanagement.{
6+
ivy, DependencyResolution, ScalaModuleInfo, SemanticSelector, UpdateConfiguration, UnresolvedWarningConfiguration,
7+
VersionNumber
8+
}
69
import sbt.internal.inc.ScalaInstance
710
import xsbti.compile._
811
import java.net.URLClassLoader
@@ -100,20 +103,6 @@ object DottyPlugin extends AutoPlugin {
100103
override def requires: Plugins = plugins.JvmPlugin
101104
override def trigger = allRequirements
102105

103-
// Adapted from CrossVersionUtil#sbtApiVersion
104-
private def sbtFullVersion(v: String): Option[(Int, Int, Int)] =
105-
{
106-
val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
107-
val CandidateV = """(\d+)\.(\d+)\.(\d+)(-RC\d+)""".r
108-
val NonReleaseV = """(\d+)\.(\d+)\.(\d+)([-\w+]*)""".r
109-
v match {
110-
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt, z.toInt))
111-
case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt, z.toInt))
112-
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt, z.toInt))
113-
case _ => None
114-
}
115-
}
116-
117106
/** Patches the IncOptions so that .tasty and .hasTasty files are pruned as needed.
118107
*
119108
* This code is adapted from `scalaJSPatchIncOptions` in Scala.js, which needs
@@ -143,12 +132,13 @@ object DottyPlugin extends AutoPlugin {
143132

144133
override val globalSettings: Seq[Def.Setting[_]] = Seq(
145134
onLoad in Global := onLoad.in(Global).value.andThen { state =>
135+
136+
val requiredVersion = ">=1.2.7"
137+
146138
val sbtV = sbtVersion.value
147-
sbtFullVersion(sbtV) match {
148-
case Some((1, sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 5) =>
149-
case _ =>
150-
sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt >= 1.1.5 is required.")
151-
}
139+
if (!VersionNumber(sbtV).matchesSemVer(SemanticSelector(requiredVersion)))
140+
sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt $requiredVersion is required.")
141+
152142
state
153143
}
154144
)

0 commit comments

Comments
 (0)