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 8, 2020
1 parent 0cf5501 commit a4ba496
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 @@ -46,12 +46,13 @@ object ScalafixPlugin extends AutoPlugin {
val scalafixOnCompile: SettingKey[Boolean] =
settingKey[Boolean](
"Run Scalafix rule(s) declared in .scalafix.conf 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 := true)."
)

import scala.language.implicitConversions
Expand Down Expand Up @@ -179,7 +180,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 @@ -354,10 +354,9 @@ object ScalafixPlugin extends AutoPlugin {
scalafixResolvers.in(ThisBuild).value,
projectDepsInternal
)
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 a4ba496

Please sign in to comment.