Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use conditions using the <code>&lt;fail&gt;</code> task:</p> <pre><code>&lt;fail message="Property &amp;quot;foo&amp;quot; needs to be set to a value"&gt; &lt;condition&gt; &lt;or&gt; &lt;equals arg1="${foo}" arg2=""/&gt; &lt;not&gt; &lt;isset property="foo"/&gt; &lt;/not&gt; &lt;/or&gt; &lt;/condition&gt; </code></pre> <p></p> <p>This is equivalent to saying <em><code>if (not set ${foo} or ${foo} = "")</code></em> is pseudocode. You have to read the XML conditions from the inside out.</p> <p>You could have used the <code>&lt;unless&gt;</code> clause on the <code>&lt;fail&gt;</code> task if you only cared whether or not the variable was set, and not whether it has an actual value.</p> <pre><code>&lt;fail message="Property &amp;quot;foo&amp;quot; needs to be set" unless="foo"/&gt; </code></pre> <p>However, this won't fail if the property is set, but has no value.</p> <hr> <p>There's a trick that can make this simpler</p> <pre><code> &lt;!-- Won't change the value of `${foo}` if it's already defined --&gt; &lt;property name="foo" value=""/&gt; &lt;fail message="Property &amp;quot;foo&amp;quot; has no value"&gt; &lt;condition&gt; &lt;equals arg1="${foo}" arg2=""/&gt; &lt;/condition&gt; &lt;/fail&gt; </code></pre> <p>Remember that I can't reset a property! If <code>${foo}</code> already has a value, the <code>&lt;property&gt;</code> task above won't do anything. This way, I can eliminate the <code>&lt;isset&gt;</code> condition. It might be nice since you have three properties:</p> <pre><code>&lt;property name="foo" value=""/&gt; &lt;property name="bar" value=""/&gt; &lt;property name="fubar" value=""/&gt; &lt;fail message="You broke the build, you dufus"&gt; &lt;condition&gt; &lt;or&gt; &lt;equals arg1="${foo}" arg2=""/&gt; &lt;equals arg1="${bar}" arg2=""/&gt; &lt;equals arg1="${fubar}" arg2=""/&gt; &lt;/or&gt; &lt;/condition&gt; &lt;/fail&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload