8

In our Play project, we are having this issue.

When we run our javascript tests, it's triggering a compilation of the scala sources.

All the javascripts tests are under test/assets and any change inside this path shouldn't trigger a compilation of the sources.

This means that this folder is referred somewhere as a source directory. I tried to see in which sbt property this folder could be referred but I didn't find any.

Can anyone give some clues on how to prevent compilation triggering when a file inside this folder is changed?

Dale Wijnand
  • 6,054
  • 5
  • 28
  • 55
rmorais
  • 229
  • 1
  • 5
  • Not a solution, but another datapoint would be to rename the folder to "donotcompile" or whatever and see if the problem still occurs. In other words, is the name "tests" significant or not? – Ed Staub Mar 31 '15 at 16:18
  • 1
    If you run `show unmanagedSourceDirectory` or `show unmanagedResourceDirectory` in sbt/activator console the tests directory is listed? Are you sure that only that dir is changed when you run your js tests? BTW what are you using to run your js tests? – Salem Mar 31 '15 at 21:07
  • When I run those commands, the test directory is not shown. That's why I don't know why it's causing a compilation. I tried to inspect other sbt properties and I couldn't found a reference for the test directory any where. I didn't inspect them all, only the obvious ones. Our js tests are run using grunt. All of our assets are managed by grunt/gulp not play. – rmorais Apr 01 '15 at 11:02
  • 1
    In SBT keys are often scoped to a specific configuration or task, so 'show show test:sourceDirectories' will show that "test" is among the source directories for test, not sure why they trigger compile though. – johanandren Apr 01 '15 at 19:04
  • adding to @johanandren comment, you can also try to see if for some reason SBT thinks it's sources (not test sources), so use `show sourceDirectories` without scoping it to `test`. (or try explicitly scoping this to `compile` or `run`). finally, a case like yours, justifies a new scope. so I suggest you follow: [Custom test configuration](http://www.scala-sbt.org/0.13/docs/Testing.html#Custom+test+configuration) – gilad hoch Apr 02 '15 at 07:37
  • @Cabexas Do you have a setup that reproduces the problem? I'm not able to reproduce what you describe. – Dale Wijnand Apr 14 '15 at 10:40
  • Hi all, thanks for your suggestions. I didn't have more time to pursue this issue. It's on hold for now but as soon as I have the time, I will keep digging it. I inspected all the suggested sbt keys, I didn't find any reference to my test directory. And this is the main problem, as I don't find a reference to it in any sbt key. @DaleWijnand I don't have a minimal setup to reproduce it. When I have more time, I will try to create one. – rmorais Apr 16 '15 at 08:21
  • I have created a minimal project to reproduce the problem I am facing. You can find it in https://github.com/rmorais/sbt. In the readme there are instructions to reproduce the problem. – rmorais Apr 17 '15 at 16:42

1 Answers1

1

The watchSources task seems to contain the files that are tracked for change. To inspect the list of folders/files type the following in sbt:

>show watchSources

I am not sure if this is the simplest solution, but it will remove the test/assets from within the watchSources.

watchSources <<= watchSources.map{
    t => t.filterNot(x => x.getCanonicalPath.endsWith("test/assets"))
}
marios
  • 8,874
  • 3
  • 38
  • 62