@@ -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
@@ -90,20 +93,6 @@ object DottyPlugin extends AutoPlugin {
90
93
override def requires : Plugins = plugins.JvmPlugin
91
94
override def trigger = allRequirements
92
95
93
- // Adapted from CrossVersionUtil#sbtApiVersion
94
- private def sbtFullVersion (v : String ): Option [(Int , Int , Int )] =
95
- {
96
- val ReleaseV = """ (\d+)\.(\d+)\.(\d+)(-\d+)?""" .r
97
- val CandidateV = """ (\d+)\.(\d+)\.(\d+)(-RC\d+)""" .r
98
- val NonReleaseV = """ (\d+)\.(\d+)\.(\d+)([-\w+]*)""" .r
99
- v match {
100
- case ReleaseV (x, y, z, ht) => Some ((x.toInt, y.toInt, z.toInt))
101
- case CandidateV (x, y, z, ht) => Some ((x.toInt, y.toInt, z.toInt))
102
- case NonReleaseV (x, y, z, ht) if z.toInt > 0 => Some ((x.toInt, y.toInt, z.toInt))
103
- case _ => None
104
- }
105
- }
106
-
107
96
/** Patches the IncOptions so that .tasty and .hasTasty files are pruned as needed.
108
97
*
109
98
* This code is adapted from `scalaJSPatchIncOptions` in Scala.js, which needs
@@ -133,12 +122,13 @@ object DottyPlugin extends AutoPlugin {
133
122
134
123
override val globalSettings : Seq [Def .Setting [_]] = Seq (
135
124
onLoad in Global := onLoad.in(Global ).value.andThen { state =>
125
+
126
+ val requiredVersion = " >=1.2.7"
127
+
136
128
val sbtV = sbtVersion.value
137
- sbtFullVersion(sbtV) match {
138
- case Some ((1 , sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 5 ) =>
139
- case _ =>
140
- sys.error(s " The sbt-dotty plugin cannot work with this version of sbt ( $sbtV), sbt >= 1.1.5 is required. " )
141
- }
129
+ if (! VersionNumber (sbtV).matchesSemVer(SemanticSelector (requiredVersion)))
130
+ sys.error(s " The sbt-dotty plugin cannot work with this version of sbt ( $sbtV), sbt $requiredVersion is required. " )
131
+
142
132
state
143
133
}
144
134
)
0 commit comments