Skip to content

Commit 4b53f80

Browse files
committed
scalafix-interfaces must now be provided alongside sbt-scalafix
This will allow for a separate release lifecycle
1 parent d54f51b commit 4b53f80

File tree

35 files changed

+101
-11
lines changed

35 files changed

+101
-11
lines changed

build.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@ scriptedParallelInstances := 2
101101
scriptedLaunchOpts ++= Seq(
102102
"-Xmx2048M",
103103
s"-Dplugin.version=${version.value}",
104+
s"-Dinterfaces.version=${Dependencies.scalafixVersion}",
104105
"-Dsbt-scalafix.uselastmodified=true" // the caching scripted relies on sbt-scalafix only checking file attributes, not content
105106
)

project/Dependencies.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import sbt._
22

33
object Dependencies {
44
val x = List(1) // scalafix:ok
5-
def scalafixVersion: String = "0.14.2"
5+
6+
// keep this as low as possible to ensure sbt-scalafix can be upgraded even if scalafix-interfaces cannot
7+
def scalafixVersion: String =
8+
"0.14.2+39-c2bf18de-SNAPSHOT" // https://github.com/scalacenter/scalafix/pull/2226
69

710
val all = List(
11+
"ch.epfl.scala" % "scalafix-interfaces" % scalafixVersion
12+
exclude ("ch.epfl.scala", "scalafix-properties"),
13+
"ch.epfl.scala" % "scalafix-interfaces" % scalafixVersion % Test,
814
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.202401111512-r",
9-
"ch.epfl.scala" % "scalafix-interfaces" % scalafixVersion,
1015
"io.get-coursier" % "interface" % "1.0.28",
1116
"org.scala-lang.modules" %% "scala-collection-compat" % "2.13.0"
1217
)

project/plugins.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ Compile / unmanagedSourceDirectories ++= {
1010
)
1111
}
1212
libraryDependencies ++= Dependencies.all
13+
14+
// latest version of interfaces to test compatibility & get most recent behavior for scalafix invocations
15+
libraryDependencies += "ch.epfl.scala" % "scalafix-interfaces" % "0.14.2"

readme.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ https://github.com/scalacenter/scalafix/issues
1212

1313
## Nightlies
1414

