Skip to content

Commit

Permalink
enable caching when scalafixOnCompile := true
Browse files Browse the repository at this point in the history
  • Loading branch information
github-brice-jaglin committed Jul 5, 2020
1 parent 2a82c8d commit 0e81719
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ object ScalafixPlugin extends AutoPlugin {
val scalafixOnCompile: SettingKey[Boolean] =
settingKey[Boolean](
"Run Scalafix rules on compilation and fail on lint errors. " +
"Off by default."
"Off by default. When enabled, caching will be automatically activated, " +
"but can be disabled with `scalafixCaching := false`."
)

val scalafixCaching: SettingKey[Boolean] =
settingKey[Boolean](
"Cache scalafix invocations (off by default, still experimental)."
"Cache scalafix invocations (off by default, on if scalafixOnCompile is set)."
)

import scala.language.implicitConversions
Expand Down Expand Up @@ -165,7 +166,6 @@ object ScalafixPlugin extends AutoPlugin {

override lazy val globalSettings: Seq[Def.Setting[_]] = Seq(
scalafixConfig := None, // let scalafix-cli try to infer $CWD/.scalafix.conf
scalafixCaching := false,
scalafixOnCompile := false,
scalafixResolvers := Seq(
Repository.ivy2Local(),
Expand Down Expand Up @@ -322,10 +322,9 @@ object ScalafixPlugin extends AutoPlugin {
"as compilation silently triggers rewrites - aborting"
)
}
val cachingRequested = scalafixCaching.or(scalafixOnCompile).value
val maybeNoCache =
if (shell.noCache || !scalafixCaching.in(config).value)
Seq(Arg.NoCache)
else Nil
if (shell.noCache || !cachingRequested) Seq(Arg.NoCache) else Nil
val mainInterface = mainInterface0
.withArgs(maybeNoCache: _*)
.withArgs(
Expand Down

0 comments on commit 0e81719

Please sign in to comment.