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.

whichresource.html 4.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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>Whichresource Task</title>
  20. </link>
  21. </meta>
  22. </head>
  23. <body>
  24. <h2><a name="whichresource">Whichresource</a></h2>
  25. <h3>Description</h3>
  26. <p>
  27. Find a class or resource on the supplied classpath, or the
  28. system classpath if none is supplied.
  29. The named property is set if the item can be found.
  30. For example:
  31. </p>
  32. <blockquote><pre>
  33. &lt;whichresource resource="/log4j.properties" property="log4j.url" &gt;
  34. </pre></blockquote>
  35. <h3>Parameters</h3>
  36. <table border="1" cellpadding="2" cellspacing="0">
  37. <tr>
  38. <td valign="top"><b>Attribute</b></td>
  39. <td valign="top"><b>Description</b></td>
  40. <td align="center" valign="top"><b>Required</b></td>
  41. </tr>
  42. <tr>
  43. <td valign="top">property</td>
  44. <td valign="top">
  45. The property to fill with the URL of the resource of class.
  46. </td>
  47. <td valign="top" align="center">Yes</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">class</td>
  51. <td valign="top">
  52. The name of the class to look for.
  53. </td>
  54. <td valign="top" align="center" rowspan="2">Exactly one of these.</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">resource</td>
  58. <td valign="top">
  59. The name of the resource to look for.
  60. </td>
  61. </tr>
  62. <tr>
  63. <td valign="top">classpath</td>
  64. <td valign="top">
  65. The classpath to use when looking up <code>class</code>
  66. or <code>resource</code>.
  67. </td>
  68. <td align="center" valign="top">No</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">classpathref</td>
  72. <td valign="top">
  73. The classpath to use, given as a
  74. <a href="../using.html#references">reference</a>
  75. to a path defined elsewhere.
  76. <em>Since Ant 1.7.1.</em>
  77. </td>
  78. <td align="center" valign="top">No</td>
  79. </tr>
  80. </table>
  81. <h3>Parameters specified as nested elements</h3>
  82. <h4>classpath</h4>
  83. <p>
  84. <code>Whichresource</code>'s <code>classpath</code> attribute is a
  85. <a href="../using.html#path">path-like structure</a> and can also be
  86. set via a nested <code>&lt;classpath&gt;</code> element.
  87. </p>
  88. <h3>Examples</h3>
  89. <p>
  90. The following shows using a classpath reference.
  91. </p>
  92. <blockquote><pre>
  93. &lt;path id="bsf.classpath"&gt;
  94. &lt;fileset dir="${user.home}/lang/bsf" includes="*.jar"/&gt;
  95. &lt;/path&gt;
  96. &lt;whichresource property="bsf.class.location"
  97. class="org.apache.bsf.BSFManager"
  98. classpathref="bsf.classpath"/&gt;
  99. &lt;echo&gt;${bsf.class.location}&lt;/echo&gt;
  100. </pre></blockquote>
  101. <p>
  102. The following shows using a nested classpath.
  103. </p>
  104. <blockquote><pre>
  105. &lt;whichresource
  106. property="ant-contrib.antlib.location"
  107. resource="net/sf/antcontrib/antlib.xml"&gt;
  108. &lt;classpath&gt;
  109. &lt;path path="f:/testing/ant-contrib/target/ant-contrib.jar"/&gt;
  110. &lt;/classpath&gt;
  111. &lt;/whichresource&gt;
  112. &lt;echo&gt;${ant-contrib.antlib.location}&lt;/echo&gt;
  113. </pre></blockquote>
  114. </body>
  115. </html>