AW: Passing command Line args for a list

Jan Matèrne (jhm) <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <000f01d17907$fb4e26f0$f1ea74d0$@de>
Something like that?

Jan


ant -Dantcontrib.jar=path/to/ant-contrib-1.0b3.jar
-Dagent.list="node1,node2" -Dnode1.description=ServerA
-Dnode2.description=AnotherServer



<project default="startAgents" xmlns:antcontrib="antlib:net.sf.antcontrib">

    <taskdef uri="antlib:net.sf.antcontrib"
             resource="net/sf/antcontrib/antlib.xml"
             classpath="${antcontrib.jar}"/>
             

    <macrodef name="executeAgent">
        <attribute name="agent"/>
        <attribute name="description"/>
        <sequential>
            <echo>starting Agent @{agent}: @{description}</echo>
        </sequential>
    </macrodef>
    
    
    <target name="startAgents">
        <antcontrib:for list="${agent.list}" delimiter="," param="agent">
            <sequential>
                <executeAgent agent="@{agent}"
description="${@{agent}.description}"/>
            </sequential>
        </antcontrib:for>
    </target>

</project>



Buildfile: C:\temp\ant-test\build.xml

startAgents:
     [echo] starting Agent node1: ServerA
     [echo] starting Agent node2: AnotherServer

BUILD SUCCESSFUL
Total time: 1 second



> -----Ursprüngliche Nachricht-----
> Von: Scot P. Floess [mailto:[email protected]]
> Gesendet: Dienstag, 8. März 2016 08:41
> An: Ant Users List
> Betreff: Re: Passing command Line args for a list
> 
> 
> Didn't hear back - did you get you figure it out?
> 
> On Sat, 5 Mar 2016, Scot P. Floess wrote:
> 
> >
> > I'm confused as you are asking about using command line params (via
> > the -D) but then reusing those for the input task.
> >
> > As an example from your post:
> >
> > ant -f build.xml addNodes -Dagents="d01, d02, d03" -
> D{node???}='node1'
> > -D{node_description???}='node1 description'
> >
> > Note you list -Dagents
> >
> > In your target I see this:
> >
> > <input message="Agents Name Seperated By , :" addproperty="agents" />
> >
> > So the property "agents" is both passed in command line and then
> > reused inside with an input task.
> >
> > Same with the properties node and node_description.
> >
> > The for loop should have no trouble using properties denoted on the
> > command line with the -D
> >
> > The -D will become a property in your ant script.
> >
> >
> >
> >
> > On Fri, 4 Mar 2016, Petronius wrote:
> >
> >>  We have to have these inputs for manual execution
> >>
> >>  Thanks
> >>
> >>
> >>
> >>
> >> --------------------------------------------------------------------
> -
> >>  To unsubscribe, e-mail: [email protected]  For
> >> additional commands, e-mail: [email protected]
> >>
> >>
> >
> > Scot P. Floess             RHCT  (Certificate Number 605010084735240)
> > Chief Architect FlossWare  http://sourceforge.net/projects/flossware
> >                            http://flossware.sourceforge.net
> >                            https://github.com/organizations/FlossWare
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected] For
> additional
> > commands, e-mail: [email protected]
> >
> >
> 
> Scot P. Floess             RHCT  (Certificate Number 605010084735240)
> Chief Architect FlossWare  http://sourceforge.net/projects/flossware
>                             http://flossware.sourceforge.net
>                             https://github.com/organizations/FlossWare
> 
> ---------------------------------------------------------------------
> 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.