Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:50:02+00:00 2026-06-16T00:50:02+00:00

Where should I place my compiled (via Rhino) Javascript classes, for them to be

  • 0

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. ))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:50:04+00:00Added an answer on June 16, 2026 at 12:50 am

    I couldn’t find a way to put classfiles to the jars on the stage task. As a workaround I generate a JAR file on stage and on play run I set the classpath to the “rhino” folder in the base folder.

    I created a gist for you, so you can check it out and try: https://gist.github.com/4321216 rhino/so/Example.class represents a Rhino class but is only a Java class that returns a String.

    Add in your Build.scala:

      val rhinoJarName = "rhino.jar"
      val folderForRhinoJar = unmanagedBase
      val rhinoClasspath = (baseDirectory) map { base => Attributed.blank(base / "rhino")}
      val rhinoClassesToJar = TaskKey[Unit]("rhino-classes-to-jar")
      val rhinoClassesToJarInitializer = (base: File, folderForJar: File) => {
        val rhinoFolder = new File(base, "rhino")
        val isClassFile = (file: File) => file.getName.endsWith("class")
        val classFiles =  rhinoFolder.***.filter(isClassFile).get
        val sources = classFiles map { file =>
          file -> file.getCanonicalPath.drop(rhinoFolder.getCanonicalPath.length + 1)
        }
        IO.jar(sources, folderForJar / rhinoJarName, new java.util.jar.Manifest())
      }
    
      val main = play.Project(appName, appVersion, appDependencies).settings(
        unmanagedClasspath in Compile <+= rhinoClasspath,
        unmanagedClasspath in Runtime <+= rhinoClasspath,
        rhinoClassesToJar <<= (baseDirectory, folderForRhinoJar) map rhinoClassesToJarInitializer,
        playStage <<= playStage.dependsOn(rhinoClassesToJar),
        playStage <<= (playStage, folderForRhinoJar) map {(unused, folder) =>
          IO.delete(folder / rhinoJarName)
        },
        cleanFiles <+= folderForRhinoJar { _ / rhinoJarName } //make sure jar will be deleted if play stage does not finish and cleanup jar
      )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should you place the @Transactional in the DAO classes and/or their methods or is
This code should i place this code at bottom of body it's in conditional
I'm still quite new to CodeIgniter and I was wondering, where should I place
Should it always come after main css or place doesn't matter? For example: if
Should be simple but I couldn't find the answer, I would like to place
Is there a consensus about the best place to put Python unittests? Should the
I was just curious, why should we use reflection in the first place? //
Criteria, don't want creating copies of objects all over the place. Should be fast,
When I develop application in IDEA, where should I place logback.xml for it to
My app should be extendable using plug-ins or often called sugars. I would place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.