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 Thu, 01 Mar 2012 16:26:00 GMT
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
>
>

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