Skip to content

Commit

Permalink
Merge pull request #334 from bjaglin/scala211
Browse files Browse the repository at this point in the history
drop support for Scala 2.11
  • Loading branch information
bjaglin authored Jan 30, 2023
2 parents 09ed18e + 491958d commit 9b81b76
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 95 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._

object Dependencies {
val x = List(1) // scalafix:ok
def scalafixVersion: String = "0.10.4"
def scalafixVersion: String = "0.10.4+78-f6b8c84d-SNAPSHOT"

val all = List(
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.1.202206130422-r",
Expand Down
5 changes: 5 additions & 0 deletions src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ object ScalafixInterface {
"Rules such as ExplicitResultTypes requiring the project version to match the Scalafix " +
"version are unsupported for the moment."
)
else if (scalafixBinaryScalaVersion == "2.11")
logger.error(
"Scala 2.11 is no longer supported. Please downgrade to the final version supporting " +
"it: sbt-scalafix 0.10.4."
)
val callback = new ScalafixLogger(logger)
val scalafixArguments = ScalafixAPI
.fetchAndClassloadInstance(
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/scalafix/sbt/BuildInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ object BuildInfo {
property("scala213")
def scala212: String =
property("scala212")
def scala211: String =
property("scala211")
@deprecated("Scala 2.11 is no longer supported", ">0.10.4")
def scala211: String = ???
def supportedScalaVersions: List[String] =
List(scala213, scala212, scala211)
List(scala213, scala212)

private val propertiesPath = "scalafix-interfaces.properties"

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scalafix/sbt/ScalafixTestkitPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object ScalafixTestkitPlugin extends AutoPlugin {
// This makes it simpler to use sbt-scalafix SNAPSHOTS: such snapshots may bring scalafix-* SNAPSHOTS which is fine in the
// meta build as the same resolver (declared in project/plugins.sbt) is used. However, since testkit-enabled projects are
// built against a version of scalafix-testkit dictated by scalafix.sbt.BuildInfo.scalafixVersion, the same resolver is
// needed here as well.
// needed here as well. Unfortunately it works only for sbt 1.7+, see https://github.com/sbt/sbt/pull/6849.
includePluginResolvers := true
)

Expand Down
8 changes: 7 additions & 1 deletion src/sbt-test/sbt-1.5/scalafixEnable/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ lazy val scala210 = project
lazy val scala211 = project
.in(file("scala211"))
.settings(
scalaVersion := "2.11.12" // supported by semanticdb-scalac
scalaVersion := "2.11.12" // supported by semanticdb-scalac, but not by sbt-scalafix
)

lazy val scala212 = project
.in(file("scala212"))
.settings(
scalaVersion := "2.12.17" // supported by semanticdb-scalac
)

lazy val scala3 = project
Expand Down
11 changes: 6 additions & 5 deletions src/sbt-test/sbt-1.5/scalafixEnable/test
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# enable semanticdb output where supported
> scalafixEnable

# check that projects not supported by semanticdb-scalac can still compile
# check that projects not supported by sbt-scalafix can still compile
> scala210/compile
> scala211/compile

# check that we can run a semantic rule against a Scala 2.11 dialect source file
-> scala211/scalafix --check SemanticRule
> scala211/scalafix SemanticRule
> scala211/scalafix --check SemanticRule
# check that we can run a semantic rule against a Scala 2.12 dialect source file
-> scala212/scalafix --check SemanticRule
> scala212/scalafix SemanticRule
> scala212/scalafix --check SemanticRule

# check that we can run a semantic rule against a Scala 3 dialect source file
-> scala3/scalafix --check SemanticRule
Expand Down
13 changes: 5 additions & 8 deletions src/sbt-test/sbt-1.5/testkit/build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
lazy val V = _root_.scalafix.sbt.BuildInfo

lazy val rulesCrossVersions = Seq(V.scala213, V.scala212, V.scala211)
lazy val rulesCrossVersions = Seq(V.scala213, V.scala212)
lazy val scala3Version = "3.0.0"

inThisBuild(
List(
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
semanticdbVersion := scalafixSemanticdb.revision,
// need for sbt <1.7.0 as includePluginResolvers has no effect, see https://github.com/sbt/sbt/pull/6853
resolvers += Resolver.sonatypeRepo("public")
)
)

Expand All @@ -26,7 +28,7 @@ lazy val input = projectMatrix
scalacOptions += "-Xsource:3"
)
)
.jvmPlatform(scalaVersions = Seq(V.scala212, V.scala211))
.jvmPlatform(scalaVersions = Seq(V.scala212))

lazy val output = projectMatrix
.defaultAxes(VirtualAxis.jvm)
Expand Down Expand Up @@ -71,10 +73,5 @@ lazy val tests = projectMatrix
axisValues = Seq(TargetAxis(V.scala212), VirtualAxis.jvm),
settings = Seq()
)
.customRow(
scalaVersions = Seq(V.scala211),
axisValues = Seq(TargetAxis(V.scala211), VirtualAxis.jvm),
settings = Seq()
)
.dependsOn(rules)
.enablePlugins(ScalafixTestkitPlugin)
9 changes: 0 additions & 9 deletions src/sbt-test/sbt-scalafix/cross-build/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,10 @@ lazy val root = project
.in(file("."))
.aggregate(
javaProject,
scala211,
scala210,
scala212,
scala213
)

lazy val scala210 = project.settings(
scalaVersion := "2.10.7"
)
lazy val scala211 = project.settings(
scalaVersion := Versions.scala211,
scalafixSettings
)
lazy val scala212 = project
.configs(IntegrationTest)
.settings(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 1 addition & 4 deletions src/sbt-test/sbt-scalafix/cross-build/test
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
> it:scalafix --test ProcedureSyntax

> javaProject/compile:scalafix ProcedureSyntax
# Should fail because 2.10 has no semanticdb
# Other >2.10 projects should succeed
-> compile:scalafix
-> test:scalafix

# it config exists only for 2.12
> it:scalafix

Expand Down
78 changes: 40 additions & 38 deletions src/sbt-test/sbt-scalafix/scalafixEnable/build.sbt
Original file line number Diff line number Diff line change
@@ -1,75 +1,77 @@
val V = _root_.scalafix.sbt.BuildInfo

// 2.10 is not supported
lazy val scala210 = project.settings(
scalaVersion := "2.10.4",
libraryDependencies := Nil,
scalacOptions := Nil
lazy val config = project

lazy val unsupported = project.settings(
// 2.11.x is not supported
scalaVersion := "2.11.12"
)

// 2.11.x is supported
lazy val scala211_old = project.settings(
// semanticdb-scalac_2.11.0 was never available
scalaVersion := "2.11.0"
lazy val bumpScala = project.settings(
// semanticdb-scalac_2.12.0 was never available
scalaVersion := "2.12.0"
)

// 2.11.x is supported
lazy val scala211 = project.settings(
// semanticdb-scalac_2.11.11 no longer available after 4.1.9
scalaVersion := "2.11.11"
lazy val downgradeScalameta = project.settings(
// semanticdb-scalac_2.12.4 no longer available after 4.1.9
scalaVersion := "2.12.4"
)

// 2.12.x is supported
lazy val scala212 = project.settings(
lazy val upgradeScalameta = project.settings(
// semanticdb-scalac_2.12.15 not yet available in 4.4.10, became available as of 4.4.28
scalaVersion := "2.12.15"
)

// 2.13.x is supported
lazy val scala213 = project.settings(
// semanticdb-scalac_2.13.4 available in 4.4.10, became available as of 4.4.0
lazy val available = project.settings(
// semanticdb-scalac_2.13.4 available in 4.4.10
scalaVersion := "2.13.4",
crossScalaVersions := Seq("2.12.15")
)

TaskKey[Unit]("check") := {
assert((scala210 / semanticdbEnabled).value == false)
assert((scala210 / scalaVersion).value == "2.10.4")
assert((scala210 / Compile / compile / scalacOptions).value.isEmpty)
assert((unsupported / semanticdbEnabled).value == false)
assert((unsupported / scalaVersion).value == "2.11.12")
assert((unsupported / Compile / compile / scalacOptions).value.isEmpty)

assert((scala211_old / semanticdbEnabled).value == true)
assert((scala211_old / scalaVersion).value == "2.11.12")
assert((scala211_old / semanticdbCompilerPlugin).value.revision == "4.4.10")
assert((bumpScala / semanticdbEnabled).value == true)
assert((bumpScala / scalaVersion).value == V.scala212)
assert(
(bumpScala / semanticdbCompilerPlugin).value.revision == V.scalametaVersion
)
assert(
(scala211_old / Compile / compile / scalacOptions).value
(bumpScala / Compile / compile / scalacOptions).value
.count(_ == "-Yrangepos") == 1
)

assert((scala211 / semanticdbEnabled).value == true)
assert((scala211 / scalaVersion).value == "2.11.11")
assert((scala211 / semanticdbCompilerPlugin).value.revision == "4.1.9")
assert((downgradeScalameta / semanticdbEnabled).value == true)
assert((downgradeScalameta / scalaVersion).value == "2.12.4")
assert(
(scala211 / Compile / compile / scalacOptions).value
(downgradeScalameta / semanticdbCompilerPlugin).value.revision == "4.1.9"
)
assert(
(downgradeScalameta / Compile / compile / scalacOptions).value
.count(_ == "-Yrangepos") == 1
)

assert((scala212 / semanticdbEnabled).value == true)
assert((scala212 / scalaVersion).value == "2.12.15")
assert((scala212 / semanticdbCompilerPlugin).value.revision == "4.4.28")
assert((upgradeScalameta / semanticdbEnabled).value == true)
assert((upgradeScalameta / scalaVersion).value == "2.12.15")
assert(
(upgradeScalameta / semanticdbCompilerPlugin).value.revision == "4.4.28"
)
assert(
(scala212 / Compile / compile / scalacOptions).value
(upgradeScalameta / Compile / compile / scalacOptions).value
.count(_ == "-Yrangepos") == 1
)

assert((scala213 / semanticdbEnabled).value == true)
assert((scala213 / scalaVersion).value == "2.13.4")
assert((scala213 / semanticdbCompilerPlugin).value.revision == "4.4.10")
assert((available / semanticdbEnabled).value == true)
assert((available / scalaVersion).value == "2.13.4")
assert((available / semanticdbCompilerPlugin).value.revision == "4.4.10")
assert(
(scala213 / Test / compile / scalacOptions).value
(available / Test / compile / scalacOptions).value
.count(_ == "-Yrangepos") == 1
)
}

TaskKey[Unit]("checkVersion") := {
assert((scala213 / scalaVersion).value == "2.12.15")
assert((available / scalaVersion).value == "2.12.15")
}
6 changes: 3 additions & 3 deletions src/sbt-test/sbt-scalafix/scalafixEnable/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
> scalafixEnable
> check

-> scala212/test:compile
> scala212/scalafixAll RemoveUnused
> scala212/test:compile
-> config/test:compile
> config/scalafixAll RemoveUnused
> config/test:compile

-> checkVersion
> ++2.12.15 -v
Expand Down
7 changes: 6 additions & 1 deletion src/test/scala/scalafix/internal/sbt/ScalafixAPISuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ class ScalafixAPISuite extends AnyFunSuite {
def assertNoDiff(obtained: String, expected: String)(implicit
pos: Position
): Unit = {
def removeSnapshotInfo(s: String) =
s.replaceAllLiterally(
"[info] Using SNAPSHOT artifacts for Scalafix and/or external rules, binary compatibility checks disabled",
""
)
def strip(s: String) = s.trim.replaceAll("\r\n", "\n")
val obtainedStrip = strip(obtained)
val obtainedStrip = strip(removeSnapshotInfo(obtained))
val expectedStrip = strip(expected)
assert(obtainedStrip == expectedStrip)
}
Expand Down

0 comments on commit 9b81b76

Please sign in to comment.