ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Swayam Prakash Vemuri <vemuriswa...@gmail.com>
Subject Re: Passing multiple targets from one build.xml to another build.xml
Date Fri, 02 Mar 2012 16:13:41 GMT
Thanks a TON Chris.
The below one worked perfectly

Thanks
Swayam

On Thu, Mar 1, 2012 at 10:37 PM, Holman, Chris <Chris.Holman@bskyb.com>wrote:

> This is how I'd approach the problem.
> (I haven't tried it, so there may be some bugs in there):
>
> <project name="topLevel">
>    <property name="product" value="xyz" description="Default to product
> xyz. Overload in command line if required" />
>
>    <property name="abcd" value="build/esrst/build_abcd.xml" />
>    <property name="xyz" value="build/ccp/build_xyz.xml" />
>
>    <macrodef name="copyProperty">
>        <attribute name="property" />
>        <attribute name="srcProperty" />
>        <sequential>
>            <fail unless="@{srcProperty}" message="There isnt a property
> called @{srcProperty}" />
>            <property name="@{property}" value="${@{srcProperty}}"
>        </sequential>
>    </macrodef>
>
>    <copyProperty property="BUILD_FILE" srcProperty="${product}" />
>
>    <target name="javabuild" >
>        <ant antfile="${BUILD_FILE}" inheritAll="true" target="javabuild" />
>    </target>
>
>    <target name="deploy" >
>        <ant antfile="${BUILD_FILE}" inheritAll="true" target="deploy" />
>    </target>
>
> </project>
>
>
>
> Regards,
> Chris Holman, Chordiant/STAR Build Engineer
> gTalk: chris.d.holman@googlemail.com
> LinkedIn: http://uk.linkedin.com/in/chrisdholman
> -----Original Message-----
> From: Swayam Prakash Vemuri [mailto:vemuriswayam@gmail.com]
> Sent: 01 March 2012 16:37
> To: Ant Users List
> Subject: Re: Passing multiple targets from one build.xml to another
> build.xml
>
> What I meant by I have only build xml, is I dont have build_abcd.xml and
> neither I have build_xyz.xml.
> Say that I have just build.xml with some targets defined.
>
> And Iam not invoking any other build xml from this build.xml, that being
> the case
> ant understands howmany ever targets I give dynamically.
>
> The moment I invoke one build.xml from other, ant is not able to understand
> any of the targets passed unless I explicitly define
> each of the target as you mentioned.
>
> Just like in Java where we have varargs, ant should be having something,
> otherwise in the simple case(where Iam not invoking one build from other)
> how come ant was able to understand multiple dynamic targets, whereas the
> same its not able to understand in the case of invoking one build from
> another
>
> thanks
> Swayam
>
> On Thu, Mar 1, 2012 at 9:56 PM, Swayam Prakash Vemuri <
> vemuriswayam@gmail.com> wrote:
>
> > Thanks much Chris for the quick reply.
> > Full marks to your reasoning, yes by mistake I have not specified any
> > target it was invoking default target which was deploy.
> >
> > But had it been this way, say that, Iam not invoking two different build
> > xmls, say I have only one build xml, in that case
> > I am able to give multiple targets dynamically and ant is able to
> > understand, why the same is not possible when Iam invoking
> > one  build xml from another. Why in the latter case ant is not able to
> get
> > the targets dynamically
> >
> > Thanks
> > Swayam
> >
> >
> > On Thu, Mar 1, 2012 at 6:06 PM, Holman, Chris <Chris.Holman@bskyb.com
> >wrote:
> >
> >> The ant task calls the default target of the project being called if you
> >> haven't declared a target in the ant task (that's probably why deploy
> >> target is running).
> >> If the targets are static you can do this:
> >>
> >> <if>
> >>        <equals arg1="${product}" arg2="abcd"/>
> >>        <then>
> >>            <echo message="Build for the product abcd"/>
> >>            <ant antfile="build/esrst/build_abcd.xml" inheritAll="true" >
> >>                   <target>javabuild</target>
> >>                  <target>deploy</target>
> >>             </ant>
> >>        </then>
> >>        <else>
> >>        <echo message="Build for the product  xyz"/>
> >>            <echo message="Build for the product xyz" />
> >>            <ant antfile="build/ccp/build_xyz.xml" inheritAll="true" >
> >>                   <target>javabuild</target>
> >>                  <target>deploy</target>
> >>            </ant>
> >>        </else>
> >>  </if>
> >>
> >> It's a bit more tricky if the targets are dynamic, i.e. can change in
> >> each invocation; because there are multiple targets.
> >> In this case you could declare a wrapper target that invoked both (a bit
> >> messy if you have many possible target combinations) and pass the name
> of
> >> this target as a property on the cmd line and use that property in a
> single
> >> target attribute.
> >>
> >> <if>
> >>        <equals arg1="${product}" arg2="abcd"/>
> >>        <then>
> >>            <echo message="Build for the product abcd"/>
> >>             <ant antfile="build/esrst/build_abcd.xml" inheritAll="true"
> >> target="${BUILD_TARGET}" />
> >>         </then>
> >>        <else>
> >>        <echo message="Build for the product  xyz"/>
> >>            <echo message="Build for the product xyz" />
> >>             <ant antfile="build/ccp/build_xyz.xml" inheritAll="true"
> >> target="${BUILD_TARGET}" />
> >>        </else>
> >>  </if>
> >>
> >> Then invoke this using
> >>
> >> ant -Dproduct=abcd -DBUILD_TARGET=build_and_deploy
> >>
> >> Regards,
> >> Chris Holman
> >>
> >> -----Original Message-----
> >> From: Swayam Prakash Vemuri [mailto:vemuriswayam@gmail.com]
> >> Sent: 01 March 2012 12:14
> >> To: user@ant.apache.org
> >> Subject: Passing multiple targets from one build.xml to another
> build.xml
> >>
> >> Hi All,
> >>
> >> In my topmost build.xml Iam doing below
> >>
> >> <if>
> >>        <equals arg1="${product}" arg2="abcd"/>
> >>        <then>
> >>            <echo message="Build for the product abcd"/>
> >>            <ant antfile="build/esrst/build_abcd.xml" inheritAll="true" >
> >>            </ant>
> >>        </then>
> >>        <else>
> >>        <echo message="Build for the product  xyz"/>
> >>            <echo message="Build for the product xyz" />
> >>            <ant antfile="build/ccp/build_xyz.xml" inheritAll="true" >
> >>            </ant>
> >>        </else>
> >>    </if>
> >>
> >> Now I am invoking ant as below
> >>
> >> ant -Dproduct=abcd javabuild deploy
> >>
> >> It is executing build_abcd.xml but it only does 'deploy' its not calling
> >> the first target that is 'javabuild'.
> >>
> >> So my question is how can I pass javabuild and deploy to build_abcd.xml
> or
> >> build_xyz.xml. can someone pleas help me out
> >>
> >> thanks
> >> Swayam
> >>
> >> Information in this email including any attachments may be privileged,
> >> confidential and is intended exclusively for the addressee. The views
> >> expressed may not be official policy, but the personal views of the
> >> originator. If you have received it in error, please notify the sender
> by
> >> return e-mail and delete it from your system. You should not reproduce,
> >> distribute, store, retransmit, use or disclose its contents to anyone.
> >> Please note we reserve the right to monitor all e-mail communication
> >> through our internal and external networks. SKY and the SKY marks are
> trade
> >> marks of British Sky Broadcasting Group plc and are used under licence.
> >> British Sky Broadcasting Limited (Registration No. 2906991), Sky
> >> Interactive Limited (Registration No. 3554332), Sky-In-Home Service
> Limited
> >> (Registration No. 2067075) and Sky Subscribers Services Limited
> >> (Registration No. 2340150) are direct or indirect subsidiaries of
> British
> >> Sky Broadcasting Group plc (Registration No. 2247735). All of the
> companies
> >> mentioned in this paragraph are incorporated in England and Wales and
> share
> >> the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >> For additional commands, e-mail: user-help@ant.apache.org
> >>
> >>
> >
>
> Information in this email including any attachments may be privileged,
> confidential and is intended exclusively for the addressee. The views
> expressed may not be official policy, but the personal views of the
> originator. If you have received it in error, please notify the sender by
> return e-mail and delete it from your system. You should not reproduce,
> distribute, store, retransmit, use or disclose its contents to anyone.
> Please note we reserve the right to monitor all e-mail communication
> through our internal and external networks. SKY and the SKY marks are trade
> marks of British Sky Broadcasting Group plc and are used under licence.
> British Sky Broadcasting Limited (Registration No. 2906991), Sky
> Interactive Limited (Registration No. 3554332), Sky-In-Home Service Limited
> (Registration No. 2067075) and Sky Subscribers Services Limited
> (Registration No. 2340150) are direct or indirect subsidiaries of British
> Sky Broadcasting Group plc (Registration No. 2247735). All of the companies
> mentioned in this paragraph are incorporated in England and Wales and share
> the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message