ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Madunic <haj...@imag.net>
Subject Re: random number generator
Date Sat, 21 Jul 2007 14:25:29 GMT
Thank you Gilbert,

it works like a charm.

Mario

Quoting Gilbert Rebhan <ant@schillbaer.de>:

> Hi,
> 
> Mario Madunic wrote:
> > Hi,
> > 
> > I'm trying to generate a random number to be used as a temporary directory
> name
> > through a multi step xslt process. I'm using Ant 1.6.5 and Java 1.6.0-b105
> 
> > I receive the following error
> > 
> >    [random] Jul 20, 2007 9:11:27 PM org.apache.bsf.BSFManager exec
> >    [random] SEVERE: Exception :
> >    [random] java.security.PrivilegedActionException:
> > org.apache.bsf.BSFException: JavaScript Error: Internal Error:
> > org.mozilla.javascript.EcmaError: ReferenceError: "self" is not defined.
> 
> 
> if you're already use BSF with <script> task i would recommend
> JRuby, get the JRuby.jar from =
> 
> http://dist.codehaus.org/jruby/jruby-complete-1.0.jar
> 
> so it's a simple as =
> 
> <target name="depends">
>    <script language="ruby">
>    <![CDATA[
>      $project.setProperty "myrand", rand(4711).to_s
>    ]]>
>    </script>
> </target>
> 
> <target name="main" depends="depends">
>    <echo>
>      $${myrand} == ${myrand}
>    </echo>
> </target>
> 
> main:
>       [echo] ${myrand} == 718
> BUILD SUCCESSFUL
> Total time: 1 second
> 
> Just put an integer to the Kernel#rand method.
> If you want a floating point number, just use
> rand without (integer) =
> 
> <script language="ruby">
>    <![CDATA[
>      $project.setProperty "myrand", rand.to_s
>    ]]>
>   </script>
> 
> 
> Regards, Gilbert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message