2 <project name="kohana" default="help">
3 <property environment="env"/>
5 <property name="basedir" value="${project.basedir}"/>
6 <property name="builddir" value="${basedir}/build"/>
8 <property name="branch" value="3.3/develop"/>
10 <property name="submodules" value="system,modules/auth,modules/cache,modules/codebench,modules/database,modules/image,modules/orm,modules/unittest,modules/userguide"/>
12 <!-- Shows the help message -->
14 <echo message="General Targets"/>
15 <echo message="==============="/>
16 <echo message="phing test Run unit tests."/>
17 <echo message="phing test-log Run unit tests with logging enabled."/>
18 <echo message="phing phpcs Run phpcs."/>
19 <echo message="phing phpcs-log Run phpcs with logging enabled."/>
20 <echo message="phing phpmd Run phpmd."/>
21 <echo message="phing phpmd-log Run phpmd with logging enabled."/>
22 <echo message="phing phpcb-log Run phpcb with logging enabled."/>
24 <echo message="Kohana Developer Targets"/>
25 <echo message="========================"/>
26 <echo message="phing dev-setup Setup for development on Kohana itself."/>
27 <echo message="phing git-status Show the git status of each submodule."/>
28 <echo message="phing git-checkout Checkout a branch accross all submodules."/>
29 <echo message="phing git-pull Perform a pull for each submodule."/>
30 <echo message="phing git-push Perform a push for each submodule."/>
32 <echo message="Misc Targets"/>
33 <echo message="============"/>
34 <echo message="phing ci Alias task for continuous integration servers"/>
35 <echo message="phing dist Build a release .zip"/>
40 <delete dir="${builddir}"/>
41 <!-- Create build directories -->
42 <mkdir dir="${builddir}/coverage"/>
43 <mkdir dir="${builddir}/logs"/>
44 <mkdir dir="${builddir}/release"/>
45 <mkdir dir="${builddir}/code-browser"/>
48 <target name="dev-setup">
49 <property name="git-checkout-branch" value="${branch}"/> <!-- Prevents git-checkout asking for a branch name -->
50 <exec command="git submodule update --init --recursive" dir="${basedir}" />
51 <phingcall target="_dev-setup-remotes" />
52 <phingcall target="git-pull" />
53 <phingcall target="git-checkout" />
56 <target name="git-pull">
57 <phingcall target="_git-pull">
58 <property name="dir" value="." />
60 <foreach list="${submodules}" param="dir" target="_git-pull"/>
63 <target name="_git-pull">
64 <exec command="git pull dev" dir="${dir}"/>
67 <target name="git-checkout">
70 <isset property="git-checkout-branch"/>
73 <propertyprompt propertyName="git-checkout-branch" defaultValue="${branch}" promptText="Branch name:" />
77 <phingcall target="_git-checkout">
78 <property name="dir" value="." />
81 <foreach list="${submodules}" param="dir" target="_git-checkout"/>
84 <target name="_git-checkout">
85 <exec returnProperty="git-checkout-branch-exists" command="git show-ref --quiet --verify -- 'refs/remotes/dev/${git-checkout-branch}'" dir="${dir}" passthru="true"/>
87 <equals arg1="${git-checkout-branch-exists}" arg2="0"/>
89 <exec command="git checkout --track -b ${git-checkout-branch} dev/${git-checkout-branch}" dir="${dir}" passthru="true"/>
92 <exec command="git checkout -b ${git-checkout-branch}" dir="${dir}" passthru="true"/>
97 <target name="git-push">
98 <foreach list="${submodules}" param="dir" target="_git-push"/>
99 <phingcall target="_git-push">
100 <property name="dir" value="." />
104 <target name="_git-push">
105 <exec command="git push dev" dir="${dir}" passthru="true"/>
108 <target name="git-status">
109 <foreach list="${submodules}" param="dir" target="_git-status"/>
110 <phingcall target="_git-status">
111 <property name="dir" value="." />
115 <target name="_git-status">
116 <exec command="git status" dir="${dir}" passthru="true"/>
119 <target name="_dev-setup-remotes">
120 <!-- TODO: Clean up... -->
121 <phingcall target="_dev-setup-remote">
122 <property name="repository" value="git@github.com:kohana/kohana.git" />
123 <property name="dir" value="${basedir}" />
125 <phingcall target="_dev-setup-remote">
126 <property name="repository" value="git@github.com:kohana/core.git" />
127 <property name="dir" value="${basedir}/system" />
129 <phingcall target="_dev-setup-remote">
130 <property name="repository" value="git@github.com:kohana/auth.git" />
131 <property name="dir" value="${basedir}/modules/auth" />
133 <phingcall target="_dev-setup-remote">
134 <property name="repository" value="git@github.com:kohana/cache.git" />
135 <property name="dir" value="${basedir}/modules/cache" />
137 <phingcall target="_dev-setup-remote">
138 <property name="repository" value="git@github.com:kohana/codebench.git" />
139 <property name="dir" value="${basedir}/modules/codebench" />
141 <phingcall target="_dev-setup-remote">
142 <property name="repository" value="git@github.com:kohana/database.git" />
143 <property name="dir" value="${basedir}/modules/database" />
145 <phingcall target="_dev-setup-remote">
146 <property name="repository" value="git@github.com:kohana/image.git" />
147 <property name="dir" value="${basedir}/modules/image" />
149 <phingcall target="_dev-setup-remote">
150 <property name="repository" value="git@github.com:kohana/orm.git" />
151 <property name="dir" value="${basedir}/modules/orm" />
153 <phingcall target="_dev-setup-remote">
154 <property name="repository" value="git@github.com:kohana/unittest.git" />
155 <property name="dir" value="${basedir}/modules/unittest" />
157 <phingcall target="_dev-setup-remote">
158 <property name="repository" value="git@github.com:kohana/userguide.git" />
159 <property name="dir" value="${basedir}/modules/userguide" />
163 <target name="_dev-setup-remote">
164 <exec command="git remote rm dev" dir="${dir}"/>
165 <exec command="git remote add dev ${repository}" dir="${dir}"/>
168 <!-- Run unit tests -->
170 <exec command="./vendor/phpunit/phpunit/composer/bin/phpunit --bootstrap=modules/unittest/bootstrap_all_modules.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
174 <!-- Run unit tests and generate junit.xml and clover.xml -->
175 <target name="test-log">
176 <exec command="phpunit --bootstrap=modules/unittest/bootstrap_all_modules.php --coverage-html='${builddir}/coverage' --log-junit='${builddir}/logs/junit.xml' --coverage-clover='${builddir}/logs/clover.xml' modules/unittest/tests.php" checkreturn="true" passthru="true"/>
179 <!-- Run PHP Code Sniffer -->
180 <target name="phpcs">
181 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
182 <fileset dir="${basedir}">
183 <include name="**/*.php" />
184 <exclude name="**/vendor/**" />
185 <exclude name="**/tests/**" />
187 <formatter type="default" usefile="false"/>
191 <!-- Run PHP Code Sniffer and generate checkstyle.xml -->
192 <target name="phpcs-log">
193 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
194 <fileset dir="${basedir}">
195 <include name="**/*.php" />
196 <exclude name="**/vendor/**" />
197 <exclude name="**/tests/**" />
199 <formatter type="default" usefile="false"/>
200 <formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
204 <!-- Run PHP Mess Detector -->
205 <target name="phpmd">
206 <exec command="phpmd '${basedir}' text codesize,unusedcode --exclude=**/vendor/**" passthru="true"/>
209 <!-- Run PHP Mess Detector and generate pmd.xml -->
210 <target name="phpmd-log">
211 <exec command="phpmd '${basedir}' xml codesize,unusedcode --exclude=**/vendor/** --reportfile '${builddir}/logs/pmd.xml'" passthru="true"/>
214 <!-- Run PHP CodeBrowser and generate output -->
215 <target name="phpcb-log">
216 <exec command="phpcb --exclude='${builddir}/**' --log='${builddir}/logs' --source='${basedir}' --output='${builddir}/code-browser'" passthru="true"/>
219 <!-- Build a release .zip -->
221 <!-- Pick an appropriate dist filename -->
223 <isset property="dist.filename" />
227 <!-- basically - are we running inside hudson? -->
228 <isset property="env.BUILD_NUMBER" />
229 <isset property="env.JOB_NAME" />
232 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
235 <property name="dist.filename" value="kohana" />
241 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
242 <fileset dir="${basedir}">
243 <include name="**/**"/>
245 <exclude name="*.zip" />
246 <exclude name="build/**" />
248 <exclude name="build.xml" />
249 <exclude name="phpunit.xml" />
251 <exclude name="**/.git/**" />
252 <exclude name="**/.git*" />
257 <!-- Hudson CI target -->
258 <target name="ci" depends="clean">
259 <phingcall target="test-log"/>
260 <phingcall target="pdepend-log"/>
261 <phingcall target="phpmd-log"/>
262 <phingcall target="phpcpd-log"/>
263 <phingcall target="phpcs-log"/>
264 <phingcall target="phpcb-log"/>