@@ -13,24 +13,45 @@ object PartialUnification extends AutoPlugin {
13
13
14
14
import autoImport ._
15
15
16
- def pluginOrFlag (scalaVersion : String , pluginModule : ModuleID ): Either [ModuleID , String ] = {
17
- val pluginDependency = Left (compilerPlugin(pluginModule cross CrossVersion .full))
18
- val flag = Right (" -Ypartial-unification" )
19
- val VersionNumber ((major +: minor +: patch +: _), _, _) = scalaVersion
20
-
21
- (major, minor, patch) match {
22
- case (2 , 10 , p) if p >= 6 => pluginDependency
23
- case (2 , 11 , 8 ) => pluginDependency
24
- case (2 , 11 , p) if p >= 9 => flag
25
- case (2 , 12 , _) => flag
26
- case (2 , 13 , _) => flag
16
+ def pluginOrFlag (scalaVersion : String , pluginModule : ModuleID ): Resolution = {
17
+ val pluginDependency = Resolution .Plugin (compilerPlugin(pluginModule cross CrossVersion .full))
18
+ val flag = Resolution .Flag (" -Ypartial-unification" )
19
+ val VersionNumber ((major +: minor +: patch +: _), tags, _) = scalaVersion
20
+
21
+ (major, minor, patch, tags) match {
22
+ case (2 , 10 , p, _) if p >= 6 => pluginDependency
23
+ case (2 , 11 , 8 , _) => pluginDependency
24
+ case (2 , 11 , p, _) if p >= 9 => flag
25
+ case (2 , 12 , _, _) => flag
26
+ case (2 , 13 , _, milestone +: _) if milestone == " M1" || milestone == " M2" || milestone == " M3" => flag // ignoring the M4 snapshot
27
+ case (2 , 13 , _, _) => Resolution .NothingHappens
27
28
case _ => sys.error(s " scala version $scalaVersion is not supported by this plugin. " )
28
29
}
29
30
}
30
31
31
32
override val projectSettings = Seq (
32
33
partialUnificationModule := " com.milessabin" % " si2712fix-plugin" % " 1.2.0" ,
33
- libraryDependencies ++= pluginOrFlag(scalaVersion.value, partialUnificationModule.value).left.toSeq,
34
- scalacOptions ++= pluginOrFlag(scalaVersion.value, partialUnificationModule.value).right.toSeq
34
+
35
+ libraryDependencies ++= {
36
+ pluginOrFlag(scalaVersion.value, partialUnificationModule.value) match {
37
+ case Resolution .Plugin (id) => Seq (id)
38
+ case _ => Seq .empty
39
+ }
40
+ },
41
+
42
+ scalacOptions ++= {
43
+ pluginOrFlag(scalaVersion.value, partialUnificationModule.value) match {
44
+ case Resolution .Flag (flag) => Seq (flag)
45
+ case _ => Seq .empty
46
+ }
47
+ }
35
48
)
49
+
50
+ sealed trait Resolution extends Product with Serializable
51
+
52
+ object Resolution {
53
+ final case class Plugin (id : ModuleID ) extends Resolution
54
+ final case class Flag (flag : String ) extends Resolution
55
+ case object NothingHappens extends Resolution
56
+ }
36
57
}
0 commit comments