Aw: Re: macrodef with parameters to pass to java task

"Al Le" <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <trinity-f2346f74-53be-4632-b528-73760030a6ce-1496055781207@3capp-gmx-bs51>
Yes, it works! Thank you!



> Gesendet: Montag, 29. Mai 2017 um 12:16 Uhr
> Von: "Stefan Bodewig" <[email protected]>
> An: [email protected]
> Betreff: Re: macrodef with parameters to pass to java task
>
> On 2017-05-29, Al Le wrote:
> 
> > in my ant script I'd like to define a macro (via macrodef) which would call the 'java' task as a part of its body/implementation.
> 
> > In the java task call in the macro, I want to just specify the main class name and the classpath. The parameters (which are usually specified via nested 'arg' elements) should be as variable as they are in the original java task.
> 
> > How would I accomplish this?
> 
> > What I've come up with until now is:
> 
> >     <macrodef name="execMyProgram">
> >         <element name="programArgs" implicit="true" description="'arg' entries for the program, use like in the java task"/>
> 
> >         <sequential>
> >             <java classname="my.class.name" classpathref="my.classpath">
> >                 <programArgs/>
> >             </java>
> >         </sequential>
> >     </macrodef>
> 
> This is the correct way to do it. "implicit=true" means any element you
> nest into <execMyProgram> later will get collected as child of your
> <programArgs> element and you don't need to use that element name
> explicitly.
> 
> So instead of
> 
> > Then I use the macro as follows:
> 
> >     <execMyProgram>
> >         <programArgs>
> >             <arg value="arg1"/>
> >             <arg value="arg2"/>
> >         </programArgs>
> >     </executeProcessMonitor>
> 
> you only have to use
> 
>     <execMyProgram>
>         <arg value="arg1"/>
>         <arg value="arg2"/>
>     </executeProcessMonitor>
> 
> Stefan
> 
> ---------------------------------------------------------------------
> 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.