Ant has specifically tried to avoid getting into "if" and "while" constructs, but they are necessary sometimes. Look at the task, which lets you set a property if certain conditions are true. You can then invoke a task which only executes if that property exists in order to achieve conditional execution.