title: Execute Ant task just if a condition is met
body: <p>I need to execute an Ant task within a specific target only if a condition is met.</p>
  
  <p>I found a way to define the condition at the target level, but not at the task level. I have also found a contribution that implements an <a href="http://ant-contrib.sourceforge.net/tasks/tasks/if.html" rel="noreferrer">IF task</a>.</p>
  
  <p>My question is, are you aware of any way to achieve this objective with standard Ant tasks?</p>
  
  <p>Longer explanation: I am trying to start Tomcat Server in case it is stopped. To detect if it is stopped I use following code:</p>
  
  <pre><code>&lt;echo message="Checking whether Tomcat is running"/&gt;
  &lt;condition property="tomcat.running"&gt;
    &lt;socket server="${tomcat.host}" port="${tomcat.port}"/&gt; 
  &lt;/condition&gt;
  </code></pre>
  
  <p>So my next task in this target, is an exec task that should be executed only if <code>${tomcat.running}</code> is false. And as I said, I don't want to add a single task in a target to use the unless property.</p>