Skip to content

Commit 2578d80

Browse files
Document how to run sbt-scalafix
1 parent 9f2d274 commit 2578d80

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,47 @@ With this compatibility library you can also use the 2.13 syntax which uses a co
3434
The 2.13 version consists only of an empty `scala.collection.compat` package object that allows you to write `import scala.collection.compat._` in 2.13.
3535
The 2.11/2.12 version has the compatibility extensions in this package.
3636

37-
3837
The library also adds backported versions of new collection types, currently `scala.collection.compat.immutable.ArraySeq`. In 2.11/2.12, this type is a new collection implementation. In 2.13, it is an alias for `scala.collection.immutable.ArraySeq`.
3938

4039
## Migration Tool
4140

42-
A tool is being developed to automatically migrate code that uses the standard
43-
collection to use the strawman.
41+
We created two migration rules:
42+
43+
* `Collection213Upgrade` For applications (like web server, etc)
44+
* `Collection213CrossCompat` For library that wants to cross compile to (2.11, 2.12 and 2.13)
45+
46+
```scala
47+
// project/plugins.sbt
48+
49+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.7.0-RC1")
50+
```
51+
52+
```scala
53+
// build.sbt or project/Build.scala
54+
55+
// If you are using project/Build.scala add the following imports:
56+
import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb}
4457

45-
To use it, add the [scalafix](https://scalacenter.github.io/scalafix/) sbt plugin
46-
to your build, as explained in
47-
[its documentation](https://scalacenter.github.io/scalafix/#Installation).
58+
val collectionCompatVersion = "0.2.1"
59+
val collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion
4860

61+
libraryDependencies += collectionCompat // required for Collection213CrossCompat
62+
addCompilerPlugin(scalafixSemanticdb)
63+
scalacOptions ++= List(
64+
"-Yrangepos",
65+
"-Ywarn-unused-import",
66+
"-P:semanticdb:synthetics:on"
67+
)
68+
69+
scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % Dependencies.collectionCompatVersion
4970
```
50-
scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1"
71+
72+
Then run:
73+
74+
```bash
75+
> ;scalafix Collection213Upgrade ;test:scalafix Collection213Upgrade # For Applications
76+
# or
77+
> ;scalafix Collection213CrossCompat ;test:scalafix Collection213CrossCompat # For Libraries
5178
```
5279

5380
The migration tool is not exhaustive and we will continue to improve

0 commit comments

Comments
 (0)