-
Notifications
You must be signed in to change notification settings - Fork 44
decouple sbt-scalafix from scalafix lifecycle #482
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,16 @@ import sbt._ | |
|
||
object Dependencies { | ||
val x = List(1) // scalafix:ok | ||
def scalafixVersion: String = "0.14.2" | ||
|
||
// keep this as low as possible, to allow bumping sbt-scalafix without scalafix-interfaces | ||
def scalafixInterfacesVersion: String = | ||
"0.14.2+48-9b6e03ac-SNAPSHOT" // scala-steward:off | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛑 this must be updated to the next stable version before merging, or at least tagging a release |
||
|
||
val all = List( | ||
"ch.epfl.scala" % "scalafix-interfaces" % scalafixInterfacesVersion | ||
exclude ("ch.epfl.scala", "scalafix-properties"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the key change in this PR, leveraging scalacenter/scalafix#2226.
|
||
"ch.epfl.scala" % "scalafix-interfaces" % scalafixInterfacesVersion % Test, | ||
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.202401111512-r", | ||
"ch.epfl.scala" % "scalafix-interfaces" % scalafixVersion, | ||
"io.get-coursier" % "interface" % "1.0.28", | ||
"org.scala-lang.modules" %% "scala-collection-compat" % "2.13.0" | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,13 @@ object ScalafixPlugin extends AutoPlugin { | |
"Defaults to a wrapper around `sbt.Logger`." | ||
) | ||
|
||
val scalafixSemanticdb: ModuleID = | ||
val scalafixAllowDynamicFallback: SettingKey[Boolean] = | ||
settingKey[Boolean]( | ||
"Control whether the latest version of scalafix may be downloaded instead of failing when " + | ||
"scalafix-interfaces is not explicitly provided. Off by default because non-deterministic." | ||
) | ||
Comment on lines
+92
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was initially a private key used internally by scalafixEnable, but I thought we could make it public for power users, without necessarily advertizing it in the docs |
||
|
||
lazy val scalafixSemanticdb: ModuleID = | ||
scalafixSemanticdb(BuildInfo.scalametaVersion) | ||
def scalafixSemanticdb(scalametaVersion: String): ModuleID = | ||
("org.scalameta" % "semanticdb-scalac" % scalametaVersion) | ||
|
@@ -263,7 +269,8 @@ object ScalafixPlugin extends AutoPlugin { | |
"via `semanticdbVersion` does follow the version recommended " + | ||
"for Scalafix, but is not supported for the given Scala " + | ||
s"version ${scalaV}. Please consider upgrading to a more recent version " + | ||
"of sbt-scalafix and/or Scala, or uninstalling sbt-scalafix plugin." | ||
"of \"ch.epfl.scala\" % \"scalafix-interfaces\" and/or Scala, or " + | ||
"uninstalling sbt-scalafix." | ||
throw inc.copy(message = Some(msg)) | ||
case _ => | ||
} | ||
|
@@ -287,6 +294,7 @@ object ScalafixPlugin extends AutoPlugin { | |
scalafixCaching := true, | ||
scalafixResolvers := defaultScalafixResolvers, | ||
scalafixDependencies := Nil, | ||
scalafixAllowDynamicFallback := false, | ||
commands += ScalafixEnable.command, | ||
scalafixInterfaceCache := new BlockingCache, | ||
concurrentRestrictions += Tags.exclusiveGroup(Scalafix), | ||
|
@@ -443,6 +451,12 @@ object ScalafixPlugin extends AutoPlugin { | |
config: ConfigKey | ||
): Def.Initialize[Task[Unit]] = { | ||
val task = Def.taskDyn { | ||
if (!scalafixAllowDynamicFallback.value) { | ||
// force scalafix properties to be loaded, to trigger an actionnable error instead | ||
// of letting the built-in scalafix-interfaces fallback to the latest scalafix version | ||
BuildInfo.scalafixVersion | ||
} | ||
|
||
implicit val conv: FileConverter = fileConverter.value | ||
|
||
val errorLogger = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
resolvers += Resolver.sonatypeRepo("public") | ||
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0" | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version")) | ||
libraryDependencies += "ch.epfl.scala" % "scalafix-interfaces" % | ||
sys.props("scalafix-interfaces.version") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
resolvers += Resolver.sonatypeRepo("public") | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version")) | ||
libraryDependencies += "ch.epfl.scala" % "scalafix-interfaces" % | ||
sys.props("scalafix-interfaces.version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sure the
project/plugins.sbt
version is up to date, for dogfooding