供給されたクラスパスにあるクラスやリソースを見つける。供給されなかった場合には、システムクラスパスから見つける。名前付きプロパティは、項目が見つかった場合に設定される。例
<whichresource resource="/log4j.properties" property="log4j.url"/>
| 属性 | 説明 | 必須 |
|---|---|---|
| property | クラスやリソースの URL を格納するプロパティを指定。 | はい |
| class | 検索するクラス名。 | 次のいずれか 1 つ |
| resource | 検索するリソース名。 | |
| classpath | class または resource を検索するときに使用するクラスパス。 | いいえ |
| classpathref | 使用するクラスパス。他の場所で定義されたパスへの 参照 として指定される。Apache Ant 1.7.1 以降。 | いいえ |
Whichresource の classpath 属性は パスライク構造 であり、ネストされた <classpath> 要素を介して設定することもできる。
クラスパス参照を使用する例を次に示す。
<path id="bsf.classpath">
<fileset dir="${user.home}/lang/bsf" includes="*.jar"/>
</path>
<whichresource property="bsf.class.location"
class="org.apache.bsf.BSFManager"
classpathref="bsf.classpath"/>
<echo>${bsf.class.location}</echo>
ネストされたクラスパスを使用する例を次に示す。
<whichresource property="ant-contrib.antlib.location"
resource="net/sf/antcontrib/antlib.xml">
<classpath>
<path path="f:/testing/ant-contrib/target/ant-contrib.jar"/>
</classpath>
</whichresource>
<echo>${ant-contrib.antlib.location}</echo>