Skip to content

Commit

Permalink
scalafmt-dynamic: 3.2.0, remove custom session
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Meltzer authored and kitbellew committed Nov 29, 2021
1 parent 309c19a commit c827ea4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

This file was deleted.

22 changes: 7 additions & 15 deletions plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._

Expand Down Expand Up @@ -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("[", ",", "]")}"
Expand Down

0 comments on commit c827ea4

Please # to comment.