Skip to content

Commit

Permalink
drop sbt 1.3.x support
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Apr 22, 2024
1 parent e3c0eac commit 5186725
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 35 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ libraryDependencies ++= List(
scalaVersion := "2.12.19"

// keep this as low as possible to avoid running into binary incompatibility such as https://github.com/sbt/sbt/issues/5049
pluginCrossBuild / sbtVersion := "1.3.1"
pluginCrossBuild / sbtVersion := "1.4.0"

scriptedSbt := {
val jdk = System.getProperty("java.specification.version").toDouble

if (jdk >= 21)
"1.9.0" // first release that supports JDK21
else
"1.3.3" // get https://github.com/sbt/sbt/issues/1673 to avoid race conditions
(pluginCrossBuild / sbtVersion).value
}

libraryDependencies += compilerPlugin(scalafixSemanticdb)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/sbt/internal/sbtscalafix/JLineAccess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package sbt.internal.sbtscalafix

/** Helper class to access sbt's JLine instance */
object JLineAccess {
def terminalWidth: Int = sbt.internal.util.JLine.usingTerminal(_.getWidth)
def terminalWidth: Int = sbt.internal.util.Terminal.get.getWidth
}
8 changes: 1 addition & 7 deletions src/main/scala/scalafix/sbt/ScalafixEnable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,7 @@ object ScalafixEnable {
)
}
}
} ++ Seq(
semanticdbEnabled := true,
// support sbt 1.3.[0-3] which does not contain
// https://github.com/sbt/sbt/pull/5202
(semanticdbCompilerPlugin := semanticdbCompilerPlugin.value
.withRevision((semanticdbVersion).value))
)
} :+ (semanticdbEnabled := true)
settings <-
inScope(ThisScope.copy(project = Select(project.ref)))(
scalacOptionsSettings ++ enableSemanticdbPlugin
Expand Down
27 changes: 10 additions & 17 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,11 @@ object ScalafixPlugin extends AutoPlugin {
): Unit = implicitly[JsonWriter[A]].write(obj, builder)
}

// we actually don't need to read anything back, see https://github.com/sbt/sbt/pull/5513
// implicit conversion of collection is only available on JsonFormat
implicit val argFormat = liftFormat(argWriter)

def diffWithPreviousRuns[T](f: (Boolean, Set[File]) => T): T = {
val tracker = Tracked.inputChanged(streams.cacheDirectory / "args") {
val tracker = Tracked.inputChangedW(streams.cacheDirectory / "args") {
(argsChanged: Boolean, _: Seq[Arg.CacheKey]) =>
val targets = paths.map(_.toFile).toSet

Expand Down Expand Up @@ -708,21 +708,14 @@ object ScalafixPlugin extends AutoPlugin {
shellArgs: ShellArgs,
config: ConfigKey
): Def.Initialize[Task[Seq[Path]]] =
Def.taskDyn {
// Dynamic task to avoid redundantly computing `unmanagedSources.value`
if (shellArgs.files.nonEmpty) {
Def.task {
shellArgs.files.map(file(_).toPath)
}
} else {
Def.task {
for {
source <- (config / scalafix / unmanagedSources).value
if source.exists()
if isScalaFile(source)
} yield source.toPath
}
}
Def.taskIf {
if (shellArgs.files.nonEmpty) shellArgs.files.map(file(_).toPath)
else
for {
source <- (config / scalafix / unmanagedSources).value
if source.exists()
if isScalaFile(source)
} yield source.toPath
}

private[sbt] val relaxScalacOptionsConfigSettings: Seq[Def.Setting[_]] =
Expand Down
1 change: 0 additions & 1 deletion src/sbt-test/sbt-1.4/build-lint/project/build.properties

This file was deleted.

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions src/sbt-test/sbt-scalafix/explicit-files/build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import _root_.scalafix.sbt.{BuildInfo => Versions}

// support sbt 1.3.x, see https://github.com/sbt/sbt/issues/5110
Global / semanticdbVersion := scalafixSemanticdb.revision

inThisBuild(
List(
scalaVersion := Versions.scala212,
scalacOptions += "-Ywarn-unused",
semanticdbVersion := scalafixSemanticdb.revision,
semanticdbEnabled := true
)
)
Expand Down
9 changes: 6 additions & 3 deletions src/sbt-test/sbt-scalafix/semanticdb-enabled/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// support sbt 1.3.x, see https://github.com/sbt/sbt/issues/5110
Global / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / semanticdbEnabled := true
inThisBuild(
List(
semanticdbVersion := scalafixSemanticdb.revision,
semanticdbEnabled := true
)
)

lazy val scala212 = project
.settings(
Expand Down

0 comments on commit 5186725

Please sign in to comment.