Skip to content

upgrade to sbt-scala-module 3.0.0 #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ scala:
- 2.11.12
- 2.12.15
- 2.13.6
- 3.0.1
- 3.0.2

env:
- SCALAJS_VERSION= ADOPTOPENJDK=8
Expand Down Expand Up @@ -37,13 +37,10 @@ matrix:

# Scala Native doesn't support Scala 3 yet

- scala: 3.0.1
- scala: 3.0.2
env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8

install:
- git fetch --tags # get all tags for sbt-dynver

before_script:
- admin/checkCLA.sh

script: sbt ci
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sbt task to run the migration tool on the input files and check whether the resu
expected output files:

~~~
> scalafix-tests/test
> scalafixTests/test
~~~

Fix the implementation of the rule (in the `rules/src/main/scala/fix/NewCollections.scala` file) until the
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![Build Status](https://travis-ci.org/scala/scala-collection-compat.svg?branch=master)](https://travis-ci.org/scala/scala-collection-compat)

## Purpose and scope

This library makes some Scala 2.13 APIs available on Scala 2.11 and 2.12.
Expand All @@ -17,7 +15,7 @@ Only the most commonly used APIs are supported; many are missing. Contributions
To use this library, add the following to your `build.sbt`:

```
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.5.0"
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "<version>"
```

All future versions will remain backwards binary compatible with 2.0.0. (The 1.0.0 release was withdrawn and should not be used.)
Expand Down Expand Up @@ -51,11 +49,11 @@ And, it includes support for some non-collections classes such as the `@nowarn`

## Migration rules

The migration rules use scalafix. Please see the [official installation instructions](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.13).
The migration rules use scalafix. Please see the [official installation instructions](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.15).

```scala
// project/plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.29")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")
```

### Collection213Upgrade
Expand Down
20 changes: 0 additions & 20 deletions admin/checkCLA.sh

This file was deleted.

108 changes: 56 additions & 52 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import _root_.scalafix.sbt.BuildInfo.{scalafixVersion, scala212 => scalafixScala212}
import com.lightbend.tools.scalamoduleplugin.ScalaModulePlugin._

import scala.sys.process._

lazy val commonSettings = Seq(
scalaModuleAutomaticModuleName := Some("scala.collection.compat"),
headerLicense := Some(HeaderLicense.Custom(s"""|Scala (https://www.scala-lang.org)
|
|Copyright EPFL and Lightbend, Inc.
Expand Down Expand Up @@ -36,16 +32,16 @@ lazy val root = project
compat213Native,
compat30JVM,
compat30JS,
`scalafix-data211`,
`scalafix-data212`,
`scalafix-data213`,
`scalafix-input`,
`scalafix-output211`,
`scalafix-output212`,
`scalafix-output213`,
// `scalafix-output213-failure`,
`scalafix-rules`,
`scalafix-tests`
scalafixData211,
scalafixData212,
scalafixData213,
scalafixInput,
scalafixOutput211,
scalafixOutput212,
scalafixOutput213,
// scalafixOutput213Failure,
scalafixRules,
scalafixTests
)
.disablePlugins(ScalafixPlugin)

Expand All @@ -60,11 +56,12 @@ lazy val scala30 = "3.0.2"

lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform)(
"compat",
_.settings(scalaModuleSettings)
_.settings(ScalaModulePlugin.scalaModuleSettings)
.settings(commonSettings)
.settings(
name := "scala-collection-compat",
moduleName := "scala-collection-compat",
scalaModuleAutomaticModuleName := Some("scala.collection.compat"),
scalacOptions ++= Seq("-feature", "-language:higherKinds", "-language:implicitConversions"),
Compile / unmanagedSourceDirectories += {
val sharedSourceDir = (ThisBuild / baseDirectory).value / "compat/src/main"
Expand Down Expand Up @@ -132,20 +129,20 @@ lazy val compat213Native = compat213.native
lazy val compat30JVM = compat30.jvm
lazy val compat30JS = compat30.js

lazy val `binary-compat-old` = project
lazy val binaryCompatOld = project
.in(file("binary-compat/old"))
.settings(commonSettings)
.settings(scalaVersion := scala212)
.disablePlugins(ScalafixPlugin)

lazy val `binary-compat-new` = project
lazy val binaryCompatNew = project
.in(file("binary-compat/new"))
.settings(commonSettings)
.settings(scalaVersion := scala212)
.dependsOn(compat212JVM)
.disablePlugins(ScalafixPlugin)

lazy val `binary-compat` = project
lazy val binaryCompat = project
.in(file("binary-compat/test"))
.settings(commonSettings)
.settings(
Expand All @@ -155,24 +152,25 @@ lazy val `binary-compat` = project
versionPolicyIntention := Compatibility.None,
buildInfoPackage := "build",
buildInfoKeys := Seq[BuildInfoKey](
"oldClasses" -> (`binary-compat-old` / Compile / classDirectory).value.toString,
"newClasses" -> (`binary-compat-new` / Compile / classDirectory).value.toString
"oldClasses" -> (binaryCompatOld / Compile / classDirectory).value.toString,
"newClasses" -> (binaryCompatNew / Compile / classDirectory).value.toString
),
Test / test := (Test / test)
.dependsOn(
`binary-compat-old` / Compile / compile,
`binary-compat-new` / Compile / compile,
binaryCompatOld / Compile / compile,
binaryCompatNew / Compile / compile,
)
.value
)
.enablePlugins(BuildInfoPlugin)
.disablePlugins(ScalafixPlugin)

lazy val `scalafix-rules` = project
lazy val scalafixRules = project
.in(file("scalafix/rules"))
.settings(scalaModuleSettings)
.settings(ScalaModulePlugin.scalaModuleSettings)
.settings(commonSettings)
.settings(
scalaModuleAutomaticModuleName := None,
organization := (compat212JVM / organization).value,
publishTo := (compat212JVM / publishTo).value,
versionPolicyIntention := Compatibility.None,
Expand All @@ -193,39 +191,43 @@ lazy val sharedScalafixSettings = Seq(
)

// common part between input/output
lazy val `scalafix-data` = MultiScalaProject(
"scalafix-data",
lazy val scalafixData = MultiScalaProject(
"scalafixData",
"scalafix/data",
_.settings(sharedScalafixSettings)
.settings(commonSettings)
.settings(publish / skip := true)
)

val `scalafix-data211` = `scalafix-data`(scala211, _.dependsOn(compat211JVM))
val `scalafix-data212` = `scalafix-data`(scalafixScala212, _.dependsOn(compat212JVM))
val `scalafix-data213` = `scalafix-data`(scala213, _.dependsOn(compat213JVM))
val scalafixData211 = scalafixData(scala211, _.dependsOn(compat211JVM))
val scalafixData212 = scalafixData(scalafixScala212, _.dependsOn(compat212JVM))
val scalafixData213 = scalafixData(scala213, _.dependsOn(compat213JVM))

lazy val `scalafix-input` = project
lazy val scalafixInput = project
.in(file("scalafix/input"))
.settings(commonSettings)
.settings(sharedScalafixSettings)
.settings(
scalaVersion := scalafixScala212,
publish / skip := true,
excludeFilter := HiddenFileFilter || "*.scala", // exclude from headerCheck
addCompilerPlugin(scalafixSemanticdb),
scalacOptions ++= Seq(
"-Yrangepos",
"-P:semanticdb:synthetics:on"
)
)
.dependsOn(`scalafix-data212`)
.dependsOn(scalafixData212)

val `scalafix-output` = MultiScalaProject(
"scalafix-output",
val scalafixOutput = MultiScalaProject(
"scalafixOutput",
"scalafix/output",
_.settings(sharedScalafixSettings)
.settings(commonSettings)
.settings(publish / skip := true)
.settings(
publish / skip := true,
excludeFilter := HiddenFileFilter || "*.scala", // exclude from headerCheck
)
.disablePlugins(ScalafixPlugin)
)

Expand All @@ -244,32 +246,32 @@ lazy val output213 =
Def.setting((ThisBuild / baseDirectory).value / "scalafix/output213/src/main/scala")
lazy val addOutput213 = Compile / unmanagedSourceDirectories += output213.value

lazy val `scalafix-output211` = `scalafix-output`(
lazy val scalafixOutput211 = scalafixOutput(
scala211,
_.dependsOn(`scalafix-data211`)
_.dependsOn(scalafixData211)
)

lazy val `scalafix-output212` = `scalafix-output`(
lazy val scalafixOutput212 = scalafixOutput(
scala212,
_.settings(addOutput212)
.settings(addOutput212Plus)
.dependsOn(`scalafix-data212`)
.dependsOn(scalafixData212)
)

lazy val `scalafix-output213` = `scalafix-output`(
lazy val scalafixOutput213 = scalafixOutput(
scala213,
_.settings(addOutput213)
.settings(addOutput212Plus)
.dependsOn(`scalafix-data213`)
.dependsOn(scalafixData213)
)

lazy val `scalafix-output213-failure` = project
lazy val scalafixOutput213Failure = project
.in(file("scalafix/output213-failure"))
.settings(commonSettings)
.settings(sharedScalafixSettings)
.settings(publish / skip := true)

lazy val `scalafix-tests` = project
lazy val scalafixTests = project
.in(file("scalafix/tests"))
.settings(commonSettings)
.settings(sharedScalafixSettings)
Expand All @@ -283,10 +285,10 @@ lazy val `scalafix-tests` = project
output212Plus.value,
output213.value
),
scalafixTestkitInputSourceDirectories := (`scalafix-input` / Compile / sourceDirectories).value,
scalafixTestkitInputClasspath := (`scalafix-input` / Compile / fullClasspath).value,
scalafixTestkitInputSourceDirectories := (scalafixInput / Compile / sourceDirectories).value,
scalafixTestkitInputClasspath := (scalafixInput / Compile / fullClasspath).value,
)
.dependsOn(`scalafix-input`, `scalafix-rules`)
.dependsOn(scalafixInput, scalafixRules)
.enablePlugins(BuildInfoPlugin, ScalafixTestkitPlugin)

val travisScalaVersion = sys.env.get("TRAVIS_SCALA_VERSION").flatMap(Version.parse)
Expand All @@ -299,9 +301,10 @@ val isBinaryCompat = sys.env.get("TEST_BINARY_COMPAT").nonEmpty
val jdkVersion = sys.env.get("ADOPTOPENJDK").map(_.toInt)

// required by sbt-scala-module
inThisBuild(
inThisBuild {
import scala.sys.process._
Seq(
commands += Command.command("scalafmt-test") { state =>
commands += Command.command("scalafmtTest") { state =>
val exitCode = Seq("admin/scalafmt.sh", "--test") ! state.globalLogging.full
if (exitCode == 0) state else state.fail
},
Expand All @@ -312,7 +315,7 @@ inThisBuild(
commands += Command.command("ci") { state =>
val toRun: Seq[String] =
if (isScalafmt) {
Seq("scalafmt-test")
Seq("scalafmtTest")
} else {
List(
"TRAVIS_SCALA_VERSION",
Expand All @@ -328,11 +331,11 @@ inThisBuild(
val platformSuffix = if (isScalaJs) "JS" else if (isScalaNative) "Native" else ""

val compatProject = "compat" + travisScalaVersion.get.binary + platformSuffix
val binaryCompatProject = "binary-compat"
val binaryCompatProject = "binaryCompat"

val testProjectPrefix =
if (isScalafix) {
"scalafix-tests"
"scalafixTests"
} else if (isBinaryCompat) {
binaryCompatProject
} else {
Expand All @@ -341,7 +344,7 @@ inThisBuild(

val projectPrefix =
if (isScalafix) {
"scalafix-rules"
"scalafixRules"
} else if (isBinaryCompat) {
binaryCompatProject
} else {
Expand Down Expand Up @@ -372,6 +375,7 @@ inThisBuild(
List(s"$projectPrefix/clean"),
List(s"$testProjectPrefix/test"),
List(s"$projectPrefix/publishLocal"),
List("headerCheck"),
publishTask
).flatten
}
Expand All @@ -385,4 +389,4 @@ inThisBuild(
state.copy(remainingCommands = newCommands ::: state.remainingCommands)
}
)
)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

package scala.jdk

import scala.collection.convert.{DecorateAsJava, DecorateAsScala}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

package scala.util.control.compat

/** A parent class for throwable objects intended for flow control.
Expand Down
12 changes: 12 additions & 0 deletions compat/src/main/scala-2.13/scala/util/control/compat/package.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

package scala.util.control

package object compat {
Expand Down
Loading