Skip to content

Commit d0a8f3b

Browse files
authored
Merge pull request #1990 from scalacenter/scalafixScalaBinaryVersion213
sbt-scalafix scalafixScalaBinaryVersion is now deprecated
2 parents 2ca0d85 + 909248c commit d0a8f3b

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

docs/developers/local-rules.md

-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ change sets as the domain sources they will be run against.
1616
Make sure the sbt plugin, as well as the Scala compiler plugin and options [are
1717
set up correctly](../users/installation.md#sbt).
1818

19-
Although it is possible to define your rules in a Scala binary version that
20-
does not match your build, it is highly recommended that you align them via:
21-
22-
```diff
23-
// build.sbt
24-
+ThisBuild / scalafixScalaBinaryVersion :=
25-
+ CrossVersion.binaryScalaVersion(scalaVersion.value)
26-
```
27-
2819
> Note that any potential external Scalafix rule, loaded with the
2920
> `scalafixDependencies` setting key, must be built and published against the
3021
> same Scala binary version.

docs/developers/setup.md

+9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ several sub-projects for each directory.
6767
can be applied.
6868
- `tests` verifies each `input` sub-project against a `rules` sub-project.
6969

70+
> Failure to cross-build will reduce the reach of your rule, as users running
71+
> Scalafix in a Scala version you are not building for will get either
72+
> resolution errors (for published rules) or potential compilation errors (for
73+
> unpublished rules, compiled on-the-fly). Note that `scalafix-core` brings
74+
> [`scala-collection-compat`](https://github.com/scala/scala-collection-compat),
75+
> which allows to use the Scala 2.13 collection framework on Scala 2.12, and
76+
> therefore removes the need for maintaining different source files depending
77+
> on the Scala version.
78+
7079
The `scalafix/` directory is a self-contained sbt build and can live in the same
7180
directory as your existing library.
7281

docs/users/installation.md

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ Great! You are all set to use Scalafix with sbt :)
168168
| `scalafixDependencies` | `SettingKey[Seq[ModuleID]]` | Dependencies making [custom rules](#run-custom-rules) available via their simple name. Can be set in `ThisBuild` or at project-level. Defaults to `Nil`.
169169
| `scalafixOnCompile` | `SettingKey[Boolean]` | When `true`, Scalafix rule(s) declared in `scalafixConfig` are run on compilation, applying rewrites and failing on lint errors. Defaults to `false`.
170170
| `scalafixResolvers` | `SettingKey[Seq[Repository]]` | Custom resolvers where `scalafixDependencies` are resolved from, in addition to the user-defined sbt `ThisBuild / resolvers`. Must be set in `ThisBuild`. Defaults to: Ivy2 local, Maven Central, Sonatype releases & Sonatype snapshots.
171-
| `scalafixScalaBinaryVersion` | `SettingKey[String]` | Scala binary version used for Scalafix execution. Can be set in `ThisBuild` or at project-level. Defaults to 2.12. For advanced rules such as ExplicitResultTypes to work, it must match the binary version defined in the build for compiling sources. Note that `scalafixDependencies` artifacts must be published against that Scala version.
172171
173172
174173
### Main and test sources

project/ScalafixBuild.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
5656
}
5757

5858
val prevVersions = previousVersions(sv).map(prev => TargetAxis(prev))
59-
val scala3FromScala2 = TargetAxis(scala3)
6059
val xsource3 = TargetAxis(sv, xsource3 = true)
6160

62-
(prevVersions :+ scala3FromScala2 :+ xsource3).map((sv, _))
63-
}
61+
(prevVersions :+ xsource3).map((sv, _))
62+
} :+ (scala213, TargetAxis(scala3))
6463

6564
lazy val publishLocalTransitive =
6665
taskKey[Unit]("Run publishLocal on this project and its dependencies")

0 commit comments

Comments
 (0)