Where should I place my compiled (via Rhino) Javascript classes, for them to be
included on the classpath during compilation, and included in the generated
dist
bundle?
Play Framework 2.1-RC1 + SBT ignores them, sometimes during compilation, and sometimes when generating the dist bundles.
1. Placing generated files in classes/
or classes_managed/
If I place the generated .class files here or here:
target/scala-2.10/classes/
target/scala-2.10/classes_managed/
Then compile
and run
works fine. But some weird compilation step (what?!) during stage
and dist
fails: it won't find the compiled classes.
2. Placing classes in dedicated directory
If I place the generated .class files here:
target/scala-2.10/compiledjs-classes/
And add a classpath entry to SBT's config:
object ApplicationBuild extends Build {
...
def mainSettings = List(
...,
unmanagedClasspath in Compile <+= (baseDirectory) map { bd =>
Attributed.blank(bd / "target/scala-2.10/compiledjs-classes")
},
...)
Then compile
, run
, stage
and dist
works fine. However! When I unzip and
start the generated .zip file (generated via dist
), then the application
fails at runtime, because the compiled Javascript classes aren't included in
the .zip.
3. Placing classes in lib/ folder
Then compile
won't find the class files.
(I placed e.g. class compiledjs.HtmlSanitizerJs
in
lib/compiledjs/HtmlSanitizerJs.class
.)
What am I supposed to do? I mean, what works and is best practices?
Anyhow, right now I'm copying the generated classes to both
target/scala-2.10/compiledjs-classes/
(so compilation works) and
target/scala-2.10/classes/
(so they're included in the generated .zip)
This works, but feels very wrong.
(( Oddly enough, everything worked okay with an older version of Play Framework
(older than RC-1) and when I was using PlayProject rather than play.Project.
I then kept the generated classes in target/scala-2.10/classes/
, only. ))