From 994b6d2d44bd94c6c8f569bfdb920e6bd50cfbbd Mon Sep 17 00:00:00 2001 From: Domantas Petrauskas Date: Sat, 17 Feb 2024 21:02:43 +0200 Subject: [PATCH] Move scripted watch triggers to scriptedSourcesSync task --- .../sources/ScriptedSourcesPlugin.scala | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/main/scala/sbt/scripted/sources/ScriptedSourcesPlugin.scala b/src/main/scala/sbt/scripted/sources/ScriptedSourcesPlugin.scala index 11df9db..23ea50b 100644 --- a/src/main/scala/sbt/scripted/sources/ScriptedSourcesPlugin.scala +++ b/src/main/scala/sbt/scripted/sources/ScriptedSourcesPlugin.scala @@ -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 @@ -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 ) }