AW: Creating task/macro wrappers

Jan Matèrne (jhm) <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <002c01d4cd15$2e4ea3e0$8aebeba0$@de>
Not sure why you want to wrap an existing Ant task ...
If you want to provide default settings, you could use <presetdef>

Jan

> -----Ursprüngliche Nachricht-----
> Von: Isaac Jurado [mailto:[email protected]]
> Gesendet: Sonntag, 24. Februar 2019 18:27
> An: Ant Users List; [email protected]
> Betreff: Re: Creating task/macro wrappers
> 
> Thanks!  I didn't notice the <augment> task existed.
> 
> However, I don't seem to wrap my head around it.  In particular, it
> doesn't seem to support forward references.  This is what I tried:
> 
> <macrodef name="mywrapper">
>   <attribute name="timeOut" default=""/>
>   <sequential>
>     <augment unless:blank="timeOut" id="my-testng-invocation"
> timeOut="@{timeOut}"/>
>     <testng id="my-testng-invocation">...</testng>
>   </sequentail>
> </macrodef>
> 
> The error I get is:
> 
> java.lang.IllegalStateException: Unknown reference "my-testng-
> invocation"
> 
> Best regards.
> 
> On Sat, Feb 23, 2019 at 5:41 PM Matt Benson <[email protected]>
> wrote:
> >
> > Look into the <augment> task with conditionally executed (using
> > if/unless namespaces, antcontrib <if>, or similar) <sequential>
> blocks.
> >
> > HTH,
> > Matt
> >
> > On Sat, Feb 23, 2019, 3:37 AM Isaac Jurado <[email protected]>
> wrote:
> >
> > > Hello Ant users,
> > >
> > > I'm trying to create a <macrodef> wrapper over <testng>.  The idea
> > > is to have my macro expose the same attributes that <testng>
> > > supports, with as close semantics as possible.
> > >
> > > Unfortunately, I have no idea how to reproduce the presence/absence
> > > behavior.  For instance, <testng> accepts a "timeout" integer
> > > attribute.  So in my macro I would do:
> > >
> > > <attribute name="timeout" default=""/>
> > >
> > > And then calling TestNG would be:
> > >
> > > <testng timeout="@{timeout}">...</testng>
> > >
> > > But this turns out not to be the same behavior as NOT specifying
> the
> > > timeout attribute.  In this case, Ant fails because empty string
> > > does not parse to an integer.
> > >
> > > Is there a way to achieve my goal?  I would like to avoid writing
> > > Java code.  But I don't mind resorting to Javascript in the build
> > > file (<script> or <scriptdef>).
> > >
> > > Thanks in advance.
> > >
> > > --
> > > Isaac Jurado
> > >
> > > "The noblest pleasure is the joy of understanding"
> > > Leonardo da Vinci
> > >
> > > -------------------------------------------------------------------
> -
> > > - To unsubscribe, e-mail: [email protected] For
> > > additional commands, e-mail: [email protected]
> > >
> > >
> 
> 
> 
> --
> Isaac Jurado
> 
> "The noblest pleasure is the joy of understanding"
> Leonardo da Vinci
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected] For additional
> commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.