From aaf4511da0854fb75971a551eba8578d2e196704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 12 Oct 2018 14:59:53 +0200 Subject: [PATCH 1/8] Upgrade to scalafix v0.9.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index b3d7d4f7..3cb37b53 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -10,7 +10,7 @@ val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty) addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0") addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.7.0-RC1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3") From d5f3fd079e3de19344e49a4383c1604c8eda21a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Mass=C3=A9?= Date: Mon, 24 Sep 2018 11:36:02 +0200 Subject: [PATCH 2/8] Bump to scalafix 0.9.0-RC1 --- README.md | 9 +++++---- build.sbt | 4 ---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4b6d5e76..491b7c1b 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ We created two migration rules: ```scala // project/plugins.sbt -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.7.0-RC1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0-RC1") ``` ```scala @@ -62,11 +62,10 @@ libraryDependencies += collectionCompat // required for Collection213CrossCompat addCompilerPlugin(scalafixSemanticdb) scalacOptions ++= List( "-Yrangepos", - "-Ywarn-unused-import", - "-P:semanticdb:synthetics:on" + "-P:semanticdb:synthetics:on" // Required by the collection rewrites ) -scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % Dependencies.collectionCompatVersion +scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % collectionCompatVersion ``` Then run: @@ -77,6 +76,8 @@ Then run: > ;scalafix Collection213CrossCompat ;test:scalafix Collection213CrossCompat # For Libraries ``` +The official documentation: https://scalacenter.github.io/scalafix/docs/users/installation.html + The migration tool is not exhaustive and we will continue to improve it over time. If you encounter a use case that’s not supported, please report it as described in the diff --git a/build.sbt b/build.sbt index 141fb877..261adae6 100644 --- a/build.sbt +++ b/build.sbt @@ -162,10 +162,6 @@ lazy val `scalafix-data` = MultiScalaProject( "scalafix/data", _.settings(sharedScalafixSettings) .settings(dontPublish) - .settings( - addCompilerPlugin(scalafixSemanticdb), - scalacOptions += "-P:semanticdb:synthetics:on" - ) ) val `scalafix-data211` = `scalafix-data`(scala211, _.dependsOn(compat211JVM)) From ba403f062aeba8cd12f434f81039ca728855af17 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Mon, 24 Sep 2018 11:51:47 +0200 Subject: [PATCH 3/8] Tune reference to scalafix documentation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 491b7c1b..2b8cd2f3 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ We created two migration rules: * `Collection213Upgrade` For upgrading applications (like web server, etc) from 2.11/2.12 to 2.13 * `Collection213CrossCompat` For library that wants to cross compile to 2.11, 2.12 and 2.13 +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 binary version is supported. + ```scala // project/plugins.sbt @@ -76,8 +78,6 @@ Then run: > ;scalafix Collection213CrossCompat ;test:scalafix Collection213CrossCompat # For Libraries ``` -The official documentation: https://scalacenter.github.io/scalafix/docs/users/installation.html - The migration tool is not exhaustive and we will continue to improve it over time. If you encounter a use case that’s not supported, please report it as described in the From 84d9654a46a165bd3b10323290bb3bd99d5e36c1 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Mon, 24 Sep 2018 13:02:58 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=E2=80=9Cexact=20Scala=20version=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b8cd2f3..c62fc86f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ We created two migration rules: * `Collection213Upgrade` For upgrading applications (like web server, etc) from 2.11/2.12 to 2.13 * `Collection213CrossCompat` For library that wants to cross compile to 2.11, 2.12 and 2.13 -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 binary version is supported. +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. ```scala // project/plugins.sbt From e9037931bc8a07db7fc8d497c598da5b7f997d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Mass=C3=A9?= Date: Mon, 24 Sep 2018 14:25:37 +0200 Subject: [PATCH 5/8] Split rule instructions --- README.md | 56 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c62fc86f..78c8aedd 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,7 @@ The library also adds backported versions of new collection types, currently `sc ## Migration Tool -We created two migration rules: - -* `Collection213Upgrade` For upgrading applications (like web server, etc) from 2.11/2.12 to 2.13 -* `Collection213CrossCompat` For library that wants to cross compile to 2.11, 2.12 and 2.13 - -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. +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). ```scala // project/plugins.sbt @@ -51,33 +46,48 @@ The migration rules use scalafix. Please see the [official installation instruct addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0-RC1") ``` +### Collection213Upgrade + +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. + ```scala -// build.sbt or project/Build.scala +// build.sbt +scalafixDependencies += "org.scala-lang.modules" ... +scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on") +``` -// If you are using project/Build.scala add the following imports: -import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb} +```bash +// sbt shell +> ;scalafix Collections213Upgrade;test:scalafix Collections213Upgrade +``` -val collectionCompatVersion = "0.2.1" -val collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion +### Collections213CrossCompat -libraryDependencies += collectionCompat // required for Collection213CrossCompat -addCompilerPlugin(scalafixSemanticdb) -scalacOptions ++= List( - "-Yrangepos", - "-P:semanticdb:synthetics:on" // Required by the collection rewrites -) -scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % collectionCompatVersion -``` +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. + +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. + +// build.sbt +scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "0.2.1" +libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1" +scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on") -Then run: ```bash -> ;scalafix Collection213Upgrade ;test:scalafix Collection213Upgrade # For Applications -# or -> ;scalafix Collection213CrossCompat ;test:scalafix Collection213CrossCompat # For Libraries +// sbt shell +> ;scalafix Collections213CrossCompat;test:scalafix Collections213CrossCompat ``` +### Build.scala + +```scala +// If you are using project/Build.scala add the following imports: +import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb} +``` + +### Contributing + The migration tool is not exhaustive and we will continue to improve it over time. If you encounter a use case that’s not supported, please report it as described in the From a76782a301c9c21aef674f57a91e0e509e5e09a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Mass=C3=A9?= Date: Mon, 24 Sep 2018 15:01:05 +0200 Subject: [PATCH 6/8] PR followup --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 78c8aedd..1e1ee405 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To use this library, add the following to your build.sbt: libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1" ``` -Version 0.2.1 is compatible with Scala 2.13.0-M5. For Scala 2.13.0-M4 you should use version 0.1.1. +Version 0.2.1 is compatible with Scala Note that there are multiple ways to cross-build projects, see https://github.com/scala/collection-strawman/wiki/FAQ#how-do-i-cross-build-my-project-against-scala-212-and-scala-213. @@ -48,25 +48,25 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0-RC1") ### Collection213Upgrade -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. +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 that don't need to cross-compile against multiple Scala versions. ```scala // build.sbt -scalafixDependencies += "org.scala-lang.modules" ... +scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "0.2.1" scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on") ``` ```bash // sbt shell -> ;scalafix Collections213Upgrade;test:scalafix Collections213Upgrade +> ;test:scalafix Collections213Upgrade ;scalafix Collections213Upgrade ``` ### Collections213CrossCompat -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. +The `Collections213CrossCompat` rewrite upgrades to the 2.13 collections with 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. -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. +To cross-build for 2.12 and 2.11, the rewrite rule introduces a dependency on the scala-collection-compat module, which provides the syntax of 2.13 on 2.12 and 2.11. This enables you to write your library using the latest 2.13 collections API while still supporting users on an older Scala version. // build.sbt scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "0.2.1" @@ -76,7 +76,7 @@ scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on") ```bash // sbt shell -> ;scalafix Collections213CrossCompat;test:scalafix Collections213CrossCompat +> ;test:scalafix Collections213CrossCompat ;scalafix Collections213CrossCompat ``` ### Build.scala From 6e96e22facf52e0d111a5fb84465cfdb5ea0e460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 19 Oct 2018 13:13:01 +0200 Subject: [PATCH 7/8] s/or later/or 2.11/ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e1ee405..1d40a5ef 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0-RC1") ### Collection213Upgrade -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 that don't need to cross-compile against multiple Scala versions. +The `Collection213Upgrade` rewrite upgrades to the 2.13 collections without the ability to compile the code-base with 2.12 or 2.11. This rewrite is suitable for applications that don't need to cross-compile against multiple Scala versions. ```scala // build.sbt From ca7b990f575412c18e2961da66fea48827601142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 19 Oct 2018 13:34:38 +0200 Subject: [PATCH 8/8] Address feedback --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d40a5ef..3cb14418 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To use this library, add the following to your build.sbt: libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1" ``` -Version 0.2.1 is compatible with Scala +Version 0.2.1 is compatible with Scala 2.13.0-M5. For Scala 2.13.0-M4 you should use version 0.1.1. Note that there are multiple ways to cross-build projects, see https://github.com/scala/collection-strawman/wiki/FAQ#how-do-i-cross-build-my-project-against-scala-212-and-scala-213. @@ -43,7 +43,7 @@ The migration rules use scalafix. Please see the [official installation instruct ```scala // project/plugins.sbt -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0-RC1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0") ``` ### Collection213Upgrade @@ -68,10 +68,12 @@ The `Collections213CrossCompat` rewrite upgrades to the 2.13 collections with th To cross-build for 2.12 and 2.11, the rewrite rule introduces a dependency on the scala-collection-compat module, which provides the syntax of 2.13 on 2.12 and 2.11. This enables you to write your library using the latest 2.13 collections API while still supporting users on an older Scala version. +```scala // build.sbt scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "0.2.1" libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1" scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on") +``` ```bash