Skip to content

Commit ad913b9

Browse files
workaround bug for InputTasks streams
1 parent 9e9c1cf commit ad913b9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/main/scala/scalafix/sbt/ScalafixPlugin.scala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package scalafix.sbt
33
import java.nio.file.Path
44

55
import com.geirsson.coursiersmall.Repository
6+
import sbt.KeyRanks.Invisible
67
import sbt.Keys._
78
import sbt.internal.sbtscalafix.{Compat, JLineAccess}
89
import sbt.plugins.JvmPlugin
@@ -44,7 +45,13 @@ object ScalafixPlugin extends AutoPlugin {
4445

4546
def scalafixConfigSettings(config: Configuration): Seq[Def.Setting[_]] =
4647
Seq(
47-
scalafix := scalafixInputTask(config).evaluated
48+
scalafix := scalafixInputTask(config).evaluated,
49+
// In some cases (I haven't been able to understand when/why, but this also happens for bgRunMain while
50+
// fgRunMain is fine), there is no specific streams attached to InputTasks, so we they end up sharing the
51+
// global streams, causing issues for cache storage. This does not happen for Tasks, so we define a dummy one
52+
// to acquire a distinct streams instance for each InputTask.
53+
scalafixDummyTask := (()),
54+
streams.in(scalafix) := streams.in(scalafixDummyTask).value
4855
)
4956

5057
@deprecated("This setting is no longer used", "0.6.0")
@@ -67,6 +74,13 @@ object ScalafixPlugin extends AutoPlugin {
6774

6875
import autoImport._
6976

77+
private val scalafixDummyTask: TaskKey[Unit] =
78+
TaskKey(
79+
"scalafixDummyTask",
80+
"Implementation detail - do not use",
81+
Invisible
82+
)
83+
7084
override lazy val projectSettings: Seq[Def.Setting[_]] =
7185
Seq(Compile, Test).flatMap(c => inConfig(c)(scalafixConfigSettings(c)))
7286

0 commit comments

Comments
 (0)