I would like to add a directory to the watchedSources setting to trigger a build task whenever I save a file in that directory.
override def baseProject = play.Project(
moduleName,
moduleVersion,
dependencies = libraries,
path = file(location),
settings = moduleSettings ++ Seq(
watchSources <++= baseDirectory map { dir =>
Seq(
dir / "src/main/javascript"
)
}
)
)
I can't seem to get around the following error:
type mismatch;
[error] found : sbt.Project.Initialize[ScalaObject with Equals]
[error] required: sbt.Project.Initialize[sbt.Task[?]]
[error] Note: ScalaObject with Equals >: sbt.Task[?], but trait Initialize is invariant in type T.
[error] You may wish to define T as -T instead. (SLS 4.5)
[error] watchSources <++= baseDirectory { f =>
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
How do I append a sequence of files to the result of the watched sources task?
watchSources <++= baseDirectory map { path => ((path / "src/main/webapp/coffee") ** "*.coffee").get }
I had a very similar problem with my Play project; I want SBT to watch public/js
as well as test/js
(which contains Jasmine tests), for changes to ALL JavaScript files.
The solution is to use an SBT Path Finder expression to nominate the locations as follows:
val main = play.Project(appName, appVersion, appDependencies, settings = Defaults.defaultSettings ++ buildInfoSettings ++ scctSettings).settings(
testOptions in Test += Tests.Argument("junitxml", "console"),
unmanagedResources in Compile ++= (file("public/js") ** "*.js").get,
unmanagedResources in Test ++= (file("test/js") ** "*.js").get,
...
The Path Finder is this bit: (file("public/js") ** "*.js")
- and calling get
on it returns a Seq[File]
, which we add to the unmanagedResources
(which are considered to be watched sources, but not Scala, which is ideal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With