Antでファイルの存在チェック
- available タスクで存在チェック。
- target の if 属性で分岐。
<?xml version="1.0" encoding="Shift_JIS" ?> <project name="file.exist.sample" default="main"> <target name="main"> <available file="hogehoge.txt" property="have.resources" /> <antcall target="file-is-existing" /> </target> <target name="file-is-existing" if="have.resources"> <echo message="File is existing"/> </target> </project>
実行結果:
main: file-is-existing: [echo] File is existing BUILD SUCCESSFUL Total time: 0 seconds