@@ -2,7 +2,10 @@ package dotty.tools.sbtplugin
2
2
3
3
import sbt ._
4
4
import sbt .Keys ._
5
- import sbt .librarymanagement ._
5
+ import sbt .librarymanagement .{
6
+ ivy , DependencyResolution , ScalaModuleInfo , SemanticSelector , UpdateConfiguration , UnresolvedWarningConfiguration ,
7
+ VersionNumber
8
+ }
6
9
import sbt .internal .inc .ScalaInstance
7
10
import xsbti .compile ._
8
11
import java .net .URLClassLoader
@@ -99,20 +102,6 @@ object DottyPlugin extends AutoPlugin {
99
102
override def requires : Plugins = plugins.JvmPlugin
100
103
override def trigger = allRequirements
101
104
102
- // Adapted from CrossVersionUtil#sbtApiVersion
103
- private def sbtFullVersion (v : String ): Option [(Int , Int , Int )] =
104
- {
105
- val ReleaseV = """ (\d+)\.(\d+)\.(\d+)(-\d+)?""" .r
106
- val CandidateV = """ (\d+)\.(\d+)\.(\d+)(-RC\d+)""" .r
107
- val NonReleaseV = """ (\d+)\.(\d+)\.(\d+)([-\w+]*)""" .r
108
- v match {
109
- case ReleaseV (x, y, z, ht) => Some ((x.toInt, y.toInt, z.toInt))
110
- case CandidateV (x, y, z, ht) => Some ((x.toInt, y.toInt, z.toInt))
111
- case NonReleaseV (x, y, z, ht) if z.toInt > 0 => Some ((x.toInt, y.toInt, z.toInt))
112
- case _ => None
113
- }
114
- }
115
-
116
105
/** Patches the IncOptions so that .tasty and .hasTasty files are pruned as needed.
117
106
*
118
107
* This code is adapted from `scalaJSPatchIncOptions` in Scala.js, which needs
@@ -142,12 +131,13 @@ object DottyPlugin extends AutoPlugin {
142
131
143
132
override val globalSettings : Seq [Def .Setting [_]] = Seq (
144
133
onLoad in Global := onLoad.in(Global ).value.andThen { state =>
134
+
135
+ val requiredVersion = " >=1.2.7"
136
+
145
137
val sbtV = sbtVersion.value
146
- sbtFullVersion(sbtV) match {
147
- case Some ((1 , sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 5 ) =>
148
- case _ =>
149
- sys.error(s " The sbt-dotty plugin cannot work with this version of sbt ( $sbtV), sbt >= 1.1.5 is required. " )
150
- }
138
+ if (! VersionNumber (sbtV).matchesSemVer(SemanticSelector (requiredVersion)))
139
+ sys.error(s " The sbt-dotty plugin cannot work with this version of sbt ( $sbtV), sbt $requiredVersion is required. " )
140
+
151
141
state
152
142
}
153
143
)
0 commit comments