Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to do conditional execution ofa target

 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I have an ant build file from which I would call another task defined in another build file. While calling another ant, I'm supplying a property say "execute" set to true. I need to have the task executed only when execute == "true".



createTar.xml


I need to have packageZip target to be executed only when property "execute" is true. I tried options like "if", "unless" but not successful so far. Because I do not want to have impact on other build files that are calling createTar. I see recommendations on using condition, but not sure how to do that.
 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this resolved using <condition><istrue> elements.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar, posting the ant script for the solution will help others when they come across your post in the future.
 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:Kumar, posting the ant script for the solution will help others when they come across your post in the future.


That is true.

Below is what I did to solve my problem.

buildConfig.xml will call createTar.xml. I need to control certain steps of execution based on the parameter sent from buildConfig.xml

so in my buildConfig.xml I added a parameter called "NEEDZIP" like below



Now in my createTar.xml, I did as following



I'm not sure, if this is a good approach, but could manage it for my requirement.. If anybody having a better approach, please share it here.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic