Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Scala 2.11 detection & use same instance across patch releases #435

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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