You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ifunless.html 2.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="stylesheets/style.css"/>
  19. <title>If and Unless on all tasks/nested elements</title>
  20. </head>
  21. <body>
  22. <h1 id="if_and_unless">If And Unless</h1>
  23. <p><em>Since Ant 1.9.1</em>, it is possible to add <var>if</var> and <var>unless</var> attributes on all tasks and nested elements using special namespaces.</p>
  24. <p>In order to use this feature you need to add the following namespace declarations</p>
  25. <pre>
  26. xmlns:if=&quot;ant:if&quot;
  27. xmlns:unless=&quot;ant:unless&quot;</pre>
  28. <p>The <code>if</code> and <code>unless</code> namespaces support the following 3 conditions:</p>
  29. <dl>
  30. <dt><q>true</q></dt><dd>true if the value of the attribute evaluates to true</dd>
  31. <dt><q>blank</q></dt><dd>true if the value of the attribute is null or empty</dd>
  32. <dt><q>set</q></dt><dd>true if the specified property is set</dd>
  33. </dl>
  34. <pre>
  35. &lt;project name=&quot;tryit&quot;
  36. xmlns:if=&quot;ant:if&quot;
  37. xmlns:unless=&quot;ant:unless&quot;&gt;
  38. &lt;exec executable=&quot;java&quot;&gt;
  39. &lt;arg line=&quot;-X&quot; if:true=&quot;${showextendedparams}&quot;/&gt;
  40. &lt;arg line=&quot;-version&quot; unless:true=&quot;${showextendedparams}&quot;/&gt;
  41. &lt;/exec&gt;
  42. &lt;condition property=&quot;onmac&quot;&gt;
  43. &lt;os family=&quot;mac&quot;/&gt;
  44. &lt;/condition&gt;
  45. &lt;echo if:set=&quot;onmac&quot;&gt;running on MacOS&lt;/echo&gt;
  46. &lt;echo unless:set=&quot;onmac&quot;&gt;not running on MacOS&lt;/echo&gt;
  47. &lt;/project&gt;</pre>
  48. </body>
  49. </html>