ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: BeanShellDef - java.lang.LinkageError: duplicate class definition: AList
Date Thu, 29 Jan 2004 14:23:20 GMT
Peter Reilly wrote:

> Michael Sunde wrote:
>
>> Hi,
>>
>> Can't wait to see beanshelldef or something equivalent in a new 
>> version of ant. How about this for a task name:
>> - inlinetypedef
>> - scripttypedef
>>  
>>
> All are good, scripttypedef may however get confused with scriptdef. 
> reflectdef was meant to mean
> that java reflection was going to be used to find attributes and 
> nested elements so that for example
> current jython could not be used.
>
>> or maybe merge the functionality into typedef.
>>  
>>
> No, the task would be an optional task (dependant on BSF).
>
>> Looking at your example of reflectdef, the only thing I don't like is 
>> the line:
>>     hello.class;
>> I prefer how it is done in beanshelldef with the classname attribute. 
>> That is just my $0.02,so do what you think is best.
>>  
>>
> The reason for this is that the beanshelldef was able to run a bit of 
> beanshell code to get the class object. reflectdef is
> meant to independent of the language used.
> One can use a macrodef to "hide" this:
>
>    <macrodef name="beanshelldef">
>      <attribute name="name"/>
>      <text name="text"/>
>      <sequential>
>        <reflectdef
>          name="@{name}" language="beanshell" exec="@{name}.class;">
>          @{text}
>        </reflectdef>
>      </sequential>
>    </macrodef>
>
>    <beanshelldef name="hello">
>      package mybeanshelltasks;
>      import org.apache.tools.ant.Task;
>      public class hello extends Task {
>          public void execute() {
>             log("Hello world");
>          }
>      }
>    </beanshelldef>
>
>    <hello/>
>
>
>
>> For now, I managed to modify beanshelldef to work around the antcall 
>> problem. See the attachment.
>>  
>>
> Pretty neat, but won't work for the general language case. - It may be 
> possible to use a different classloader
> for each definition or use textual comparision for override  checking.
>
>> Keep up the good work. I look forward to seeing future versions of ant.
>>  
>>
> Cheers,
> Peter
>
>> Michael
>>
>>  
>>
>>> -----Original Message-----
>>> From: Peter Reilly [mailto:peter.reilly@corvil.com]
>>> Sent: Friday, January 23, 2004 4:08 AM
>>> To: Ant Developers List
>>> Subject: Re: BeanShellDef - java.lang.LinkageError: duplicate class
>>> definition: AList
>>>
>>>
>>> Thanks,
>>>  Yes I find it very usefull to write small tasks using beanshelldef.
>>>
>>>  There is a  problem with antcall and beanshelldef.
>>> The easiest work-around would be to place the definition in an init
>>> target that gets called only if a property is not defined:
>>>
>>> <target name="init-beanshell-tasks" unless="beanshell-tests-defined">
>>>   <beanshelldef .../>
>>>   <property name="beanshell-tasks-defined" value="yes"/>
>>> </target>
>>>
>>> About the beanshelldef, I have found that I can use BSF to do this 
>>> and not
>>> call beanshell directly. This will mean that the define will support 
>>> any
>>> BSF language that can export proper java classes and also make the
>>> ant code independant of linking to beanshell.
>>>
>>> The working title is reflectdef:
>>>
>>>    <reflectdef name="hello" language="beanshell">
>>>      import org.apache.tools.ant.Task;
>>>      public class hello extends Task {
>>>          public void execute() {
>>>             log("Hello world");
>>>          }
>>>      }
>>>      hello.class;
>>>    </reflectdef>
>>>
>>>    <hello/>
>>>
>>>
>>> Currently the only language (I know) that can export a java class 
>>> that can be
>>> reflected is beanshell 2.0b1.  It looks like grovvy and pnuts may 
>>> have this
>>> ability. jython and rhino (As far as I can see) do not.
>>>
>>> Peter
>>>
>>
>>
>>  
>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>
>


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


Mime
View raw message