Merge branch '3.0.x' of github.com:kohana/kohana into 3.0.x
[kohana.git] / build.xml
blob5295decca8f7300af5427d01326e27a12882562f
1 <project name="kohana" default="test" basedir=".">
2         <!--
3         USAGE
4         =====
5         
6         Build a release.zip from a tag.
7         $ TAG=3.0.8 ant release-tag
9         Update submodules and push back. This won't affect your local clone.
10         $ ant update-submodules
12         Run unit tests
13         $ ant test
15         Run unit tests with logging enabled
16         $ ant test-log
18         -->
19         <property environment="env"/>
20         <property name="repo" value="git@github.com:kohana/kohana.git"/>
21         <property name="branch" value="3.0.x"/>
22         <property name="tag" value="${env.TAG}"/>
23         <!-- Used by update-submodules2 - not update-submodules -->
24         <property name="submodules" value="system,modules/auth,modules/cache,modules/codebench,modules/database,modules/image,modules/oauth,modules/orm,modules/pagination,modules/unittest,modules/userguide"/>
25         <property name="release-excludes" value="**/.git,**/.git*,build.xml,phpunit.xml,DEVELOPERS.md,phpunitcc,code_coverage.xml,release-tag,TESTING.md,**/tests"/>
27         <target name="clean">
28                 <!-- Clean up -->
29                 <delete dir="${basedir}/build"/>
30                 <!-- Create build directories -->
31                 <mkdir dir="${basedir}/build/coverage"/>
32                 <mkdir dir="${basedir}/build/logs"/>
33                 <mkdir dir="${basedir}/build/release"/>
34         </target>
35         
36         <!-- Run unit tests -->
37         <target name="phpunit">
38                 <exec executable="phpunit" failonerror="true"/>
39         </target>
41         <!-- Run unit tests and generate junit.xml and clover.xml -->
42         <target name="phpunit-log">
43                 <exec executable="phpunit" failonerror="true">
44                         <arg line="--coverage-html=${basedir}/build/coverage"/>
45                         <arg line="--log-junit=${basedir}/build/logs/junit.xml"/>
46                         <arg line="--coverage-clover=${basedir}/build/logs/clover.xml"/>
47                 </exec>
48         </target>
50         <!-- Update submodules -->
51         <target name="update-submodules" depends="clean,clone-branch">
52                 <!-- System -->
53                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/system">
54                         <arg line="checkout 3.0.x"/>
55                 </exec>
56                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/system">
57                         <arg line="pull"/>
58                 </exec>
59                 <!-- Auth -->
60                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/auth">
61                         <arg line="checkout master"/>
62                 </exec>
63                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/auth">
64                         <arg line="pull"/>
65                 </exec>
66                 <!-- Cache -->
67                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/cache">
68                         <arg line="checkout master"/>
69                 </exec>
70                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/cache">
71                         <arg line="pull"/>
72                 </exec>
73                 <!-- Codebench -->
74                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/codebench">
75                         <arg line="checkout master"/>
76                 </exec>
77                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/codebench">
78                         <arg line="pull"/>
79                 </exec>
80                 <!-- Database -->
81                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/database">
82                         <arg line="checkout master"/>
83                 </exec>
84                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/database">
85                         <arg line="pull"/>
86                 </exec>
87                 <!-- Image -->
88                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/image">
89                         <arg line="checkout master"/>
90                 </exec>
91                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/image">
92                         <arg line="pull"/>
93                 </exec>
94                 <!-- OAuth -->
95                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/oauth">
96                         <arg line="checkout master"/>
97                 </exec>
98                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/oauth">
99                         <arg line="pull"/>
100                 </exec>
101                 <!-- ORM -->
102                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/orm">
103                         <arg line="checkout master"/>
104                 </exec>
105                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/orm">
106                         <arg line="pull"/>
107                 </exec>
108                 <!-- Pagination -->
109                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/pagination">
110                         <arg line="checkout master"/>
111                 </exec>
112                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/pagination">
113                         <arg line="pull"/>
114                 </exec>
115                 <!-- Unittest -->
116                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/unittest">
117                         <arg line="checkout 3.0.x"/>
118                 </exec>
119                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/unittest">
120                         <arg line="pull"/>
121                 </exec>
122                 <!-- Userguide -->
123                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/userguide">
124                         <arg line="checkout master"/>
125                 </exec>
126                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/modules/userguide">
127                         <arg line="pull"/>
128                 </exec>
130                 <!-- Commit and Push -->
131                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}">
132                         <arg line="commit -a -m 'Updating submodules'"/>
133                 </exec>
134                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}">
135                         <arg line="push"/>
136                 </exec>
137         </target>
139         <!-- Update submodules - For when we sort out the submodule branch names -->
140         <target name="update-submodules2" depends="clean,clone-branch">
141                 <for list="${submodules}" param="submodule">
142                         <sequential>
143                                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/${submodule}">
144                                         <arg line="checkout ${branch}"/>
145                                 </exec>
146                                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}/${submodule}">
147                                         <arg line="pull"/>
148                                 </exec>
149                         </sequential>
150                 </for>
152                 <!-- Commit and Push -->
153                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}">
154                         <arg line="commit -a -m 'Updating submodules'"/>
155                 </exec>
156                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}">
157                         <arg line="push"/>
158                 </exec>
159         </target>
161         <!-- Check if a specific tag exists -->
162         <target name="tag-exists">
163                 <echo message="TODO: Check if tag (${tag}) exists."/>
164         </target>
166         <!-- Clone a specific tag -->
167         <target name="clone-tag">
168                 <exec executable="git" failonerror="true" dir="${basedir}/build/release">
169                         <arg line="clone ${repo} kohana-${tag}"/>
170                 </exec>
171                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${tag}">
172                         <arg line="checkout ${tag}"/>
173                 </exec>
174                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${tag}">
175                         <arg line="submodule update --init --recursive"/>
176                 </exec>
177         </target>
179         <!-- Clone a specific branch -->
180         <target name="clone-branch">
181                 <exec executable="git" failonerror="true" dir="${basedir}/build/release">
182                         <arg line="clone ${repo} kohana-${branch}"/>
183                 </exec>
184                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}">
185                         <arg line="checkout ${branch}"/>
186                 </exec>
187                 <exec executable="git" failonerror="true" dir="${basedir}/build/release/kohana-${branch}">
188                         <arg line="submodule update --init --recursive"/>
189                 </exec>
190         </target>
192         <!-- Build a release of a specific tag -->
193         <target name="release-tag" depends="clean,tag-exists,clone-tag,test-tag">
194                 <zip destfile="${basedir}/build/kohana-${tag}.zip">
195                         <fileset dir="${basedir}/build/release" excludes="${release-excludes}"/>
196                 </zip>
197         </target>
199         <target name="test-tag">
200                 <exec executable="phpunit" failonerror="true" dir="${basedir}/build/release/kohana-${tag}"/>
201         </target>
203         <target name="test-branch">
204                 <exec executable="phpunit" failonerror="true" dir="${basedir}/build/release/kohana-${branch}"/>
205         </target>
207         <target name="test" depends="clean,phpunit"/>
208         <target name="test-log" depends="clean,phpunit-log"/>
209 </project>