ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: import classes in <scriptdef javascript/>
Date Fri, 14 Nov 2003 10:18:42 GMT
Looks like this is a more general problem:
    <script language="javascript">
      <![CDATA[
        // this would work
        //throw new java.lang.Exception("an Exception");
        
        // causes: ReferenceError: "Package" is not defined.
        importClass(Package.org.apache.tools.ant.BuildException);
        throw new BuildException("an Exception");
        ]]>
    </script>
Also gives the same error.
This also does not work for ant 1.5.3.
Perhaps this is an issue with the rhino version?

In any case beanshell (2.0b) works fine:
    <scriptdef name="dofail" language="beanshell">
        import org.apache.tools.ant.BuildException;
        throw new BuildException("an Exception");
    </scriptdef>
    <dofail/>

- well nearly fine, the reported line number looks wrong..
/home/preilly/learning/ant/f.xml:50: org.apache.bsf.BSFException: The 
application script threw an exception: an Exception BSF info: scriptdef 
<dofail> at line: 0 column: columnNo

Peter
On Friday 14 November 2003 08:21, Jan.Materne@rzf.fin-nrw.de wrote:
> I want to check if some attributes are set and throw a BuildException if
> not.
> So I have to import the BuildException class. With <script> you would do
> that
> with
>     importClass(Package.org.apache.tools.ant.BuildException);
> "Package" is needed, because "org" is not a standard namespace (java,
> javax) for that method
> (see script task manual).
>
> But inside <scriptdef> that doesn´t work.
>
>
>     <scriptdef name="dofail" language="javascript">
>         <![CDATA[
>             // this would work
>             //throw new java.lang.Exception("an Exception");
>
>             // causes: ReferenceError: "Package" is not defined.
>             importClass(Package.org.apache.tools.ant.BuildException);
>             throw new BuildException("an Exception");
>         ]]>
>     </scriptdef>
>
>
>
> Jan


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


Mime
View raw message