I'd like to use the Rhino JavaScript compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and jythonc tasks for Groovy, NetREXX(!) and Jython, respectively. Has anyone used or written such an Ant task, or can anyone provide some tips on how to write one?
Ideally it would have some way to resolve dependencies among JavaScript or Java classes.
Here is a sample build.xml I use for my rhino applications. If you have lots of javascript files you just need to keep adding more tags
~:ant compile jar run
~
Why not simply use java task?
Any objections?
I'm using RequireJS in my project, which includes a script that traces out dependencies between modules, and combines them into a single JavaScript file. Optionally, it can also minify the combined js file with the Google Closure compiler. Once it's in this form, where all dependencies are included in a single js file, the file can be easily compiled using jsc.
Here's a segment of my ant script which I use to create the single combined js file, compile it to a class file, and then create an executable JAR:
The complete build script can be found here.