15-
Our CI publishes a [snapshot release to Sonatype](https://oss.sonatype.org/content/repositories/snapshots/ch/epfl/scala/sbt-scalafix_2.12_1.0/)
16-
on every merge into main. The latest snapshot at the time of the writing can be used via:
15+
Our CI publishes a snapshot release to Sonatype on every merge into main. The latest snapshot(s) of
16+
[the plugin](https://oss.sonatype.org/content/repositories/snapshots/ch/epfl/scala/sbt-scalafix_2.12_1.0/)
17+
and/or [scalafix-interfaces](https://oss.sonatype.org/content/repositories/snapshots/ch/epfl/scala/scalafix-interfaces/)
18+
can be used via:
1719

1820
```diff
1921
// project/plugins.sbt
20-
-addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34")
21-
+addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34+5-5dfe5fb6-SNAPSHOT")
2222
+resolvers += Resolver.sonatypeRepo("snapshots")
23+
-addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.2")
24+
+addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.2+10-d54f51b2-SNAPSHOT")
25+
-libraryDependencies += "ch.epfl.scala" % "scalafix-interfaces" % "0.14.2"
26+
+libraryDependencies += "ch.epfl.scala" % "scalafix-interfaces" % "0.14.2+37-a0cfc1df-SNAPSHOT"
2327
```
2428

2529
## Team

src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ object ScalafixInterface {
151151
callback: ScalafixMainCallback
152152
): ScalafixInterface = {
153153

154+
// force scalafix properties to be loaded, to handle failure within sbt-scalafix instead
155+
// of within scalafix-interfaces, which has a more generic error message
156+
scalafix.sbt.BuildInfo.scalafixVersion
157+
154158
// Build or retrieve from the cache the scalafix interface that can run
155159
// built-in rules. This is the most costly instantiation, which should be
156160
// shared as much as possible.

src/main/scala/scalafix/sbt/BuildInfo.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ object BuildInfo {
2929
props.load(stream)
3030
case None =>
3131
sys.error(
32-
s"failed to load the resource file '$propertiesPath'. To fix this problem, make sure to enable the sbt-scalafix in 'project/plugins.sbt' and validate that the scalafix-interfaces jar is available on the classpath of the sbt build."
32+
s"failed to load the resource file '$propertiesPath'; " +
33+
"to fix this problem, add \"ch.epfl.scala\" % \"scalafix-interfaces\" " +
34+
"to libraryDependencies in 'project/plugins.sbt'"
3335
)
3436
}
3537
props
@@ -39,7 +41,8 @@ object BuildInfo {
3941
Option(props.getProperty(key)).getOrElse {
4042
sys.error(
4143
s"sbt-scalafix property '$key' missing in $propertiesPath; " +
42-
"to fix this problem, upgrade to the latest version of Scalafix."
44+
"to fix this problem, upgrade to a more recent version of " +
45+
"\"ch.epfl.scala\" % \"scalafix-interfaces\""
4346
)
4447
}
4548
}

src/main/scala/scalafix/sbt/ScalafixPlugin.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ object ScalafixPlugin extends AutoPlugin {
8989
"Defaults to a wrapper around `sbt.Logger`."
9090
)
9191

92-
val scalafixSemanticdb: ModuleID =
92+
lazy val scalafixSemanticdb: ModuleID =
9393
scalafixSemanticdb(BuildInfo.scalametaVersion)
9494
def scalafixSemanticdb(scalametaVersion: String): ModuleID =
9595
("org.scalameta" % "semanticdb-scalac" % scalametaVersion)
@@ -260,7 +260,8 @@ object ScalafixPlugin extends AutoPlugin {
260260
"via `semanticdbVersion` does follow the version recommended " +
261261
"for Scalafix, but is not supported for the given Scala " +
262262
s"version ${scalaV}. Please consider upgrading to a more recent version " +
263-
"of sbt-scalafix and/or Scala, or uninstalling sbt-scalafix plugin."
263+
"of \"ch.epfl.scala\" % \"scalafix-interfaces\" and/or Scala, or " +
264+
"uninstalling sbt-scalafix."
264265
throw inc.copy(message = Some(msg))
265266
case _ =>
266267
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
33
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
4+
libraryDependencies +=
5+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
33
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
4+
libraryDependencies +=
5+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
33
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
4+
libraryDependencies +=
5+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
33
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
4+
libraryDependencies +=
5+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
lazy val checkLogs =
2+
taskKey[Unit]("Check presence of call to action in last logs")
3+
4+
checkLogs := {
5+
val lastLog: File = BuiltinCommands.lastLogFile(state.value).get
6+
val last: String = IO.read(lastLog)
7+
assert(
8+
last.contains(
9+
"add \"ch.epfl.scala\" % \"scalafix-interfaces\" to libraryDependencies in 'project/plugins.sbt'"
10+
),
11+
"actionable error should be logged"
12+
)
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resolvers += Resolver.sonatypeRepo("public")
2+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# the project loads, but scalafix fails
2+
-> scalafix
3+
> checkLogs
4+
5+
# a build reference to the member relying on scalafix properties prevents loading the project
6+
-> set ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
35
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"

src/sbt-test/sbt-scalafix/unavailable-semanticdb-scalac/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ checkLogs := {
1919
assert(
2020
logLines.exists(
2121
_.contains(
22-
"Please consider upgrading to a more recent version of sbt-scalafix and/or Scala, or uninstalling sbt-scalafix plugin"
22+
"Please consider upgrading to a more recent version of \"ch.epfl.scala\" % \"scalafix-interfaces\" and/or Scala, or uninstalling sbt-scalafix"
2323
)
2424
)
2525
)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
35
addSbtPlugin("nl.gn0s1s" %% "sbt-dotenv" % "3.1.1")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")

src/sbt-test/skip-sbt1.4/testkit/project/plugins.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
35

46
libraryDependencies ++= {
57
val sbtV = sbtBinaryVersion.value
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resolvers += Resolver.sonatypeRepo("public")
22
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3+
libraryDependencies +=
4+
"ch.epfl.scala" % "scalafix-interfaces" % sys.props("interfaces.version")

0 commit comments

Comments
 (0)