-
Notifications
You must be signed in to change notification settings - Fork 54
/
build.xml
220 lines (190 loc) · 8.01 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"?>
<!-- build xml -->
<project name="services_openstreetmap" default="main" phingVersion="2.11.0">
<property name="builddir" value = "build"/>
<available file="${builddir}/docs" property="docs_exist" value="Y"/>
<available file="${builddir}/logs/pmd.xml" property="pmd_exist" value="Y"/>
<available file="${builddir}/logs/checkstyle.xml" property="phpcs_exist" value="Y"/>
<available file="${builddir}/coverage" property="coverage_exist" value="Y"/>
<available file="${builddir}/pdepend" property="pdepend_exist" value="Y"/>
<available file="/usr/local/bin/phpcpd.phar" property="phpcpd_phar" value="Y"/>
<available file="/usr/local/bin/phploc.phar" property="phploc_phar" value="Y"/>
<fileset dir="tests" id="tests" includes="**/*.php"/>
<fileset dir="Services" id="Services" includes="**/*.php"/>
<target name="prepare">
<mkdir dir="${builddir}" />
<mkdir dir="${builddir}/logs" />
<mkdir dir="${builddir}/coverage" />
</target>
<target name="main" depends="prepare,clean,lint,phpcs,phpmd,docs,test,phpcpd,phploc,phpdepend"/>
<target name="clean" depends="clean_phpunit,clean_pmd,clean_phpcs,clean_docs,clean_phploc,clean_phpcpd,clean_phpdepend" description="Clean out all files." />
<target name="clean_docs" if="docs_exist">
<delete dir="${builddir}/docs" includeemptydirs="yes"/>
</target>
<target name="clean_phpcpd">
<delete verbose="yes">
<fileset dir="${builddir}/logs">
<include name="pmd-cpd.csv"/>
</fileset>
</delete>
</target>
<target name="clean_phpcs" description="Clean PHPCS files." if="phpcs_exist">
<delete verbose="yes">
<fileset dir="${builddir}/logs">
<include name="**.*" />
</fileset>
</delete>
</target>
<target name="clean_phpdepend" description="Clean phpdepend files" if="pdepend_exist">
<delete verbose="yes">
<fileset dir="${builddir}/logs">
<include name="jdepend.xml"/>
</fileset>
</delete>
<delete dir="${builddir}/pdepend" includeemptydirs="yes"/>
</target>
<target name="clean_phploc">
<delete verbose='yes'>
<fileset dir="${builddir}/logs">
<include name="phploc.csv"/>
</fileset>
</delete>
</target>
<target name="clean_phpunit" if="coverage_exist">
<delete verbose='yes'>
<fileset dir="${builddir}/coverage/">
<include name="coverage.xml"/>
<include name="coverage.db"/>
</fileset>
</delete>
<delete verbose='no' dir='${builddir}/coverage' includeemptydirs="yes"/>
</target>
<target name="clean_pmd" description="Clean Mess Detector file[s]." if="pmd_exist">
<delete verbose="yes">
<fileset dir="${builddir}/logs">
<include name="pmd.xml"/>
</fileset>
</delete>
</target>
<target name="delete_build" description="Delete build directory.">
<delete dir="${builddir}" includeemptydirs="yes"/>
</target>
<target name="docs" description="Generate Documentation" depends="clean_docs">
<mkdir dir="build/docs" />
<touch file="build/docs/index.html"/>
<!--
<phpdoc2 title="Services_Openstreetmap" destdir="build/docs">
<fileset refid="Services"/>
</phpdoc2>
-->
</target>
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD" depends="prepare">
<if><equals arg1="${phpcpd_phar}" arg2="Y"/>
<then>
<phpcpd pharLocation="/usr/local/bin/phpcpd.phar">
<formatter type="pmd" outfile="${builddir}/logs/pmd-cpd.xml"/>
<fileset refid="Services"/>
</phpcpd>
</then>
<else>
<phpcpd>
<formatter type="pmd" outfile="${builddir}/logs/pmd-cpd.xml"/>
<fileset refid="Services"/>
</phpcpd>
</else>
</if>
</target>
<target name="phpcs" description="coding standards">
<phpcodesniffer format="checkstyle" standard="PEAR" haltonerror="no">
<formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
<fileset refid="Services"/>
</phpcodesniffer>
</target>
<target name="phpdepend" description="Calculate software metrics using PHP_Depend" depends="prepare">
<mkdir dir="${builddir}/pdepend" />
<phpdepend>
<logger type="jdepend-xml" outfile="${builddir}/logs/jdepend.xml" />
<logger type="jdepend-chart" outfile="${builddir}/pdepend/dependencies.svg" />
<logger type="overview-pyramid" outfile="${builddir}/pdepend/overview-pyramid.svg" />
<fileset refid="Services"/>
<fileset refid="tests"/>
</phpdepend>
</target>
<target name="phploc" description="Measure project size using PHPLOC" depends="prepare">
<if><equals arg1="${phploc_phar}" arg2="Y"/>
<then>
<phploc pharLocation="/usr/local/bin/phploc.phar" countTests="true" reportType="csv" reportName="phploc" reportDirectory="${builddir}/logs">
<fileset refid="Services"/>
<fileset refid="tests"/>
</phploc>
</then>
<else>
<phploc countTests="true" reportType="csv" reportName="phploc" reportDirectory="${builddir}/logs">
<fileset refid="Services"/>
<fileset refid="tests"/>
</phploc>
</else>
</if>
</target>
<target name="phpmd" description="PHP Mess Detector.">
<phpmd rulesets="unusedcode">
<fileset refid="Services"/>
<formatter type="xml" outfile="build/logs/pmd.xml"/>
</phpmd>
</target>
<target name="lint" description="Check syntax">
<phplint>
<fileset refid="Services"/>
<fileset refid="tests"/>
</phplint>
</target>
<target name="prepare">
<mkdir dir="${builddir}/logs" />
<mkdir dir="${builddir}/coverage" />
</target>
<target name="test" description="run unit tests" depends="lint,clean_phpunit,prepare">
<echo msg='Run unit tests'/>
<mkdir dir="tests/coverage" />
<coverage-setup database="./coverage.db">
<fileset dir="tests" includes="**/*.php"/>
<fileset dir="Services" includes="**/*.php"/>
</coverage-setup>
<phpunit printsummary="yes" codecoverage="yes" pharlocation="/usr/local/bin/phpunit">
<formatter type="clover" outfile="${builddir}/logs/clover.xml"/>
<formatter type="xml" outfile="${builddir}/logs/junit.xml"/>
<formatter type="plain" usefile="no"/>
<batchtest>
<fileset refid="tests"/>
</batchtest>
</phpunit>
<coverage-report outfile="coverage.xml">
<report todir="tests/coverage" usesorttable="yes" styledir="/usr/share/php/data/phing/etc"/>
</coverage-report>
</target>
<target name="clean" depends="clean_phpunit,clean_docs,clean_pmd"/>
<target name="clean_phpunit" if="coverage_exist">
<delete verbose='yes'>
<fileset dir="tests/coverage">
<include name="**.*" />
</fileset>
</delete>
<delete verbose='no' dir='tests/coverage'/>
</target>
<target name="clean_docs" if="docs_exist">
<delete verbose='yes'>
<fileset dir="build/docs">
<include name="**.*" />
</fileset>
</delete>
</target>
<target name="clean_pmd" description="Clean Mess Detector file[s]." if="pmd_exist">
<delete verbose="yes">
<fileset dir="build">
<include name="phpmd.xml"/>
</fileset>
</delete>
</target>
<target name="stan">
<phpstan command="analyse" level="7" paths="Services"/>
</target>
</project>