Skip to content

Commit e903793

Browse files
MasseGuillaumeolafurpg
authored andcommitted
Split rule instructions
1 parent 84d9654 commit e903793

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

README.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,56 @@ The library also adds backported versions of new collection types, currently `sc
3838

3939
## Migration Tool
4040

41-
We created two migration rules:
42-
43-
* `Collection213Upgrade` For upgrading applications (like web server, etc) from 2.11/2.12 to 2.13
44-
* `Collection213CrossCompat` For library that wants to cross compile to 2.11, 2.12 and 2.13
45-
46-
The migration rules use scalafix. Please see the [official installation instruction](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your exact Scala version is supported.
41+
The migration rules use scalafix. Please see the [official installation instruction](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.6).
4742

4843
```scala
4944
// project/plugins.sbt
5045

5146
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0-RC1")
5247
```
5348

49+
### Collection213Upgrade
50+
51+
The `Collection213Upgrade` rewrite upgrades to the 2.13 collections without the ability to compile the code-base with 2.12 or later. This rewrite is suitable for applications such as web servers that don't need to cross-compile against multiple Scala versions.
52+
5453
```scala
55-
// build.sbt or project/Build.scala
54+
// build.sbt
55+
scalafixDependencies += "org.scala-lang.modules" ...
56+
scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on")
57+
```
5658

57-
// If you are using project/Build.scala add the following imports:
58-
import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb}
59+
```bash
60+
// sbt shell
61+
> ;scalafix Collections213Upgrade;test:scalafix Collections213Upgrade
62+
```
5963

60-
val collectionCompatVersion = "0.2.1"
61-
val collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion
64+
### Collections213CrossCompat
6265

63-
libraryDependencies += collectionCompat // required for Collection213CrossCompat
64-
addCompilerPlugin(scalafixSemanticdb)
65-
scalacOptions ++= List(
66-
"-Yrangepos",
67-
"-P:semanticdb:synthetics:on" // Required by the collection rewrites
68-
)
6966

70-
scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % collectionCompatVersion
71-
```
67+
The `Collections213CrossCompat` rewrite upgrades to the 2.13 collections without the ability to compile the code-base with 2.12 or later. This rewrite is suitable for libraries that are cross-published for multiple Scala versions.
68+
69+
To cross-build for 2.12 and 2.11, an additional module `scala-collection-compat` is required to provide missing extensions methods. This enables you to write your library using the latest 2.13 collections API while still supporting users on an older Scala version.
70+
71+
// build.sbt
72+
scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "0.2.1"
73+
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1"
74+
scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on")
7275

73-
Then run:
7476

7577
```bash
76-
> ;scalafix Collection213Upgrade ;test:scalafix Collection213Upgrade # For Applications
77-
# or
78-
> ;scalafix Collection213CrossCompat ;test:scalafix Collection213CrossCompat # For Libraries
78+
// sbt shell
79+
> ;scalafix Collections213CrossCompat;test:scalafix Collections213CrossCompat
7980
```
8081

82+
### Build.scala
83+
84+
```scala
85+
// If you are using project/Build.scala add the following imports:
86+
import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb}
87+
```
88+
89+
### Contributing
90+
8191
The migration tool is not exhaustive and we will continue to improve
8292
it over time. If you encounter a use case that’s not supported, please
8393
report it as described in the

0 commit comments

Comments
 (0)