Description

FileIteratorは「あるディレクトリ配下にあるディレクトリ又はファイルに対して処理を行う」ために作成されたantのタスクです。
現在はあるディレクトリ「直下」にあるディレクトリ又はファイルのみをサポートしますが、近いうちに再帰的に指定されたレベルまでの走査をサポートする予定です。

License

FileIteratorはApache Software Licenseに基づきます。

Parameters

Attribute Description Required
path 反復処理を行いたいディレクトリ(※又はファイル)のフルパスを記述します。
filesetエレメントをFileIterator内部で使用した場合はpath属性は無視されます。
No
file 指定したディレクトリ配下にあるファイルに対して処理を行いたい場合はtrueを、
ファイルを無視したい場合はfalseを指定します。
No
Default="true"
dir 指定したディレクトリ配下にあるディレクトリに対して処理を行いたい場合はtrueを、
ディレクトリを無視したい場合はfalseを指定します。
No
Default="true"
fileKey 指定したフォルダ配下にファイルが発見された場合に環境変数にセットされるファイル名のキーを指定します No
Default="file"
dirKey 指定したフォルダ配下にディレクトリが発見された場合に環境変数にセットされるディレクトリ名のキーを指定します No
Default="dir"

Nested Elements

  • fileset

  • ディレクトリやファイルの指定を細かく設定したい場合にfilesetを使用します。
    filesetを使用した場合はpath属性は無視されます。

  • ant

  • 発見されたファイルやディレクトリに対して行う何らかの処理はantタスクを使用して行います。
Examples

Example1.
<?xml version="1.0" encoding="Shift_JIS"?>
<project name="example1" default="main" basedir=".">
<taskdef name="fi" classname="tv.dacha.ebisu.ant.tasks.FileIterator"/>
<target name="main">
<fi path="C:\"> <ant target="file"/> <ant target="dir"/>
</fi> </target> <target name="file" if="file"> <echo message="${file}"/> </target> <target name="dir" if="dir"> <echo message="${dir}"/> </target> </project>

Example2.
<?xml version="1.0" encoding="Shift_JIS"?>
<project name="example1" default="main" basedir=".">
<taskdef name="fi" classname="tv.dacha.ebisu.ant.tasks.FileIterator"/>
<target name="main">
<fi> <fileset dir="C:\WINNT"> <include name="*.ini"/> </fileset> <ant target="file"/> </fi> </target> <target name="file" if="file"> <echo message="${file}"/> </target> </project>

Example3.
<?xml version="1.0" encoding="Shift_JIS"?>
<project name="example1" default="main" basedir=".">
<taskdef name="fi" classname="tv.dacha.ebisu.ant.tasks.FileIterator"/>
<target name="main">
<fi file="true" dir="false" path="C:\WINNT"> <ant target="file"/> <ant target="dir"/> </fi> </target> <target name="file" if="file"> <echo message="${file}"/> </target>
<target name="dir" if="dir"> <echo message="${dir}"/> </target> </project>

Example4.
<?xml version="1.0" encoding="Shift_JIS"?>
<project name="example1" default="main" basedir=".">
<taskdef name="fi" classname="tv.dacha.ebisu.ant.tasks.FileIterator"/>
<target name="main">
<fi file="false" dirKey="dir_key" path="C:\WINNT"> <ant target="dir"/><!--キーがdir_keyなのでこれは実行されない--> <ant target="dirkey"/> </fi> </target> <target name="dir" if="dir"> <echo message="${dir}"/> </target> <target name="dirkey" if="dir_key"> <echo message="${dir_key}"/> </target>
</project>

Example5.
<?xml version="1.0" encoding="Shift_JIS"?>
<project name="example1" default="main" basedir=".">
<taskdef name="fi" classname="tv.dacha.ebisu.ant.tasks.FileIterator"/>
<target name="main">
<fi path="C:\MyProject\META-INF\ejb-jar.xml" fileKey="isEJB"> <ant target="isEJB"/> </fi> </target> <target name="isEJB" if="isEJB"> <echo message="${isEJB} is EJB Project"/> </target> </project>

 


Copyright © 2003, ebisu project. All rights reserved.