ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: Conditional logic in ANT build scripts
Date Fri, 11 Apr 2003 06:39:22 GMT
Ant-Contrib:
  Homepage:   http://sourceforge.net/projects/ant-contrib/
  CVS-Source:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/ant-contrib/src/n
et/sf/antcontrib/
  CVS-Manual:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/ant-contrib/manua
l/index.html
	
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/ant-contrib/ant-co
ntrib/manual/tasks/index.html
  Binary:     http://gump.covalent.net/jars/latest/ant-contrib/


Jan Matèrne

> -----Urspr√ľngliche Nachricht-----
> Von: pshenoy@netscape.com [mailto:pshenoy@netscape.com]
> Gesendet am: Donnerstag, 10. April 2003 19:00
> An: Ant Users List
> Betreff: Re: Conditional logic in ANT build scripts
> 
> An "if else" task would be of great use. Will Ant support 
> anything like 
> this in future versions? I have come across more than half a dozen 
> situations writing our 3 dozen build xmls for our project. The way I 
> generally try to get this to work is by having task "a" 
> depend on task b 
> and c and use an "if" clause in task b and "unless" clause in task c. 
> The classic case I can tell you is as below:
> 
> We use a build.xml for running automated builds. We have 
> wrapper shell 
> and perl scripts that eventually call ant with a build.xml. 
> We use one 
> build.xml for doing both branch builds and tip builds. Tip builds are 
> easy as we do not have to pass any tags to the cvs task. When 
> it comes 
> to branch builds, we need to pass a tag. Now the question is, 
> if we had 
> an if else task, this was pretty easy. Something like this
> <if tag not null>
>    <cvs ....... tag="cvstag">
> <else>
>    <cvs ......>
> </if>
> 
> In the absence of this, what I did was, pass an additional isBranch 
> property with the tag to the build.xml. So, the command line 
> looks like this
> 
> ant -Dcvstag=branch_tag -DisBranch=true
> 
> and then I have this task
> 
> <target name="checkout" depends="checkout_notag, checkout_with_tag"/>
> <target name="checkout_notag" unless="isBranch">
>    <cvs .........>
> </target>
> <target name="checkout_with_tag" if="isBranch">
>    <cvs................>
> </target>
> 
> So, in yor case, if it s just two scenarios, you can do the 
> same. This 
> fails, when you have more than two conditions.
> 
> 
> Andrew Zeon wrote:
> 
> >Hi, 
> >
> >I know that the 'if' attribute in the 'target' task can be 
> used to determine
> >whether or not a target should be executed. However, it is 
> my understanding
> >that the 'if' attribute does not take into consideration the 
> value of the
> >property... it merely checks its presence. Is there a way I 
> can dynamically
> >determine whether or not a target is to be executed 
> according to the actual
> >value of a property?
> >
> >The reason why I ask is I have a build script, but that 
> build script's
> >behaviour has to be different for different environments. 
> This is how I
> >invoke my script:
> >
> >"ant -Denvironment=dev dist"
> >
> >for the development environment
> >
> >"ant -Denvironment=staging dist "
> >
> >for the staging environment
> >
> >ant -D environment=live dist
> >
> >for the live environment
> >
> >
> >I have targets which should only be run for specific 
> environments... how can
> >I do this?
> >
> >Thanks.
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >For additional commands, e-mail: user-help@ant.apache.org
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> 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