[Webtest] Is it possible to use <script> without putting JARs in $ANT_HOME/lib?

Matt Raible webtest@lists.canoo.com
Tue, 4 Apr 2006 17:57:03 -0600


I sent the e-mail below the Ant users list a couple hours ago, but no
response so far. Does anyone on this list know of a solution?=20
Basically, the <script> task in Ant requires an older version of
js.jar, therefore webtest doesn't work when I copy it into
$ANT_HOME/lib.

Thanks,

Matt

------------------
I'd like to use the <script> task without putting bsf.jar and js.jar
in ANT_HOME/lib.  Is that possible?

I tried the following, but no dice:

        <taskdef name=3D"foo"
classname=3D"org.apache.tools.ant.taskdefs.optional.Script">
                <classpath>
                        <fileset dir=3D"${ant-contrib.dir}" includes=3D"*.j=
ar"/>
                </classpath>
        </taskdef>

                <!-- Using Javascript functions to capitalize and
lowercase the model.name -->
         <foo language=3D"javascript"><![CDATA[

             // getting the value
             lowercaseValue =3D project.getProperty("object.name");

             // the first character
             low =3D lowercaseValue.substring(0,1).toLowerCase();

             // the rest of the value
             rest =3D lowercaseValue.substring(1);

            // convert first character to uppercase
             up =3D low.toUpperCase();

             // concatenate the uppercase with the rest
             uppercaseValue =3D up + rest;
             lowercaseValue =3D low + rest;

             // store the result in a new property
             project.setProperty("model.name",uppercaseValue);
             project.setProperty("model.name.lowercase", lowercaseValue);

         ]]></foo>
    </target>

I get:

BUILD FAILED
java.lang.NoClassDefFoundError: org/apache/bsf/BSFException

If I move js.jar and bsf.jar in $ANT_HOME/lib, everything works fine.
The main reason I want to keep the JARs in my project is because 1) I
don't want users to go through an extra "copy JARs into ANT_HOME/lib
step", and 2) I'm using Canoo WebTest uses a newer version of js.jar
(the latest version of rhino) and I don't want the conflict.

Thanks,

Matt