-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
198 lines (171 loc) · 8.97 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="support" default="build">
<property name="builddir" value="${project.basedir}/resources/build"/>
<property name="toolsdir" value="${builddir}/tools/"/>
<property name="srcdir" value="${project.basedir}/src" />
<property name="testsdir" value="${project.basedir}/tests" />
<property name="changelog.header" value="# Changelog"/>
<property name="changelog.filename" value="CHANGELOG.md"/>
<property name="gitremote.url" value="https://github.com"/>
<property name="gitremote.owner" value="laradic"/>
<property name="gitremote.repo" value="${phing.project.name}"/>
<if>
<equals arg1="${phing.project.name}" arg2="change-me" />
<then>
<fail message="You need to change the project name." />
</then>
</if>
<property name="changelog.header" value="# Changelog"/>
<property name="changelog.filename" value="CHANGELOG.md"/>
<target name="changelog">
<delete file="${changelog.filename}" quiet="true" />
<exec command='echo "${changelog.header} \n" >> ${changelog.filename}'/>
<exec command='git log --date=short --format="- [%cd](${gitremote.url}/${gitremote.owner}/${gitremote.repo}/commit/%H) %gs %s " >> ${changelog.filename}' logoutput="false"/>
<echo message="Created markdown changelog: ${changelog.filename}" />
</target>
<target name="git.submodule.update">
<exec command="bash ${project.basedir}/resources/scripts/submodule-update.sh" dir="${project.basedir}" logoutput="true" />
</target>
<target name="build" depends="vendor,prepare,lint,phploc-ci,pdepend,phpcs-ci,phpcpd-ci,phpunit,phpdox,phpdoc" description=""/>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${builddir}/api"/>
<delete dir="${builddir}/coverage"/>
<delete dir="${builddir}/logs"/>
<delete dir="${builddir}/pdepend"/>
<delete dir="${builddir}/phpdox"/>
<delete dir="${builddir}/phpdoxwd"/>
<delete dir="${builddir}/phpdoc"/>
<property name="clean.done" value="true"/>
</target>
<target name="vendor" unless="vendor.done" description="Cleanup composer and vendor">
<delete dir="${project.basedir}/vendor"/>
<delete file="${project.basedir}/composer.lock"/>
<exec executable="composer" logoutput="true">
<arg line="install"/>
</exec>
<property name="vendor.done" value="true"/>
</target>
<target name="prepare" unless="prepare.done" depends="clean,git.submodule.update" description="Prepare for build">
<mkdir dir="${builddir}/coverage"/>
<mkdir dir="${builddir}/logs"/>
<mkdir dir="${builddir}/pdepend"/>
<mkdir dir="${builddir}/phpdox"/>
<mkdir dir="${builddir}/phpdoxwd"/>
<mkdir dir="${builddir}/phpdoc"/>
<exec executable="composer" logoutput="true">
<arg line="install"/>
</exec>
<property name="prepare.done" value="true"/>
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l"/>
<fileset dir="${srcdir}" >
<include name="**/*.php"/>
</fileset>
<fileset dir="${testsdir}">
<include name="**/*.php"/>
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${toolsdir}phploc.phar" logoutput="true">
<arg value="--count-tests"/>
<arg path="${srcdir}"/>
<arg path="${testsdir}"/>
</exec>
</target>
<target name="phploc-ci" depends="prepare" description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phploc.phar" logoutput="true">
<arg value="--count-tests"/>
<arg value="--log-csv"/>
<arg path="${builddir}/logs/phploc.csv"/>
<arg value="--log-xml"/>
<arg path="${builddir}/logs/phploc.xml"/>
<arg path="${srcdir}"/>
<arg path="${testsdir}"/>
</exec>
</target>
<target name="pdepend" depends="prepare" description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}pdepend.phar" logoutput="true">
<arg value="--jdepend-xml=${builddir}/logs/jdepend.xml"/>
<arg value="--jdepend-chart=${builddir}/pdepend/dependencies.svg"/>
<arg value="--overview-pyramid=${builddir}/pdepend/overview-pyramid.svg"/>
<arg path="${project.basedir}/src"/>
</exec>
</target>
<target name="phpmd" description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpmd.phar" logoutput="true">
<arg path="${project.basedir}/src"/>
<arg value="text"/>
<arg path="${builddir}/phpmd.xml"/>
</exec>
</target>
<target name="phpmd-ci" depends="prepare" description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpmd.phar" logoutput="true">
<arg path="${project.basedir}/src"/>
<arg value="xml"/>
<arg path="${builddir}/phpmd.xml"/>
<arg value="--reportfile"/>
<arg path="${builddir}/logs/pmd.xml"/>
</exec>
</target>
<target name="phpcbf" description="Fixes coding standard violations using PHP_CodeSniffer Fixer">
<exec executable="${toolsdir}phpcbf.phar" logoutput="true">
<arg value="--tabWidth=4"/>
<arg value="--standard=PSR2"/>
<arg value="--extensions=php"/>
<arg value="--ignore=autoload.php"/>
<arg path="${srcdir}"/>
<arg path="${testsdir}"/>
</exec>
</target>
<target name="phpcs" depends="phpcbf" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcs.phar" logoutput="true">
<arg value="--standard=PSR2"/>
<arg value="--extensions=php"/>
<arg value="--ignore=autoload.php"/>
<arg path="${srcdir}"/>
<arg path="${testsdir}"/>
</exec>
</target>
<target name="phpcs-ci" depends="prepare" description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcs.phar" output="/dev/null">
<arg value="--report=checkstyle"/>
<arg value="--report-file=${builddir}/logs/checkstyle.xml"/>
<arg value="--standard=PSR2"/>
<arg value="--extensions=php"/>
<arg value="--ignore=autoload.php"/>
<arg path="${srcdir}"/>
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcpd.phar" logoutput="true">
<arg path="${srcdir}"/>
</exec>
</target>
<target name="phpcpd-ci" depends="prepare" description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcpd.phar" logoutput="true">
<arg value="--log-pmd"/>
<arg path="${builddir}/logs/pmd-cpd.xml"/>
<arg path="${srcdir}"/>
</exec>
</target>
<target name="phpunit" depends="prepare" description="Run unit tests with PHPUnit">
<exec executable="${toolsdir}phpunit.phar" logoutput="true">
<arg value="--configuration"/>
<arg path="${builddir}/phpunit.xml"/>
</exec>
</target>
<target name="phpdox" depends="phploc-ci,phpcs-ci,phpmd-ci" description="Generate project documentation using phpDox">
<exec executable="${toolsdir}phpdox.phar" dir="${builddir}" logoutput="true"/>
</target>
<target name="phpdoc" depends="prepare" description="Generate project documentation using phpDocumentator">
<exec executable="${toolsdir}phpdoc.phar" dir="${project.basedir}" logoutput="true">
<arg line="-t ./resources/docs/phpdoc"/>
<arg line="-d ./src"/>
<arg line="--cache-folder=./resources/build/phpdoc"/>
<arg line="--template=xml"/>
</exec>
</target>
</project>