From 8f27d868baacc22816da0fa81ab13bff8ac38aae Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sun, 29 Sep 2024 23:57:47 +0200 Subject: [PATCH 1/2] fix Scala 2.11 detection & use same instance across patch releases --- src/main/scala/scalafix/sbt/ScalafixPlugin.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scala/scalafix/sbt/ScalafixPlugin.scala b/src/main/scala/scalafix/sbt/ScalafixPlugin.scala index 9a04919e..6d4bf75b 100644 --- a/src/main/scala/scalafix/sbt/ScalafixPlugin.scala +++ b/src/main/scala/scalafix/sbt/ScalafixPlugin.scala @@ -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( @@ -363,7 +364,7 @@ object ScalafixPlugin extends AutoPlugin { val interface = ScalafixInterface( cache = buildScalafixInterfaceCache, - scalafixScalaBinaryVersion = projectScalafixScalaBinaryVersion, + scalafixScalaMajorMinorVersion = projectScalafixScalaBinaryVersion, toolClasspath = toolClasspath, logger = ScalafixInterface.defaultLogger, callback = buildScalafixMainCallback From 2cf21cefddb5c07104ef4a8f485088411b78c8c2 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Mon, 30 Sep 2024 00:08:17 +0200 Subject: [PATCH 2/2] reflect what is actually provided as argument --- .../scalafix/internal/sbt/ScalafixInterface.scala | 12 ++++++------ src/main/scala/scalafix/sbt/ScalafixPlugin.scala | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala b/src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala index cee229ea..57a27c8a 100644 --- a/src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala +++ b/src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala @@ -126,7 +126,7 @@ object ScalafixInterface { type Cache = BlockingCache[ ( - String, // scalafixScalaBinaryVersion + String, // scalafixScalaMajorMinorVersion Option[Arg.ToolClasspath] ), ( @@ -139,7 +139,7 @@ object ScalafixInterface { def apply( cache: Cache, - scalafixScalaBinaryVersion: String, + scalafixScalaMajorMinorVersion: String, toolClasspath: Arg.ToolClasspath, logger: Logger, callback: ScalafixMainCallback @@ -150,7 +150,7 @@ object ScalafixInterface { // shared as much as possible. val (buildinRulesInterface, _) = cache.compute( ( - scalafixScalaBinaryVersion, + scalafixScalaMajorMinorVersion, None ), { @@ -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() @@ -197,7 +197,7 @@ object ScalafixInterface { val (toolClasspathInterface, _) = cache.compute( ( - scalafixScalaBinaryVersion, + scalafixScalaMajorMinorVersion, Some(toolClasspath) ), { diff --git a/src/main/scala/scalafix/sbt/ScalafixPlugin.scala b/src/main/scala/scalafix/sbt/ScalafixPlugin.scala index 6d4bf75b..efd6d978 100644 --- a/src/main/scala/scalafix/sbt/ScalafixPlugin.scala +++ b/src/main/scala/scalafix/sbt/ScalafixPlugin.scala @@ -327,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, @@ -364,7 +364,7 @@ object ScalafixPlugin extends AutoPlugin { val interface = ScalafixInterface( cache = buildScalafixInterfaceCache, - scalafixScalaMajorMinorVersion = projectScalafixScalaBinaryVersion, + scalafixScalaMajorMinorVersion = projectScalaMajorMinorVersion, toolClasspath = toolClasspath, logger = ScalafixInterface.defaultLogger, callback = buildScalafixMainCallback