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

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


Nevermind, I solved this with an Ant Task I found in the Antelope project.

       <stringutil string=3D"${object.name}" property=3D"remainder">
           <substring beginindex=3D"1"/>
       </stringutil>
       <stringutil string=3D"${object.name}" property=3D"char1">
           <substring endindex=3D"1"/>
       </stringutil>
       <stringutil string=3D"${char1}" property=3D"upperChar1">
           <uppercase/>
       </stringutil>
       <stringutil string=3D"${char1}" property=3D"lowerChar1">
           <lowercase/>
       </stringutil>
       <property name=3D"model.name" value=3D"${upperChar1}${remainder}"/>
       <property name=3D"model.name.lowercase"
value=3D"${lowerChar1}${remainder}"/>

Thanks,

Matt

On 4/4/06, Matt Raible <mraible@gmail.com> wrote:
> 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?
> 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"*=
.jar"/>
>                 </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
>