This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.xml
163 lines (149 loc) · 6.87 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Phing static code analysis" default="all">
<!-- Properties -->
<property name="dir.base" value="." />
<property name="dir.tests" value="${project.basedir}/tests" />
<property name="dir.tests.unit" value="${project.basedir}/tests" />
<property name="dir.build" value="${project.basedir}/build" />
<property name="dir.docs" value="${dir.build}/docs" />
<property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" />
<property name="dir.reports" value="${dir.build}/logs" />
<property name="dir.reports.pdepend" value="${dir.reports}/pdepend" />
<property name="dir.reports.unit" value="${dir.reports}/phpunit" />
<property name="dir.reports.coverage" value="${dir.reports}/phpunit/coverage" />
<property name="dir.reports.build" value="${dir.reports}/htmlreport" />
<!-- ============================================ -->
<!-- Fileset: sources (all php files but those in test) -->
<!-- ============================================ -->
<fileset expandsymboliclinks="true" dir="${dir.base}" id="sources">
<include name="src/**/*.php" />
</fileset>
<!-- ============================================ -->
<!-- Target: clean -->
<!-- ============================================ -->
<target name="clean" description="Clean up build directories.">
<echo msg="Cleaning build directories ..." />
<delete dir="${dir.build}" verbose="false" />
</target>
<!-- ============================================ -->
<!-- Target: prepare -->
<!-- ============================================ -->
<target name="prepare" description="Create build directories.">
<echo msg="Creating build directories ..." />
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.docs}" />
<mkdir dir="${dir.docs.phpdoc}" />
<mkdir dir="${dir.reports}" />
<mkdir dir="${dir.reports.unit}" />
<mkdir dir="${dir.reports.coverage}" />
<mkdir dir="${dir.reports.pdepend}" />
<mkdir dir="${dir.reports.build}" />
</target>
<!-- ============================================ -->
<!-- Target: all (default target) -->
<!-- ============================================ -->
<target name="all" depends="clean, prepare">
<phingcall target="codecheck" />
<phingcall target="tests" />
<phingcall target="documentation" />
</target>
<!-- ============================================ -->
<!-- Target: codecheck (run all static code checks) -->
<!-- ============================================ -->
<target name="codecheck">
<phingcall target="lint" />
<phingcall target="codestyle" />
<phingcall target="mess" />
<phingcall target="copypaste" />
<phingcall target="measure" />
</target>
<!-- ============================================ -->
<!-- Target: tests (run all tests) -->
<!-- ============================================ -->
<target name="tests">
<!-- Now we are not running unit tests -->
<!-- <phingcall target="unittests" /> -->
</target>
<!-- ============================================ -->
<!-- Target: lint (Checks code syntax) -->
<!-- ============================================ -->
<target name="lint">
<echo msg="Running lint to check code syntax..." />
<phplint>
<fileset refid="sources" />
</phplint>
</target>
<!-- ============================================ -->
<!-- Target: codestyle (Checks code style compliance) -->
<!-- ============================================ -->
<target name="codestyle">
<echo msg="Running code sniffer to check PSR2 standard..." />
<phpcodesniffer standard="PSR2" showSniffs="true" showWarnings="true" verbosity="0" encoding="UTF-8">
<fileset refid="sources" />
<formatter type="full" outfile="${dir.reports}/reportcs.txt" />
<formatter type="checkstyle" outfile="${dir.reports}/checkstylecs.xml" />
</phpcodesniffer>
</target>
<!-- ============================================ -->
<!-- Target: mess (Detects mess in code. Recommended rulesets: -->
<!-- unusedcode,codesize,controversial,design,naming) -->
<!-- ============================================ -->
<target name="mess">
<echo msg="Running mess detector" />
<phpmd rulesets="unusedcode,codesize,controversial,design,naming">
<fileset refid="sources" />
<formatter type="xml" outfile="${dir.reports}/pmd.xml"/>
</phpmd>
</target>
<!-- ============================================ -->
<!-- Target: copypaste (detects copy/paste in code) -->
<!-- ============================================ -->
<target name="copypaste">
<echo msg="Running copy/paste detector..." />
<phpcpd>
<fileset refid="sources" />
<formatter type="pmd" outfile="${dir.reports}/pmd-cpd.xml" />
</phpcpd>
</target>
<!-- ============================================ -->
<!-- Target: measure (measures the code) -->
<!-- ============================================ -->
<target name="measure">
<echo msg="Running code measurements..." />
<phploc reportType="csv" reportName="phploc" reportDirectory="${dir.reports}">
<fileset refid="sources" />
</phploc>
<phpdepend>
<fileset refid="sources" />
<logger type="jdepend-xml" outfile="${dir.reports}/jdepend.xml"/>
<analyzer type="coderank-mode" value="method"/>
</phpdepend>
</target>
<!-- ============================================ -->
<!-- Target: documentation (PHP Documentor parsing) -->
<!-- ============================================ -->
<target name="documentation">
<phpdoc2 title="Project Documentation" destdir="${dir.docs.phpdoc}" template="responsive-twig">
<fileset refid="sources" />
</phpdoc2>
</target>
<!-- ============================================ -->
<!-- Target: unittests (unit testing) -->
<!-- ============================================ -->
<target name="unittests">
<echo msg="Running unit tests..." />
<coverage-setup database="${dir.reports.unit}/coverage.db">
<fileset refid="sources" />
</coverage-setup>
<phpunit configuration="${dir.tests}/phpunit.xml" codecoverage="true">
<formatter todir="${dir.reports.unit}" type="xml" />
<formatter todir="${dir.reports.unit}" type="clover" />
<batchtest>
<fileset dir="${dir.tests.unit}" />
</batchtest>
</phpunit>
<coverage-report outfile="${dir.reports.unit}/coverage.xml">
<report todir="${dir.reports.coverage}" title="Phing unit tests run" usesorttable="true"/>
</coverage-report>
</target>
</project>