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
)