File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes How to use If action in Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to use If action in Ant" Watch "How to use If action in Ant" New topic
Author

How to use If action in Ant

Sachin Dare
Greenhorn

Joined: May 04, 2004
Posts: 12
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.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29247
    
139

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.



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use If action in Ant
 
Similar Threads
JBuilder 9 with JDK1.5.0 beta
ant waits for user input
append a batch file
Case sensitive Issue when using Ant Replace task
generated WSDL through wsgen and REPLACE_WITH_ACTUAL_URL