forked from clevertech/YiiBooster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
220 lines (189 loc) · 8.89 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
219
220
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<project name="YiiBooster" basedir="." default="dist"
description="Widget toolkit for the Yii web framework">
<!-- Changeable properties for this project are placed into the build.properties -->
<property file="./build/build.properties"/>
<!-- Main fileset containing files to be packaged for end-users. -->
<fileset id="sources" dir="${path.src}">
<include name="**"/>
</fileset>
<target name="all" depends="clean,check,doc,dist" />
<target name="check" depends="phploc, phpcpd, test, phpmd, phpcs, pdepend, codebrowser" />
<target name="doc" depends="apigen,annotated" />
<!-- Make an archive ready for distribution to end-users. -->
<target name="dist" depends="prepare-dist">
<propertyprompt useExistingValue="true" propertyName="project.version" defaultValue="beta"
promptText="What is the version of this release"/>
<property name="build.distfilename" value="${path.dist}/yiibooster-${project.version}.zip"/>
<echo msg="Packing the sources to ${build.distfilename} ..."/>
<zip destfile="${build.distfilename}">
<fileset refid="sources"/>
<fileset dir=".">
<include name="README.md"/>
<include name="INSTALL.md"/>
<include name="CHANGELOG.md"/>
<include name="LICENSE"/>
</fileset>
</zip>
</target>
<!-- Prepare the destination folder for distribution archive. -->
<target name="prepare-dist">
<echo msg="Recreating a distribution directory at ${path.dist}"/>
<delete dir="${path.dist}" includeemptydirs="true" failonerror="true" quiet="true"/>
<mkdir dir="${path.dist}"/>
</target>
<target name="prepare-reports-dir">
<if>
<not>
<available file="reports" type="dir" />
</not>
<then>
<echo msg="It seems we don't have `reports` directory, creating one..." />
<mkdir dir="reports" />
</then>
</if>
</target>
<target name="phploc" depends="prepare-reports-dir">
<exec executable="${path.composer.vendor}/bin/phploc" dir="." passthru="true">
<arg value="--verbose" />
<arg value="--progress" />
<arg value="--exclude" />
<arg value="assets" />
<arg value="--log-xml" />
<arg value="${path.reports}/phploc.xml" />
<!-- This "line" instead of "value" is extremely important, it allows us to specify several tokens as an argument -->
<arg line="${path.src} ${path.tests}" />
</exec>
</target>
<target name="prepare-docs-dir">
<if>
<not>
<available file="doc" type="dir" />
</not>
<then>
<echo msg="It seems we don't have `doc` directory, creating one..." />
<mkdir dir="doc" />
</then>
</if>
</target>
<!-- Make an API-level documentation -->
<target name="apigen" depends="prepare-docs-dir">
<exec executable="${path.composer.vendor}/bin/apigen" dir="." passthru="true">
<arg value="--config" />
<arg value="${path.build}/apigen.neon" />
<arg value="--destination" />
<arg line="${path.docs}/api" />
<arg value="--report" />
<arg line="${path.reports}/apigen.checkstyle.xml" />
</exec>
</target>
<!-- Make an annotated source code documentation (using Pinnocchio) -->
<target name="annotated" depends="prepare-docs-dir">
<echo msg="Running Pinnocchio over our source code base..."/>
<exec command="${path.composer.vendor}/bin/pinocchio --source=${path.src}/widgets --output=${path.docs}/annotated"
passthru="true"
returnProperty="annotated.return"/>
<if>
<not>
<equals arg1="${annotated.return}" arg2="0"/>
</not>
<then>
<echo msg="It seems you have a problem with your Pinnocchio setup."/>
<fail message="Error when trying to launch Pinnocchio."/>
</then>
<else>
<echo msg="Now you should be able to browse the annotated source code starting from ${path.docs}/annotated/index.html"/>
</else>
</if>
</target>
<!-- Run all tests -->
<target name="test" depends="prepare-reports-dir">
<echo msg="Running all existing tests..."/>
<!-- NO we will NOT use built-in "phpunit" task because it's pretty shitty compared to phpunit.xml -->
<exec executable="${path.composer.vendor}/bin/phpunit" passthru="true">
<arg value="--configuration"/>
<arg path="${path.tests}/phpunit.xml"/>
<arg value="--bootstrap"/>
<arg path="${path.tests}/bootstrap.php"/>
<!-- Logging setup -->
<arg value="--coverage-html"/>
<arg path="${path.reports}/coverage"/>
<arg value="--coverage-clover"/>
<arg path="${path.reports}/clover.xml"/>
<arg value="--testdox-text"/>
<arg path="${path.reports}/testdox.txt"/>
</exec>
</target>
<!-- We deliberately do not exclude anything to get duplication not necessarily in class definitions -->
<target name="phpcpd" depends="prepare-reports-dir">
<exec executable="${path.composer.vendor}/bin/phpcpd" dir="." passthru="true">
<arg value="--log-pmd" />
<arg value="${path.reports}/phpcpd.xml" />
<arg value="--min-lines" />
<arg value="4" />
<arg value="--fuzzy" />
<arg value="--progress" />
<arg line="${path.src}" />
</exec>
</target>
<!-- Checking the coding style within project with CodeSniffer. Intended to be used manually in console mode. -->
<target name="phpcs" depends="prepare-reports-dir">
<echo msg="Checking the code style..." />
<exec executable="${path.composer.vendor}/bin/phpcs" passthru="true">
<arg value="-p"/>
<arg value="--extensions=php" />
<arg value="--standard=${path.build}/ruleset.xml" />
<arg value="--tab-width=4" />
<arg value="--ignore=assets"/>
<arg value="--report-checkstyle=${path.reports}/checkstyle.xml" />
<arg path="${path.src}"/>
</exec>
</target>
<target name="phpmd" depends="prepare-reports-dir">
<exec executable="${path.composer.vendor}/bin/phpmd" dir="." passthru="true">
<arg value="--reportfile" />
<arg value="${path.reports}/phpmd.xml" />
<arg value="--exclude" />
<arg value="${path.src}/assets" />
<arg value="${path.src}" />
<arg value="xml" />
<arg value="${path.build}/phpmd.xml" />
</exec>
</target>
<target name="pdepend" depends="prepare-reports-dir">
<exec executable="${path.composer.vendor}/bin/pdepend" dir="." passthru="true">
<arg value="--ignore=assets" />
<!-- Note that this option is for INPUT file, not GENERATED one! -->
<arg value="--coverage-report=${path.reports}/clover.xml" />
<arg value="--summary-xml=${path.reports}/pdepend.xml" />
<arg value="--jdepend-chart=${path.reports}/jdepend.svg" />
<arg value="--overview-pyramid=${path.reports}/overview.svg" />
<arg value="${path.src}" />
</exec>
</target>
<!-- Generating the highlighted sources with the marks from Code Sniffer and Mess Detector (and code coverage, too) -->
<target name="codebrowser" depends="prepare-reports-dir">
<echo msg="Generating the browsable codebase..." />
<exec executable="${path.composer.vendor}/bin/phpcb" passthru="true">
<arg value="--log"/>
<arg path="${path.reports}"/>
<arg value="--output"/>
<arg path="${path.reports}/codebrowser/"/>
<arg value="--source"/>
<arg path="${path.src}"/>
</exec>
</target>
<!-- Prepare the destination folder for distribution archive. -->
<target name="prepare-dist">
<echo msg="Recreating a distribution directory at ${path.dist}"/>
<delete dir="${path.dist}" includeemptydirs="true" failonerror="true" quiet="true"/>
<mkdir dir="${path.dist}"/>
</target>
<target name="clean">
<echo msg="Purging all runtime directories"/>
<delete dir="${path.dist}" includeemptydirs="true" failonerror="false" quiet="false"/>
<delete dir="${path.reports}" includeemptydirs="true" failonerror="false" quiet="false"/>
<delete dir="${path.docs}" includeemptydirs="true" failonerror="false" quiet="false"/>
<echo msg="Now your codebase should be completely clean."/>
</target>
</project>