Skip to content

Commit

Permalink
use cli3.x.y for Scala 3 projects
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Aug 22, 2024
1 parent ab31f5d commit cfbd99e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
8 changes: 1 addition & 7 deletions src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,7 @@ object ScalafixInterface {
None
case None =>
// cache miss, resolve scalafix artifacts and classload them
if (scalafixScalaBinaryVersion.startsWith("3"))
logger.error(
"To use Scalafix on Scala 3 projects, you must unset `scalafixScalaBinaryVersion`. " +
"Rules such as ExplicitResultTypes requiring the project version to match the Scalafix " +
"version are unsupported for the moment."
)
else if (scalafixScalaBinaryVersion == "2.11")
if (scalafixScalaBinaryVersion == "2.11")
logger.error(
"Scala 2.11 is no longer supported. Please downgrade to the final version supporting " +
"it: sbt-scalafix 0.10.4."
Expand Down
14 changes: 4 additions & 10 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ object ScalafixPlugin extends AutoPlugin {
"Can be set in ThisBuild or at project-level."
)
@deprecated(
"scalafixScalaBinaryVersion now follows scalaBinaryVersion by default",
"scalafixScalaBinaryVersion now follows scalaVersion by default",
"0.12.1"
)
val scalafixScalaBinaryVersion: SettingKey[String] =
settingKey[String](
"The Scala binary version used for scalafix execution. Must be set at project-level. " +
"Custom rules must be compiled against that binary version. Defaults to 2.12 for 2.12 projects, " +
"2.13 otherwise."
"The Scala version used for scalafix execution. Must be set at project-level. " +
"Custom rules must be compiled against that binary version. Defaults to the project's scalaVersion."
)
val scalafixConfig: SettingKey[Option[File]] =
settingKey[Option[File]](
Expand Down Expand Up @@ -268,12 +267,7 @@ object ScalafixPlugin extends AutoPlugin {
},
ivyConfigurations += ScalafixConfig,
scalafixAll := scalafixAllInputTask.evaluated,
(scalafixScalaBinaryVersion: @nowarn) := {
scalaBinaryVersion.value match {
case "2.12" => "2.12"
case _ => "2.13"
}
}
(scalafixScalaBinaryVersion: @nowarn) := scalaVersion.value
)

override lazy val globalSettings: Seq[Def.Setting[_]] = Seq(
Expand Down
9 changes: 8 additions & 1 deletion src/sbt-test/sbt-scalafix/scalafixEnable/build.sbt
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
val V = _root_.scalafix.sbt.BuildInfo

lazy val config = project
lazy val config = project.settings(
scalafixScalaBinaryVersion := scalaBinaryVersion.value, // to support old scalafix-interface
)

lazy val unsupported = project.settings(
scalafixScalaBinaryVersion := scalaBinaryVersion.value, // to support old scalafix-interface
// 2.11.x is not supported
scalaVersion := "2.11.12"
)

lazy val bumpScala = project.settings(
scalafixScalaBinaryVersion := scalaBinaryVersion.value, // to support old scalafix-interface
// semanticdb-scalac_2.12.0 was never available
scalaVersion := "2.12.0"
)

lazy val downgradeScalameta = project.settings(
scalafixScalaBinaryVersion := scalaBinaryVersion.value, // to support old scalafix-interface
// semanticdb-scalac_2.12.4 no longer available after 4.1.9
scalaVersion := "2.12.4"
)

lazy val upgradeScalameta = project.settings(
scalafixScalaBinaryVersion := scalaBinaryVersion.value, // to support old scalafix-interface
// semanticdb-scalac_2.12.15 not yet available in 4.4.10, became available as of 4.4.28
scalaVersion := "2.12.15"
)

lazy val available = project.settings(
scalafixScalaBinaryVersion := scalaBinaryVersion.value, // to support old scalafix-interface
// semanticdb-scalac_2.13.4 available in 4.4.10
scalaVersion := "2.13.4",
crossScalaVersions := Seq("2.12.15")
Expand Down
1 change: 1 addition & 0 deletions src/sbt-test/skip-windows/caching/test
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ $ copy-file files/Valid.scala src/main/scala/Valid.scala
> set scalafixDependencies in ThisBuild := Nil
> scalafix --check ProcedureSyntax
> reload plugins
> set scalafixBinaryVersion := scalaBinaryVersion.value // to support old scalafix-interface
> 'set dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.11.0+134-f4dcc6fa-SNAPSHOT"' // different than above, requires bumping when using new APIs
> session save
> reload return
Expand Down

0 comments on commit cfbd99e

Please sign in to comment.