Skip to content

Commit

Permalink
scalafixOnCompile: hook scalafix into manipulateBytecode
Browse files Browse the repository at this point in the history
Hooking-in into `manipulateBytecode` achieves the same goal, but is
less intrusive than `compile`, particularly since we use a dynamic
task.
  • Loading branch information
github-brice-jaglin committed Jul 10, 2020
1 parent 7562e24 commit 3702195
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ object ScalafixPlugin extends AutoPlugin {
def scalafixConfigSettings(config: Configuration): Seq[Def.Setting[_]] =
Seq(
scalafix := scalafixInputTask(config).evaluated,
compile := Def.taskDyn {
val oldCompile =
compile.value // evaluated first, before the potential scalafix evaluation
manipulateBytecode := Def.taskDyn {
val orig = manipulateBytecode.value
val runScalafixAfterCompile =
scalafixOnCompile.value && !scalafixRunExplicitly.value
if (runScalafixAfterCompile)
scalafix
.toTask("")
.map(_ => oldCompile)
else Def.task(oldCompile)
.map(_ => orig)
else Def.task(orig)
}.value,
// In some cases (I haven't been able to understand when/why, but this also happens for bgRunMain while
// fgRunMain is fine), there is no specific streams attached to InputTasks, so we they end up sharing the
Expand Down

0 comments on commit 3702195

Please sign in to comment.