Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 36 additions & 27 deletions src/main/scala/sbt/scripted/sources/ScriptedSourcesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ object ScriptedSourcesPlugin extends AutoPlugin {
sbtTestDirectory := target.value / "generated-sbt-test",
scriptedSourcesConfigFileName := ".sources",
scriptedSourcesSbtTestDirectory := sourceDirectory.value / "sbt-test",
scripted / watchTriggers := Seq(
Glob(
scriptedSourcesSbtTestDirectory.value,
RecursiveGlob
)
),
scriptedSourcesSync := {
val log = streams.value.log

Expand Down Expand Up @@ -197,29 +191,44 @@ object ScriptedSourcesPlugin extends AutoPlugin {
).reduce(_ && _)
}
},
scripted := scripted.dependsOn(scriptedSourcesSync).evaluated,
scripted / watchTriggers ++= {
scriptedSourcesSync / watchTriggers ++= {
val log = Keys.sLog.value

log.debug("Setting scripted sources as watch triggers")

val baseDirectoryV = baseDirectory.value
val scriptedSourcesSbtTestDirectoryV =
scriptedSourcesSbtTestDirectory.value
val scriptedSourcesConfigFileNameV = scriptedSourcesConfigFileName.value
Seq(
{
log.debug(
s"Setting `scriptedSourcesSbtTestDirectory` [$scriptedSourcesSbtTestDirectory] as watch trigger"
)

processScriptedSources(log)(
baseDirectoryV,
scriptedSourcesSbtTestDirectoryV,
scriptedSourcesConfigFileNameV
)(
_.flatMap { case (_, sourcesForTest) =>
sourcesForTest
.map { sourceForTest =>
Glob(sourceForTest, RecursiveGlob)
}
}.toList
)
}
Glob(
scriptedSourcesSbtTestDirectory.value,
RecursiveGlob
)
}
) ++ {

log.debug("Setting scripted sources as watch triggers")

val baseDirectoryV = baseDirectory.value
val scriptedSourcesSbtTestDirectoryV =
scriptedSourcesSbtTestDirectory.value
val scriptedSourcesConfigFileNameV = scriptedSourcesConfigFileName.value

processScriptedSources(log)(
baseDirectoryV,
scriptedSourcesSbtTestDirectoryV,
scriptedSourcesConfigFileNameV
)(
_.flatMap { case (_, sourcesForTest) =>
sourcesForTest
.map { sourceForTest =>
Glob(sourceForTest, RecursiveGlob)
}
}.toList
)
}
},
scripted := scripted.dependsOn(scriptedSourcesSync).evaluated,
scripted / watchTriggers := Seq.empty // watch triggers should be added to `scriptedSourcesSync` task instead
)
}