ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Beard <>
Subject Re: Rhino global.load() in script context
Date Sat, 21 Aug 2010 18:03:17 GMT
Hi Greg,

Thanks for your response. Replies below:

On 10-08-21 01:41 PM, Greg Roodt wrote:
> I believe load() is part of Rhino Shell. I think all that the<script />
> task runs when using JavaScript is the interpreter. It would only have the
> pure Javascript standard language features (and a few bits and pieces to
> interact with Java and the execution context).
load() is normally exposed as part of the global object when running 
Rhino, in the shell or the interpreter. All the js module loaders that 
support Rhino that I've encountered, including RequireJS and dojo, make 
use of load() to load JavaScript modules.
> It might be easier to run the shell for each test? Like so:
> java [options]
> script-filename-or-url [script-arguments]
> Or like John Resig does with env.js:
I'm using that technique for other parts of my code, but it would be 
much easier to simply hook into Ant's ResourceSet data structures for 
this part, as it's possible to register a number of unit tests with dojo 
before running them.

> Or maybe, define your own global load() function inside the<script />  tag?
That's what I'm working on. This seems to work, but I still need to test 
it with the dojo module loader:

         <script language="javascript" manager="bsf">


                 <fileset dir="../../../lib/java/" includes="js.jar"/>

                 <fileset dir="../../../lib/build-java/" includes="*.jar"></fileset>


             //define load in global scope

             function readFile(path){

                 stream = new;

                 fc = stream.getChannel();

                 bb =, 0, fc.size());

                 return java.nio.charset.Charset.defaultCharset().decode(bb).toString();


             load = function(path){



             echo = helloworld.createTask("echo");

             var contents = readFile('hello.js')







echo.setMessage("hello world!");



      [echo] echo.setMessage("hello world!");

      [echo] hello world!



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message