-
Notifications
You must be signed in to change notification settings - Fork 69
/
build.xml
executable file
·218 lines (194 loc) · 10.4 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<project name="rubedo" default="main" basedir=".">
<!-- By default, indicates all available arguments -->
<target name="main" depends="help"></target>
<target name="help" depends="">
<echo msg='Please use an argument to launch an action :' />
<echo msg=' build launch all build' />
<echo msg=' phpunit launch test suits' />
<echo msg=' set-rights set the good rights on cache and build folders' />
<echo msg=' ' />
<echo msg='Specific actions :' />
<echo msg=' phpunit-slim launch test suits whithout reporting' />
<echo msg=' ' />
<echo msg=' prepare-cache create cache folders and set rights on it' />
<echo msg=' clean-cache delete all cache folders' />
<echo msg=' prepare-build create build folders' />
<echo msg=' clean-build delete artifacts in build folders' />
<echo msg=' ' />
<echo msg=' phploc calculate project size and log the information' />
<echo msg=' pdepend log dependencies between all classes' />
<echo msg=' phpmd-ci perform project mess detection and log the result' />
<echo msg=' phpcs-ci check if the source code respects the PSR2 standards and log errors' />
<echo msg=' phpcpd Find duplicate code and log the result' />
<echo msg=' phpdoc create all the phpdoc for the project into build/phpdoc' />
</target>
<!-- Set good rights on folders -->
<target name="set-rights" depends="prepare-cache"></target>
<!-- Clear cache and build folders -->
<target name="clear" depends="clean-cache,clean-build,prepare-cache,prepare-build"></target>
<!-- Launch all the application for the continuous integration -->
<target name="build" depends="clean-build,prepare-build,lint,phploc,pdepend,phpcpd,phpmd-ci,phpcs-ci,phpunit,phpdoc"></target>
<!--*********************************************************************
************ Action for the test suit ***********************************
**********************************************************************-->
<target name="phpunit" description="Launch test suit">
<exec executable="${project.basedir}/vendor/bin/phpunit" passthru="true">
<arg value="--colors"/>
<arg value="--configuration"/>
<arg path="${project.basedir}/test/phpunit.xml"/>
<arg value="--log-junit"/>
<arg path="${project.basedir}/build/logs/phpunit.xml"/>
<arg value="--coverage-html"/>
<arg path="${project.basedir}/build/coverage"/>
<arg value="--coverage-clover"/>
<arg path="${project.basedir}/build/logs/coverage.xml"/>
</exec>
</target>
<target name="phpunit-slim" description="Launch test suit without coverage and report">
<exec executable="${project.basedir}/vendor/bin/phpunit" passthru="true">
<arg value="--colors"/>
<arg value="--configuration"/>
<arg path="${project.basedir}/test/phpunit.xml"/>
</exec>
</target>
<!--*********************************************************************
************ All actions for folders and rights *************************
**********************************************************************-->
<!-- Create dirs for the cache and set rights -->
<target name="prepare-cache" depends="">
<mkdir dir="${project.basedir}/cache"/>
<mkdir dir="${project.basedir}/cache/htmlpurifier"/>
<mkdir dir="${project.basedir}/cache/zend"/>
<mkdir dir="${project.basedir}/cache/config"/>
<mkdir dir="${project.basedir}/cache/images"/>
<mkdir dir="${project.basedir}/cache/twig"/>
<mkdir dir="${project.basedir}/log"/>
<mkdir dir="${project.basedir}/public/captcha"/>
<mkdir dir="${project.basedir}/public/theme"/>
<mkdir dir="${project.basedir}/public/generate-image"/>
<chmod file="${project.basedir}/cache" mode="777"/>
<chmod file="${project.basedir}/cache/htmlpurifier" mode="777"/>
<chmod file="${project.basedir}/cache/zend" mode="777"/>
<chmod file="${project.basedir}/cache/config" mode="777"/>
<chmod file="${project.basedir}/cache/images" mode="777"/>
<chmod file="${project.basedir}/cache/twig" mode="777"/>
<chmod file="${project.basedir}/log" mode="777"/>
<chmod file="${project.basedir}/config/autoload" mode="777"/>
<chmod file="${project.basedir}/public/captcha" mode="777"/>
<chmod file="${project.basedir}/public/theme" mode="777"/>
<chmod file="${project.basedir}/public/generate-image" mode="777"/>
</target>
<!-- Delete all cache dirs -->
<target name="clean-cache" description="Cleanup cache Folder">
<delete dir="${project.basedir}/cache"/>
</target>
<!-- Create build dirs -->
<target name="prepare-build" depends="clean-build" description="Prepare for build">
<mkdir dir="${project.basedir}/build"/>
<mkdir dir="${project.basedir}/build/api"/>
<mkdir dir="${project.basedir}/build/code-browser"/>
<mkdir dir="${project.basedir}/build/coverage"/>
<mkdir dir="${project.basedir}/build/logs"/>
<mkdir dir="${project.basedir}/build/pdepend"/>
<mkdir dir="${project.basedir}/build/phpdoc"/>
<chmod file="${project.basedir}/build" mode="777"/>
<chmod file="${project.basedir}/build/api" mode="777"/>
<chmod file="${project.basedir}/build/code-browser" mode="777"/>
<chmod file="${project.basedir}/build/coverage" mode="777"/>
<chmod file="${project.basedir}/build/logs" mode="777"/>
<chmod file="${project.basedir}/build/pdepend" mode="777"/>
<chmod file="${project.basedir}/build/phpdoc" mode="777"/>
</target>
<!-- Delete build dirs -->
<target name="clean-build" description="Cleanup build artifacts">
<delete dir="${project.basedir}/build/api"/>
<delete dir="${project.basedir}/build/code-browser"/>
<delete dir="${project.basedir}/build/coverage"/>
<delete dir="${project.basedir}/build/logs"/>
<delete dir="${project.basedir}/build/pdepend"/>
</target>
<!--*********************************************************************
************ All actions for the continuous integration *****************
**********************************************************************-->
<!-- Check syntax of all *.php files in Rubedo core -->
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l"/>
<fileset dir="${project.basedir}/module">
<include name="**/*.php"/>
</fileset>
</apply>
</target>
<!-- Determine the project size -->
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="${project.basedir}/vendor/bin/phploc">
<arg value="--log-csv"/>
<arg value="${project.basedir}/build/logs/phploc.csv"/>
<arg value="${project.basedir}/module"/>
</exec>
</target>
<!-- Calculate software metrics using PHP_Depend -->
<target name="pdepend" description="Calculate software metrics using PHP_Depend">
<exec executable="${project.basedir}/vendor/bin/pdepend">
<arg value="--jdepend-xml=${project.basedir}/build/logs/jdepend.xml"/>
<arg value="--jdepend-chart=${project.basedir}/build/pdepend/dependencies.svg"/>
<arg value="--overview-pyramid=${project.basedir}/build/pdepend/overview-pyramid.svg"/>
<arg path="${project.basedir}/module"/>
</exec>
</target>
<!-- Perform project mess detection using PHPMD and print human readable output -->
<target name="phpmd"
description="Perform project mess detection using PHPMD and print human readable output. ">
<exec executable="${project.basedir}/vendor/bin/phpmd" passthru="true">
<arg path="${project.basedir}/module"/>
<arg value="text"/>
<arg value="design,unusedcode"/>
</exec>
</target>
<!-- Perform project mess detection using PHPMD -->
<target name="phpmd-ci"
description="Perform project mess detection using PHPMD. ">
<exec executable="${project.basedir}/vendor/bin/phpmd">
<arg path="${project.basedir}/module"/>
<arg value="xml"/>
<arg value="design,unusedcode"/>
<arg value="--reportfile"/>
<arg value="${project.basedir}/build/logs/pmd.xml"/>
</exec>
</target>
<!-- Check if the source code respects the PSR2 standards -->
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${project.basedir}/vendor/bin/phpcs" passthru="true">
<arg value="--standard=PSR2"/>
<arg path="${project.basedir}/module"/>
</exec>
</target>
<!-- Check if the source code respects the PSR2 standards -->
<target name="phpcs-ci"
description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="${project.basedir}/vendor/bin/phpcs">
<arg value="-p"/>
<arg value="--report=checkstyle"/>
<arg value="--report-file=${project.basedir}/build/logs/checkstyle.xml"/>
<arg value="--standard=PSR2"/>
<arg path="${project.basedir}/module"/>
</exec>
</target>
<!-- Find duplicate code using PHPCPD -->
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="${project.basedir}/vendor/bin/phpcpd">
<arg value="--log-pmd"/>
<arg value="${project.basedir}/build/logs/pmd-cpd.xml"/>
<arg path="${project.basedir}/module"/>
</exec>
</target>
<!-- Build PHPdoc -->
<target name="phpdoc" description="Build PHPdoc">
<exec executable="${project.basedir}/vendor/bin/phpdoc">
<arg value="run"/>
<arg value="-d"/>
<arg path="${project.basedir}/module"/>
</exec>
</target>
</project>