tags:

views:

98

answers:

1

SBT has triggered execution so if I execute a command like

~test

It executes all test cases and then waits for source changes. I want to extend this behavior to get triggered execution whenever input files are changed. All input files exist in a single folder. To achieve this I created a scala file in project/buildfolder:

import sbt._

class ExtendedProject(info: ProjectInfo) extends DefaultProject(info)
{
  override def watchPaths = (mainSources +++ testSources +++ mainResources 
                            +++ testResources) \ "d:\\...path to folder"
}

but when I execute the test command nothing happens! Invoking ~test waits for sometime and then exits without any output.

Is this because SBT expects all other settings to be overridden too? Is there a way to specify watchPaths in build.properties file?

+1  A: 

try this one:

override def watchPaths = mainSources +++ testSources +++ mainResources +++ testResources +++ Path.fromFile("/path/to/your/dir")
Piotr Maj
thanks a lot Piotr, I am able to modify watchPaths to include the folder. Another question. Is it possible for me to specify file extensions to be watched. In the same directory there can be different files, I want to watch only few of them based on the file extension.
thequark
yes, it is. Look the code below. It uses FileFilter to filter out files you don't want to check.<code>val myfilter = new FileFilter { def accept(f:File) = f.getName.endsWith(".log") } override def watchPaths = mainSources +++ testSources +++ mainResources +++ testResources +++ (Path.fromFile("/Path/to/dir") * myfilter)</code>
Piotr Maj