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

Support several scalafixScalaBinaryVersion within a build #380

Merged
merged 11 commits into from
Dec 19, 2023
10 changes: 5 additions & 5 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ object ScalafixPlugin extends AutoPlugin {
SettingKey[Boolean]("bspEnabled") := false
)
),
scalafixInterfaceProvider := ScalafixInterface.fromToolClasspath(
bjaglin marked this conversation as resolved.
Show resolved Hide resolved
(scalafixScalaBinaryVersion).value,
scalafixDependencies = (scalafixDependencies).value,
scalafixCustomResolvers = (scalafixResolvers).value
bjaglin marked this conversation as resolved.
Show resolved Hide resolved
),
update := {
object SemanticdbScalac {
def unapply(id: ModuleID): Option[String] =
Expand Down Expand Up @@ -211,11 +216,6 @@ object ScalafixPlugin extends AutoPlugin {
),
scalafixDependencies := Nil,
commands += ScalafixEnable.command,
scalafixInterfaceProvider := ScalafixInterface.fromToolClasspath(
(ThisBuild / scalafixScalaBinaryVersion).value,
scalafixDependencies = (ThisBuild / scalafixDependencies).value,
scalafixCustomResolvers = (ThisBuild / scalafixResolvers).value
),
scalafixInterfaceCache := new BlockingCache[
ToolClasspath,
ScalafixInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules = [DisableSyntax, OrganizeImports, ExplicitResultTypes]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DisableSyntax seems unexercised, but it doesn't hurt to keep a syntactic rule here I guess

OrganizeImports.removeUnused = true
ExplicitResultTypes.skipSimpleDefinitions = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rules = [DisableSyntax, OrganizeImports]
OrganizeImports.removeUnused = false
24 changes: 24 additions & 0 deletions src/sbt-test/sbt-scalafix/cross-build-advanced/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import _root_.scalafix.sbt.{BuildInfo => Versions}

val scala3Version = "3.3.0"
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision

lazy val root = project
.in(file("."))
.settings(
scalaVersion := Versions.scala212,
crossScalaVersions := Seq(Versions.scala212, Versions.scala213, scala3Version),
scalacOptions ++= (if (scalaVersion.value.startsWith("2")) Seq("-Ywarn-unused") else Seq()),
scalafixScalaBinaryVersion := {
if ((scalaBinaryVersion).value == "3") {
(scalafixScalaBinaryVersion).value
} else { (scalaBinaryVersion).value }
bjaglin marked this conversation as resolved.
Show resolved Hide resolved
},
scalafixConfig := {
if (scalaBinaryVersion.value == "3")
Some(file(".scalafix-3.conf"))
else
Some(file(".scalafix-2.conf"))
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolvers += Resolver.sonatypeRepo("public")
libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
zarthross marked this conversation as resolved.
Show resolved Hide resolved
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.Int
import scala.collection.Seq
import scala.collection.AbstractSeq

object Main {
def foo(a: Int) = a + 2.0f
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import scala.Int

object Main {
def foo(a: Int): Float = a + 2.0f
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.Int
import scala.collection.Seq
import scala.collection.AbstractSeq

object Main {
def foo(a: Int) = a + 2.0f
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.Int
import scala.collection.AbstractSeq
import scala.collection.Seq

object Main {
def foo(a: Int) = a + 2.0f
}
6 changes: 6 additions & 0 deletions src/sbt-test/sbt-scalafix/cross-build-advanced/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
> +compile

> +scalafix

$ must-mirror src/main/scala-2/Main.scala src/main/scala-2/Main.scala.expected
$ must-mirror src/main/scala-3/Main.scala src/main/scala-3/Main.scala.expected