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.

resourcecount.html 3.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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>ResourceCount Task</title>
  20. </head>
  21. <body>
  22. <h2>ResourceCount</h2>
  23. <h3>Description</h3>
  24. <p>Display or set a property containing the size of a nested
  25. <a href="../CoreTypes/resources.html#collection">Resource Collection</a>.
  26. Can also be used as a condition. <b>Since Ant 1.7</b></p>
  27. <h3>Parameters</h3>
  28. <table border="1" cellpadding="2" cellspacing="0">
  29. <tr>
  30. <td valign="top"><b>Attribute</b></td>
  31. <td valign="top"><b>Description</b></td>
  32. <td align="center" valign="top"><b>Required</b></td>
  33. </tr>
  34. <tr>
  35. <td valign="top">property</td>
  36. <td valign="top">The property to set. If omitted the results are written
  37. to the log. Ignored when processing as a condition.</td>
  38. <td valign="top" align="center">No</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">refid</td>
  42. <td valign="top">A <a href="../using.html#references">reference</a>
  43. to a Resource Collection.</td>
  44. <td valign="top" align="center">
  45. Yes, unless a nested Resource Collection is supplied
  46. </td>
  47. </tr>
  48. <tr>
  49. <td valign="top">count</td>
  50. <td valign="top">Comparison count for processing as a condition.</td>
  51. <td valign="top" align="center">Yes, in condition mode</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">when</td>
  55. <td valign="top">Comparison type: "equal", "eq", "greater", "gt", "less",
  56. "lt", "ge" (greater or equal), "ne" (not equal), "le" (less or equal)
  57. for use when operating as a condition.</td>
  58. <td valign="top" align="center">No; default is "equal"</td>
  59. </tr>
  60. </table>
  61. <h3>Parameters specified as nested elements</h3>
  62. <h4>Resource Collection</h4>
  63. <p>A single
  64. <a href="../CoreTypes/resources.html#collection">Resource Collection</a>
  65. should be specified via a nested element or the <code>refid</code> attribute.
  66. </p>
  67. <h3>Examples</h3>
  68. <pre>&lt;resourcecount property=&quot;count.foo&quot;&gt;
  69. &lt;filelist dir=&quot;.&quot; files=&quot;foo,bar&quot; /&gt;
  70. &lt;/resourcecount&gt;
  71. </pre>
  72. <p>Stores the number of resources in the specified filelist (two)
  73. in the property named <i>count.foo</i>.</p>
  74. <pre>
  75. &lt;project&gt;
  76. &lt;property name=&quot;file&quot; value=&quot;${ant.file}&quot;/&gt;
  77. &lt;resourcecount property=&quot;file.lines&quot;&gt;
  78. &lt;tokens&gt;
  79. &lt;concat&gt;
  80. &lt;filterchain&gt;
  81. &lt;tokenfilter&gt;
  82. &lt;linetokenizer/&gt;
  83. &lt;/tokenfilter&gt;
  84. &lt;/filterchain&gt;
  85. &lt;fileset file=&quot;${file}&quot;/&gt;
  86. &lt;/concat&gt;
  87. &lt;/tokens&gt;
  88. &lt;/resourcecount&gt;
  89. &lt;echo&gt;The file '${file}' has ${file.lines} lines.&lt;/echo&gt;
  90. &lt;/project&gt;
  91. </pre>
  92. <p>Stores the number of lines of the current buildfile in the property <tt>file.lines</tt>.
  93. Requires Ant 1.7.1+ as &lt;concat&gt; has to be resource.</p>
  94. </body>
  95. </html>