1

I have a Spray application with a basic front end component with source in src/main/frontend and the deployed version (compiled sass, minification etc.) in Spray's default resources location src/main/resources. I would like to change the resource directory to src/main/frontend for Revolver's re-start task only, in order to see changes quicker when developing.

I have tried adding the setting

resourceDirectory in Revolver.reStart <<= baseDirectory(_ / "src" / "main" / "frontend")

but it doesn't seem to have an effect. I guess because resourceDirectory is a setting in the Compile scope and not one in Revolver itself. In the SBT console:

> reStart:resourceDirectory
[info] /Users/cartew01/workspace/applaudio-spray/src/main/frontend
> compile:resourceDirectory
[info] /Users/cartew01/workspace/applaudio-spray/src/main/resources

Does anyone know how I can change this for the re-start task but not for any others? Possibly by creating a custom task that calls re-start with the additional setting?

Thank you for your help.

William Carter
  • 1,287
  • 12
  • 19
  • 1
    You should add your another resource directory to the fullClasspath in reStart, for instance `(fullClasspath in Revolver.reStart) += (WebKeys.public in Assets in web).value`, or in your case `fullClasspath in Revolver.reStart += baseDirectory(_ / "src" / "main" / "frontend")` - actually, getFromResourceDirectory and getFromResource will serve contents from the classpath. – abatyuk Feb 25 '15 at 02:47
  • 1
    actually, to better understand it, i suggest running `inspect reStart` - it depends on `compile:products`, which in turn depends on `compile:copyResources`, which in turn depends on `compile:resourceDirectories`. So, reStart will use whatever is produced by compiler, i.e. resources copied from somewhere. The solution above seems a bit easier. – abatyuk Feb 25 '15 at 02:52
  • 1
    Brilliant solution to the problem. Thanks a lot. However, I'm now stuck with something a lot more trivial. I've added `fullClasspath in Revolver.reStart += baseDirectory(_ / "src" / "main" / "frontend").value` to the build as suggested and it works but I'd like this directory to appear at the start of the classpath. How do I append a file to an SBT classpath? Thanks again. – William Carter Feb 26 '15 at 00:26
  • 2
    Found the answer in this post: http://stackoverflow.com/questions/18525478/is-there-anyway-to-prepend-a-jar-to-the-unmanagedclasspath-in-sbt. You can map classpaths: `fullClasspath in Revolver.reStart <<= (fullClasspath in Revolver.reStart, baseDirectory) map { (classpath, base) => Attributed.blank(base/"src"/"main"/"frontend") +: classpath }` Thanks abatyuk. – William Carter Feb 26 '15 at 00:42
  • As noone else chimed in, put the solution above as an answer – abatyuk Feb 26 '15 at 00:45

1 Answers1

0

You should add your another resource directory to the fullClasspath in reStart, for instance (fullClasspath in Revolver.reStart) += (WebKeys.public in Assets in web).value, or in your case fullClasspath in Revolver.reStart += baseDirectory(_ / "src" / "main" / "frontend") - actually, getFromResourceDirectory and getFromResource will serve contents from the class path.

to better understand it, i suggest running inspect reStart - it depends on compile:products, which in turn depends on compile:copyResources, which in turn depends on compile:resourceDirectories. So, reStart will use whatever is produced by compiler, i.e. resources copied from somewhere. The solution above seems a bit easier

abatyuk
  • 1,342
  • 9
  • 16