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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us"/>
  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><a name="if_and_unless">If And Unless</a></h1>
  23. <p>Since Ant 1.9.1 it is possible to add if and unless 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. <blockquote><pre>
  26. xmlns:if=&quot;ant:if&quot;
  27. xmlns:unless=&quot;ant:unless&quot;
  28. </pre>
  29. </blockquote>
  30. <p>The if and unless namespaces support the following 3 conditions :
  31. <ul>
  32. <li>true</li>true if the value of the attribute evaluates to true
  33. <li>blank</li>true if the value of the attribute is null or empty
  34. <li>set</li>true if the specified property is set
  35. </ul></p>
  36. <blockquote>
  37. <pre>
  38. &lt;project name=&quot;tryit&quot;
  39. xmlns:if=&quot;ant:if&quot;
  40. xmlns:unless=&quot;ant:unless&quot;
  41. &gt;
  42. &lt;exec executable=&quot;java&quot;&gt;
  43. &lt;arg line=&quot;-X&quot; if:true=&quot;${showextendedparams}&quot;/&gt;
  44. &lt;arg line=&quot;-version&quot; unless:true=&quot;${showextendedparams}&quot;/&gt;
  45. &lt;/exec&gt;
  46. &lt;condition property=&quot;onmac&quot;&gt;
  47. &lt;os family=&quot;mac&quot;/&gt;
  48. &lt;/condition&gt;
  49. &lt;echo if:set=&quot;onmac&quot;&gt;running on MacOS&lt;/echo&gt;
  50. &lt;echo unless:set=&quot;onmac&quot;&gt;not running on MacOS&lt;/echo&gt;
  51. &lt;/project&gt;
  52. </pre>
  53. </blockquote>
  54. </body>
  55. </html>