This repository has been archived by the owner on May 26, 2021. It is now read-only.
forked from msroot/vanity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
247 lines (218 loc) · 10 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?xml version="1.0" encoding="UTF-8"?>
<project default="help" basedir=".">
<!-- Human-readable info about our component -->
<taskdef name="now" classname="Phix_Project.ComponentManager.Phing.NowTask" />
<now name="date.now"/>
<if>
<and>
<isset property="project.snapshot"/>
<istrue value="${project.snapshot}"/>
</and>
<then>
<property name="project.version" value="${project.majorVersion}.${project.minorVersion}.${project.patchLevel}-${date.now}" />
<property name="project.stability" value="snapshot" />
</then>
<else>
<property name="project.version" value="${project.majorVersion}.${project.minorVersion}.${project.patchLevel}" />
<property name="project.stability" value="stable" />
</else>
</if>
<property name="project.apiversion" value="${project.majorVersion}.${project.minorVersion}" />
<!-- Paths to the directories that we work with -->
<property name="project.srcdir" value="${project.basedir}/src" override="true" />
<property name="project.testdir" value="${project.basedir}/tests" override="true" />
<property name="project.reviewdir" value="${project.basedir}/review" override="true" />
<property name="project.review.logsdir" value="${project.basedir}/review/logs" override="true" />
<property name="project.review.docsdir" value="${project.reviewdir}/docs" override="true" />
<property name="project.review.codebrowserdir" value="${project.reviewdir}/code-browser" override="true" />
<property name="project.review.codecoveragedir" value="${project.reviewdir}/code-coverage" override="true" />
<property name="project.builddir" value="${project.basedir}/.build" override="true" />
<property name="project.pkgdir" value="${project.builddir}/${project.name}-${project.version}" override="true" />
<property name="project.tmpdir" value="${project.basedir}/.tmp" override="true" />
<property name="project.distdir" value="${project.basedir}/dist" />
<property name="project.distdir.lastBuilt" value="${project.basedir}/dist/lastBuilt" />
<property name="project.tarfilename" value="${project.name}-${project.version}.tgz" />
<property name="project.zipfilename" value="${project.name}-${project.version}.zip" />
<property name="project.tarfile" value="${project.distdir}/${project.tarfilename}" />
<property name="project.zipfile" value="${project.distdir}/${project.zipfilename}" />
<!-- override this if you want to run additional PEAR commands -->
<property name="pear.cmd" value="" override="true" />
<!-- lists of the files that make up our package -->
<fileset dir="${project.basedir}" id="allfiles">
<include name="**/**" />
<exclude name=".build/" />
<exclude name="dist/" />
<exclude name="review/" />
<exclude name="composer.lock" />
<exclude name="TODO" />
</fileset>
<taskdef name="phingcallifexists" classname="Phix_Project.ComponentManager.Phing.PhingCallIfExistsTask" />
<!-- Tell the user what this build file supports -->
<target name="help">
<echo message="build.xml targets:" />
<echo message="" />
<echo message="Setup your dev environment:" />
<echo message="" />
<echo message=" composer" />
<echo message=" Run `composer install` to install all dependencies using Composer." />
<echo message="" />
<echo message="Develop your code:" />
<echo message="" />
<echo message=" lint" />
<echo message=" Check the PHP files for syntax errors." />
<echo message=" test" />
<echo message=" Run all of the tests." />
<echo message=" code-review" />
<echo message=" Run all of the code quality targets:" />
<echo message="" />
<echo message=" code-browser" />
<echo message=" Run code quality tests for PHP_CodeBrowser." />
<echo message=" phpcpd" />
<echo message=" Check for cut and paste problems." />
<echo message=" phploc" />
<echo message=" Calculate the size of your PHP project." />
<echo message="" />
<echo message="Publish your component:" />
<echo message="" />
<echo message=" pear-package" />
<echo message=" Run `onion build` to create a PEAR/Pyrus-compatible package.xml file." />
<!--
<echo message=" publish-local" />
<echo message=" Publish your PEAR-compatible package into a local copy" />
<echo message=" of your PEAR channel" />
-->
<echo message=""/>
<echo message="Additional targets:" />
<echo message=""/>
<echo message=" clean" />
<echo message=" Remove all temporary folders created by this build file" />
<echo message=" version" />
<echo message=" Show this component's version from build.properties" />
<echo message="" />
<phingcallifexists target="local.help" />
</target>
<!-- Show the current version, as set in build.properties -->
<!-- This is just to be a time-saver -->
<target name="version">
<echo message="${project.version}" />
</target>
<!-- Run PHP lint on all of the source code -->
<target name="lint">
<phplint>
<fileset dir="${project.srcdir}">
<include name="**/*.php" />
</fileset>
</phplint>
<phingcallifexists target="local.lint" />
</target>
<!-- Run the unit tests for this module -->
<target name="run-unittests" depends="lint">
<!-- run the tests -->
<delete dir="${project.review.codecoveragedir}" />
<mkdir dir="${project.review.codecoveragedir}" />
<mkdir dir="${project.review.logsdir}" />
<exec command="phpunit" checkreturn="true" logoutput="true"/>
<echo/>
<echo>The code coverage report is in file://${project.review.codecoveragedir}</echo>
<echo/>
</target>
<!-- Run all the tests for this module -->
<target name="test" depends="run-unittests">
<phingcallifexists target="local.test"/>
</target>
<!-- Run the code review quality tests -->
<target name="code-review" depends="run-unittests, code-browser, phpcpd, pdepend, phploc">
<phingcallifexists target="local.code-review"/>
</target>
<!-- Run all of the targets for setting up the code browser -->
<target name="code-browser" depends="phpmd, phpcs, phpcb">
<phingcallifexists target="local.code-browser"/>
</target>
<target name="pdepend">
<mkdir dir="${project.review.logsdir}" />
<exec command="pdepend --phpunit-xml=${project.review.logsdir}/pdepend.xml --jdepend-xml=${project.review.logsdir}/jdepend.xml --jdepend-chart=${project.review.logsdir}/dependencies.svg --overview-pyramid=${project.review.logsdir}/overview-pyramid.svg ${project.src.phpdir}" logoutput="true"/>
</target>
<!-- Generate package docs -->
<!--
<target name="phpdoc">
<mkdir dir="${project.review.logsdir}" />
<exec command="phpdoc -d ${project.src.phpdir} -t ${project.review.docsdir}" logoutput="true"/>
<echo message="You will find the PHPDoc for your project at: ${project.review.docsdir}/index.html"/>
<phingcallifexists target="local.phpdoc"/>
</target>
-->
<!-- Check code for code smells -->
<target name="phpmd">
<mkdir dir="${project.review.logsdir}" />
<exec command="phpmd ${project.src.phpdir} xml codesize,design,naming,unusedcode --reportfile ${project.review.logsdir}/phpmd.xml" logoutput="true" />
</target>
<target name="phpcpd">
<mkdir dir="${project.review.logsdir}"/>
<exec command="phpcpd --log-pmd ${project.review.logsdir}/pmd-cpd.xml ${project.src.phpdir}" logoutput="true" />
</target>
<!-- Check the code for style violations -->
<target name="phpcs">
<mkdir dir="${project.review.logsdir}" />
<exec command="phpcs --report=xml --report-file=${project.review.logsdir}/checkstyle.xml --standard=${checkstyle.standard} --extensions=php ${project.src.phpdir}" logoutput="true"/>
</target>
<!-- Build the code-browser files -->
<target name="phpcb" depends="phpmd">
<delete dir="${project.review.codebrowserdir}" />
<mkdir dir="${project.review.codebrowserdir}" />
<exec command="phpcb --log ${project.review.logsdir} --source ${project.src.phpdir} --output ${project.review.codebrowserdir}" logoutput="true" />
</target>
<!-- Work out the size of the project -->
<target name="phploc">
<mkdir dir="${project.review.logsdir}" />
<exec command="phploc --log-xml ${project.review.logsdir}/phploc.xml --log-csv ${project.review.logsdir}/phploc.csv ${project.src.phpdir}" logoutput="true" />
</target>
<!-- Create the PEAR package, ready for release -->
<target name="pear-package">
<exec command="onion build" logoutput="true" />
</target>
<!-- Publish to local copy of PEAR channel -->
<target name="publish-local" depends="pear-package">
<if>
<not>
<contains string="${project.lastBuiltTarfile}" substring="${project.name}"/>
</not>
<then>
<echo>Please run 'phing pear-package' first, then try again.</echo>
</then>
<elseif>
<available file="${project.lastBuiltTarfile}"/>
<then>
<!-- get rid of any existing snapshots we may have published -->
<foreach param="packagefile" absparam="abspackagefile" target="pirum-remove-package">
<fileset dir="${pear.local}/get">
<include name="${project.name}*snapshot*.tgz" />
</fileset>
</foreach>
<!-- publish the new PEAR package -->
<exec command="pirum add ${pear.local} ${project.lastBuiltTarfile}" checkreturn="true" logoutput="true" />
<phingcallifexists target="local.publish-local"/>
</then>
</elseif>
<else>
<echo>Cannot find PEAR package file ${project.lastBuiltTarfile}</echo>
<echo>Run 'phing pear-package' to create a new PEAR package, then try again</echo>
</else>
</if>
</target>
<target name="pirum-remove-package">
<exec command="pirum remove ${pear.local} ${packagefile}" logoutput="true" checkreturn="true" />
</target>
<target name="composer">
<exec command="composer install" logoutput="true" checkreturn="true" />
</target>
<!-- Clean up the mess -->
<target name="clean">
<delete dir="${project.builddir}" />
<delete dir="${project.distdir}" />
<delete dir="${project.reviewdir}" />
<delete dir="${project.pkgdir}" />
<delete dir="${project.distdir}" />
<delete dir="${project.tmpdir}" />
<phingcallifexists target="local.clean"/>
</target>
</project>