diff --git a/build.sbt b/build.sbt index 0123e40..df80bc2 100644 --- a/build.sbt +++ b/build.sbt @@ -34,12 +34,13 @@ inThisBuild( onLoadMessage := s"Welcome to sbt-scalafmt ${version.value}" skip in publish := true +val scalafmtVersion = "3.2.0" lazy val plugin = project .enablePlugins(SbtPlugin) .settings( moduleName := "sbt-scalafmt", libraryDependencies ++= List( - "org.scalameta" %% "scalafmt-dynamic" % "3.1.1" + "org.scalameta" %% "scalafmt-dynamic" % scalafmtVersion ), scriptedBufferLog := false, scriptedLaunchOpts += s"-Dplugin.version=${version.value}" diff --git a/plugin/src/main/scala/org/scalafmt/sbt/CompatibilityScalafmtSession.scala b/plugin/src/main/scala/org/scalafmt/sbt/CompatibilityScalafmtSession.scala deleted file mode 100644 index be5cfb7..0000000 --- a/plugin/src/main/scala/org/scalafmt/sbt/CompatibilityScalafmtSession.scala +++ /dev/null @@ -1,14 +0,0 @@ -package org.scalafmt.sbt - -import java.nio.file.Path - -import org.scalafmt.interfaces.{Scalafmt, ScalafmtSession} - -private[sbt] class CompatibilityScalafmtSession( - config: Path, - instance: Scalafmt -) extends ScalafmtSession { - override def format(file: Path, code: String): String = - instance.format(config, file, code) - override def matchesProjectFilters(file: Path): Boolean = true -} diff --git a/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala b/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala index fc5a02a..e15d7b4 100644 --- a/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala +++ b/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala @@ -15,7 +15,7 @@ import scala.util.Failure import scala.util.Success import scala.util.Try -import org.scalafmt.interfaces.{Scalafmt, ScalafmtSessionFactory} +import org.scalafmt.interfaces.Scalafmt import complete.DefaultParsers._ @@ -116,23 +116,15 @@ object ScalafmtPlugin extends AutoPlugin { val repositories = resolvers.collect { case r: MavenRepository => r.root } - val instance = + val scalafmtSession = globalInstance .withReporter(reporter) .withMavenRepositories(repositories: _*) - val scalafmtSession = - instance match { - case t: ScalafmtSessionFactory => - val session = t.createSession(config.toAbsolutePath) - if (session == null) { - throw new MessageOnlyException( - "failed to create formatting session. Please report bug to https://github.com/scalameta/sbt-scalafmt" - ) - } - session - case _ => - new CompatibilityScalafmtSession(config.toAbsolutePath, instance) - } + .createSession(config.toAbsolutePath) + if (scalafmtSession == null) + throw new MessageOnlyException( + "failed to create formatting session. Please report bug to https://github.com/scalameta/sbt-scalafmt" + ) log.debug( s"Adding repositories ${repositories.mkString("[", ",", "]")}"