Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update project for Scala 3.0.0 and Scala 2.13.6 #40

Merged
merged 4 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ scalacOptions.in(Tut) ~= filterConsoleScalacOptions

I can't promise this plugin will work for old minor releases of Scala. It has been tested with:

* 2.13.6
* 2.13.5
* 2.13.4
* 2.13.3
Expand All @@ -40,9 +41,8 @@ I can't promise this plugin will work for old minor releases of Scala. It has be

and Dotty versions:

* 3.0.0-M1
* 0.27.0-RC1
* 0.26.0
* 3.0.0
* 3.0.0-RC3

### License

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ developers := List(
)
homepage := scmInfo.value.map(_.browseUrl)

crossSbtVersions := Seq("0.13.18", "1.4.7")
crossSbtVersions := Seq("1.4.9")

enablePlugins(SbtPlugin)

Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.7
sbt.version=1.5.2
9 changes: 6 additions & 3 deletions src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object TpolecatPlugin extends AutoPlugin {
val V2_13_3 = Version(2, 13, 3)
val V2_13_4 = Version(2, 13, 4)
val V2_13_5 = Version(2, 13, 5)
val V2_13_6 = Version(2, 13, 6)
val V3_0_0 = Version(3, 0, 0)

implicit val versionOrdering: Ordering[Version] =
Expand Down Expand Up @@ -111,7 +112,9 @@ object TpolecatPlugin extends AutoPlugin {
ScalacOption("-Wunused:privates", addedIn = Some(V2_13_0), removedIn = Some(V3_0_0)), // ^ Replaces the above
ScalacOption("-Ywarn-value-discard", removedIn = Some(V2_13_0)), // Warn when non-Unit expression results are unused.
ScalacOption("-Wvalue-discard", addedIn = Some(V2_13_0), removedIn = Some(V3_0_0)), // ^ Replaces the above
ScalacOption("-Ykind-projector", addedIn = Some(V3_0_0)) // Enables a subset of kind-projector syntax (see https://github.com/lampepfl/dotty/pull/7775)
ScalacOption("-Ykind-projector", addedIn = Some(V3_0_0)), // Enables a subset of kind-projector syntax (see https://github.com/lampepfl/dotty/pull/7775)
ScalacOption("-Vimplicits", addedIn = Some(V2_13_6), removedIn = Some(V3_0_0)), // Enables the tek/splain features to make the compiler print implicit resolution chains when no implicit value can be found
ScalacOption("-Vtype-diffs", addedIn = Some(V2_13_6), removedIn = Some(V3_0_0)) // Enables the tek/splain features to turn type error messages (found: X, required: Y) into colored diffs between the two types
)

object autoImport {
Expand Down Expand Up @@ -164,7 +167,7 @@ object TpolecatPlugin extends AutoPlugin {

override def projectSettings: Seq[Setting[_]] = Seq(
scalacOptions ++= scalacOptionsFor(scalaVersion.value),
scalacOptions.in(Compile, console) ~= filterConsoleScalacOptions,
scalacOptions.in(Test, console) ~= filterConsoleScalacOptions
Compile / console / scalacOptions ~= filterConsoleScalacOptions,
Test / console / scalacOptions ~= filterConsoleScalacOptions
)
}
48 changes: 43 additions & 5 deletions src/sbt-test/sbt-tpolecat/scalacOptions/build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,51 @@
import scala.util.Try

val scala2Versions = Seq(
"2.10.7",
"2.11.12",
"2.12.12",
"2.13.3",
"2.13.4",
"2.13.5"
"2.13.5",
"2.13.6"
)

val scala3Versions = Seq(
"3.0.0-RC3",
"3.0.0"
)

crossScalaVersions := (CrossVersion.partialVersion(sbtVersion.value) match {
case Some((1, _)) => scala2Versions :+ "0.26.0" :+ "0.27.0-RC1" :+ "3.0.0-M1" // the dotty plugin isn't available for sbt 0.13.x, so we can only add the dotty version here
case _ => scala2Versions
})
crossScalaVersions := {
object ExtractVersion {
val sbtVersionMatch = raw"(\d+)\.(\d+)\.(\d+)".r
def unapply(sbtVersion: String): Option[(Long, Long, Long)] = {
sbtVersion match {
case sbtVersionMatch(major, minor, patch) =>
for {
maj <- Try(major.toLong).toOption
min <- Try(minor.toLong).toOption
p <- Try(patch.toLong).toOption
} yield (maj, min, p)

case _ =>
None
}
}
}

def supportedSbtVersions(major: Long, minor: Long, patch: Long): Boolean =
(major, minor, patch) match {
case (1, 5, patch) if patch >= 2 => true
case (1, minor, _) if minor > 5 => true
case (major, _, _) if major > 1 => true
case _ => false
}

sbtVersion.value match {
case ExtractVersion(major, minor, patch) if supportedSbtVersions(major, minor, patch) =>
scala2Versions ++ scala3Versions

case _ =>
scala2Versions
}
}
9 changes: 0 additions & 9 deletions src/sbt-test/sbt-tpolecat/scalacOptions/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % System.getProperty("plugin.version"))

libraryDependencies ++= {
CrossVersion.partialVersion(sbtVersion.value) match {
case Some((1, _)) => // the dotty plugin isn't available for sbt 0.13.x
Seq(Defaults.sbtPluginExtra("ch.epfl.lamp" % "sbt-dotty" % "0.4.5", (sbtBinaryVersion in update).value, (scalaBinaryVersion in update).value))
case _ =>
Seq.empty
}
}