Skip to content

Commit

Permalink
Merge pull request #435 from bjaglin/interface-version
Browse files Browse the repository at this point in the history
fix Scala 2.11 detection & use same instance across patch releases
  • Loading branch information
bjaglin authored Sep 29, 2024
2 parents 666b50d + 2cf21ce commit cde3045
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object ScalafixInterface {

type Cache = BlockingCache[
(
String, // scalafixScalaBinaryVersion
String, // scalafixScalaMajorMinorVersion
Option[Arg.ToolClasspath]
),
(
Expand All @@ -139,7 +139,7 @@ object ScalafixInterface {

def apply(
cache: Cache,
scalafixScalaBinaryVersion: String,
scalafixScalaMajorMinorVersion: String,
toolClasspath: Arg.ToolClasspath,
logger: Logger,
callback: ScalafixMainCallback
Expand All @@ -150,7 +150,7 @@ object ScalafixInterface {
// shared as much as possible.
val (buildinRulesInterface, _) = cache.compute(
(
scalafixScalaBinaryVersion,
scalafixScalaMajorMinorVersion,
None
),
{
Expand All @@ -159,14 +159,14 @@ object ScalafixInterface {
None
case None =>
// cache miss, resolve scalafix artifacts and classload them
if (scalafixScalaBinaryVersion == "2.11")
if (scalafixScalaMajorMinorVersion == "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 scalafixArguments = ScalafixAPI
.fetchAndClassloadInstance(
scalafixScalaBinaryVersion,
scalafixScalaMajorMinorVersion,
toolClasspath.repositories.asJava
)
.newArguments()
Expand Down Expand Up @@ -197,7 +197,7 @@ object ScalafixInterface {

val (toolClasspathInterface, _) = cache.compute(
(
scalafixScalaBinaryVersion,
scalafixScalaMajorMinorVersion,
Some(toolClasspath)
),
{
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ object ScalafixPlugin extends AutoPlugin {
},
ivyConfigurations += ScalafixConfig,
scalafixAll := scalafixAllInputTask.evaluated,
(scalafixScalaBinaryVersion: @nowarn) := scalaVersion.value
(scalafixScalaBinaryVersion: @nowarn) :=
scalaVersion.value.split('.').take(2).mkString(".")
)

override lazy val globalSettings: Seq[Def.Setting[_]] = Seq(
Expand Down Expand Up @@ -326,7 +327,7 @@ object ScalafixPlugin extends AutoPlugin {
shell: ShellArgs,
projectDepsExternal: Seq[ModuleID],
projectDepsInternal: Seq[File],
projectScalafixScalaBinaryVersion: String,
projectScalaMajorMinorVersion: String,
projectScalafixDependencies: Seq[ModuleID],
buildAllResolvers: Seq[Repository],
buildScalafixMainCallback: ScalafixMainCallback,
Expand Down Expand Up @@ -363,7 +364,7 @@ object ScalafixPlugin extends AutoPlugin {

val interface = ScalafixInterface(
cache = buildScalafixInterfaceCache,
scalafixScalaBinaryVersion = projectScalafixScalaBinaryVersion,
scalafixScalaMajorMinorVersion = projectScalaMajorMinorVersion,
toolClasspath = toolClasspath,
logger = ScalafixInterface.defaultLogger,
callback = buildScalafixMainCallback
Expand Down

0 comments on commit cde3045

Please sign in to comment.