diff --git a/.travis.yml b/.travis.yml index 2b564fb1..e0f69674 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e21ef57f..8852f93d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index 9d72f527..0c2614f8 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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" % "" ``` All future versions will remain backwards binary compatible with 2.0.0. (The 1.0.0 release was withdrawn and should not be used.) @@ -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 diff --git a/admin/checkCLA.sh b/admin/checkCLA.sh deleted file mode 100755 index 5e65685c..00000000 --- a/admin/checkCLA.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -# Script copied from https://github.com/scalameta/scalameta -set -e - -if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then - echo "Incoming pull request from https://github.com/$TRAVIS_REPO_SLUG/pull/$TRAVIS_PULL_REQUEST"; - author=$(curl -s "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST" | jq -r ".user.login"); - if [ $? -ne 0 ] ; then exit 1; fi; - echo "Pull request submitted by $author"; - signed=$(curl -s https://www.lightbend.com/contribute/cla/scala/check/$author | jq -r ".signed"); - if [ $? -ne 0 ] ; then exit 1; fi; - if [ "$signed" = "true" ] ; then - echo "CLA check for $author successful"; - else - echo "CLA check for $author failed"; - echo "Please sign the Scala CLA to contribute to $TRAVIS_REPO_SLUG"; - echo "Go to https://www.lightbend.com/contribute/cla/scala and then resubmit this pull request"; - exit 1; - fi; -fi; diff --git a/build.sbt b/build.sbt index f2cec653..824f9ce1 100644 --- a/build.sbt +++ b/build.sbt @@ -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. @@ -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) @@ -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" @@ -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( @@ -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, @@ -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) ) @@ -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) @@ -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) @@ -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 }, @@ -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", @@ -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 { @@ -341,7 +344,7 @@ inThisBuild( val projectPrefix = if (isScalafix) { - "scalafix-rules" + "scalafixRules" } else if (isBinaryCompat) { binaryCompatProject } else { @@ -372,6 +375,7 @@ inThisBuild( List(s"$projectPrefix/clean"), List(s"$testProjectPrefix/test"), List(s"$projectPrefix/publishLocal"), + List("headerCheck"), publishTask ).flatten } @@ -385,4 +389,4 @@ inThisBuild( state.copy(remainingCommands = newCommands ::: state.remainingCommands) } ) -) +} diff --git a/compat/src/main/scala-2.11_2.12/scala/jdk/CollectionConverters.scala b/compat/src/main/scala-2.11_2.12/scala/jdk/CollectionConverters.scala index 0a254eac..3cefffdc 100644 --- a/compat/src/main/scala-2.11_2.12/scala/jdk/CollectionConverters.scala +++ b/compat/src/main/scala-2.11_2.12/scala/jdk/CollectionConverters.scala @@ -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} diff --git a/compat/src/main/scala-2.11_2.12/scala/util/control/compat/ControlThrowable.scala b/compat/src/main/scala-2.11_2.12/scala/util/control/compat/ControlThrowable.scala index 08b4bb8f..ff42324b 100644 --- a/compat/src/main/scala-2.11_2.12/scala/util/control/compat/ControlThrowable.scala +++ b/compat/src/main/scala-2.11_2.12/scala/util/control/compat/ControlThrowable.scala @@ -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. diff --git a/compat/src/main/scala-2.13/scala/util/control/compat/package.scala b/compat/src/main/scala-2.13/scala/util/control/compat/package.scala index bad246d6..41866d1a 100644 --- a/compat/src/main/scala-2.13/scala/util/control/compat/package.scala +++ b/compat/src/main/scala-2.13/scala/util/control/compat/package.scala @@ -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 { diff --git a/compat/src/test/scala-jvm/test/scala/collection/LazyListGCTest.scala b/compat/src/test/scala-jvm/test/scala/collection/LazyListGCTest.scala index eb741958..6b936739 100644 --- a/compat/src/test/scala-jvm/test/scala/collection/LazyListGCTest.scala +++ b/compat/src/test/scala-jvm/test/scala/collection/LazyListGCTest.scala @@ -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 test.scala.collection import org.junit.Assert._ diff --git a/compat/src/test/scala/scala/jdk/CollectionConvertersTest.scala b/compat/src/test/scala/scala/jdk/CollectionConvertersTest.scala index 8eb12800..329bafd9 100644 --- a/compat/src/test/scala/scala/jdk/CollectionConvertersTest.scala +++ b/compat/src/test/scala/scala/jdk/CollectionConvertersTest.scala @@ -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 java.{lang => jl, util => ju} diff --git a/compat/src/test/scala/scala/util/ChainingOpsTest.scala b/compat/src/test/scala/scala/util/ChainingOpsTest.scala index 5ec37c98..94e95304 100644 --- a/compat/src/test/scala/scala/util/ChainingOpsTest.scala +++ b/compat/src/test/scala/scala/util/ChainingOpsTest.scala @@ -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 import org.junit.Assert._ diff --git a/compat/src/test/scala/scala/util/UsingTest.scala b/compat/src/test/scala/scala/util/UsingTest.scala index a2f1173e..e401ed28 100644 --- a/compat/src/test/scala/scala/util/UsingTest.scala +++ b/compat/src/test/scala/scala/util/UsingTest.scala @@ -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 import org.junit.Test diff --git a/compat/src/test/scala/scala/util/control/compat/ControlThrowableTest.scala b/compat/src/test/scala/scala/util/control/compat/ControlThrowableTest.scala index 43caa63a..f7e7cb49 100644 --- a/compat/src/test/scala/scala/util/control/compat/ControlThrowableTest.scala +++ b/compat/src/test/scala/scala/util/control/compat/ControlThrowableTest.scala @@ -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.compat import org.junit.Test diff --git a/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala b/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala index 494d476b..883c5418 100644 --- a/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala +++ b/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala @@ -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 test.scala.collection import org.junit.Test diff --git a/compat/src/test/scala/test/scala/collection/LazyListTest.scala b/compat/src/test/scala/test/scala/collection/LazyListTest.scala index 3126b55b..fbcac1c9 100644 --- a/compat/src/test/scala/test/scala/collection/LazyListTest.scala +++ b/compat/src/test/scala/test/scala/collection/LazyListTest.scala @@ -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 test.scala.collection import org.junit.Test diff --git a/compat/src/test/scala/test/scala/collection/LazyZipTest.scala b/compat/src/test/scala/test/scala/collection/LazyZipTest.scala index a583da52..3754d98a 100644 --- a/compat/src/test/scala/test/scala/collection/LazyZipTest.scala +++ b/compat/src/test/scala/test/scala/collection/LazyZipTest.scala @@ -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 test.scala.collection import org.junit.Assert.assertEquals diff --git a/compat/src/test/scala/test/scala/collection/MapTest.scala b/compat/src/test/scala/test/scala/collection/MapTest.scala index 63a6a233..dbc5eab1 100644 --- a/compat/src/test/scala/test/scala/collection/MapTest.scala +++ b/compat/src/test/scala/test/scala/collection/MapTest.scala @@ -9,6 +9,7 @@ * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ + package test.scala.collection import org.junit.Test diff --git a/project/plugins.sbt b/project/plugins.sbt index 35ade440..ce41a12e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,7 @@ -val crossVer = "1.1.0" -val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.7.0") -val scalaNativeVersion = - Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.4.0") - -addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % crossVer) -addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) -addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % crossVer) -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.4.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")