Created
October 9, 2012 18:44
-
-
Save ykst/3860637 to your computer and use it in GitHub Desktop.
Ant copy task (with PHP syntax checking)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="Build Test" default="all" basedir="." > | |
<target name="all" depends="deploy"/> | |
<property name="tgtdir" value="/tmp"/> | |
<!-- パーミッションを気にする場合はcpを使うのが楽そう。 | |
--parentがサポートされてない場合はcopyタスクとchownで頑張らないとかも | |
<target name="deploy_apps" > | |
<apply executable="cp" dest="/tmp" parallel="false"> | |
<arg value="--parent"/> | |
<srcfile/> | |
<fileset dir="${basedir}/apps" includes="**/*.php" /> | |
<targetfile/> | |
<mapper type="identity"/> | |
</apply> | |
</target> | |
--> | |
<target name="deploy" depends="deploy_apps, deploy_tests"/> | |
<!-- サブターゲットにパラメータを渡して汎用化してみるテスト --> | |
<target name="deploy_apps"> | |
<antcall target="deploy_sub"> | |
<param name="deploy_dir" value="apps"/> | |
</antcall> | |
</target> | |
<target name="deploy_tests"> | |
<antcall target="deploy_sub"> | |
<param name="deploy_dir" value="tests"/> | |
</antcall> | |
</target> | |
<target name="deploy_sub"> | |
<antcall target="syntax_check"> | |
</antcall> | |
<!-- copyタスクはターゲットに無いディレクトリも作ってくれる --> | |
<copy todir="${tgtdir}"> | |
<fileset dir="${basedir}" includes="${deploy_dir}/**/*.php"> | |
<depend targetdir="${tgtdir}" /> | |
</fileset> | |
</copy> | |
</target> | |
<!-- modifiedセレクタは失敗した時に変更を覚えてくれないので、 | |
ターゲットがある場合はdependが楽であるように思える。 | |
cache.propertiesを置き換えるやり方もあるようだが、あまりやりたくない。 --> | |
<target name="syntax_check"> | |
<!-- ローカル変数気分でpropertyを使える --> | |
<property name="extension" value="php"/> | |
<apply executable="php" failonerror="true"> | |
<arg value="-l"/> | |
<fileset dir="${basedir}" includes="${deploy_dir}/**/*.${extension}"> | |
<depend targetdir="${tgtdir}" /> | |
</fileset> | |
</apply> | |
</target> | |
<target name="clean"> | |
<!-- verbose付けないと消されたかわからない --> | |
<delete verbose="true"> | |
<fileset dir="${tgtdir}/apps" includes="**/*.php" /> | |
<fileset dir="${tgtdir}/tests" includes="**/*.php" /> | |
</delete> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tested by ant 1.8.2 on OSX