• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use If action in Ant

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello World,
I want to use the replace action on some conditions, I am not able to do the conditioning part.
Kindly help me in this. I do not want to use Ant Contrib for this.
I want something like this -

<if environment-type="Dev">
<replace file="${dir.src}/log4j.xml" token="@@@" value="DEBUG"/>
</if>

<if environment-type="QA">
<replace file="${dir.src}/log4j.xml" token="@@@" value="INFO"/>
</if>

<if environment-type="Prod">
<replace file="${dir.src}/log4j.xml" token="@@@" value="WARN"/>
</if>

Thanks a lot in advance.
Regards,
Sachin Dare.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a lot more code without Ant contrib. Here's the pattern. You use one target to set the conditional properties. Then you use another target for the replace. You need a separate target for each if statement you want. Then you need to tie them all together in order.

 
reply
    Bookmark Topic Watch Topic
  • New Topic