-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
214 lines (195 loc) · 10.6 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
<?xml version="1.0"?>
<project name="TechDivision_ApplicationServerWebsite" default="deploy" basedir=".">
<property name="php-src.dir" value="${basedir}/src" />
<property name="php-test.dir" value="${basedir}/tests" />
<property name="php-target.dir" value="${basedir}/target"/>
<property environment="env" />
<property file="${basedir}/build.properties"/>
<property file="${basedir}/build.default.properties"/>
<!-- ==================================================================== -->
<!-- Cleans the directories with the generated source files -->
<!-- ==================================================================== -->
<target name="clean" description="Cleans almost everything, so use carefully.">
<delete dir="${php-target.dir}" includeemptydirs="true" quiet="false" verbose="true" failonerror="true"/>
</target>
<!-- ==================================================================== -->
<!-- Prepares all the required directories -->
<!-- ==================================================================== -->
<target name="prepare" depends="clean" description="Prepares all the required directories.">
<mkdir dir="${php-target.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the target directory -->
<!-- ==================================================================== -->
<target name="copy" depends="prepare" description="Copies the sources to the target directory.">
<antcall target="sass-compile"/>
<copy todir="${php-target.dir}/${webapp.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-src.dir}">
<include name="**/*.php" />
<include name="**/*.yml" />
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*.xml.*" />
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<copy todir="${php-target.dir}/${webapp.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-src.dir}">
<include name="**/*" />
<exclude name="**/*.php" />
<exclude name="**/*.yml" />
<exclude name="**/*.properties" />
<exclude name="**/*.xml" />
<exclude name="**/*.xml.*" />
</fileset>
</copy>
<exec executable="composer.phar" dir="${php-target.dir}/${webapp.name}">
<arg line="update"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Prepares the documentation to the target directory -->
<!-- ==================================================================== -->
<target name="prepare-doc" description="Copies the documentation to the target directory.">
<exec executable="git" dir="${php-target.dir}">
<arg line="clone https://github.com/${doc.git.namespace}/${doc.git.repo}.git"/>
</exec>
<exec executable="git" dir="${php-target.dir}/${doc.git.repo}">
<arg line="checkout ${webapp.appserver.version}"/>
</exec>
<exec executable="make" dir="${php-target.dir}/${doc.git.repo}/doc" failonerror="true">
<arg line="html" />
</exec>
<copy
file="${doc.build.file}"
tofile="${doc.target.file}"
overwrite="true"
/>
<copy todir="${doc.image.target.dir}" preservelastmodified="true" overwrite="true" failonerror="false">
<fileset dir="${doc.image.build.dir}">
<include name="**/*" />
</fileset>
</copy>
<replaceregexp file="${doc.target.file}"
match="src="_images"
replace="src="static/img/docs"
byline="true"
/>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the deploy directory -->
<!-- ==================================================================== -->
<target name="deploy" depends="copy" description="Copies the sources to the deploy directory.">
<antcall target="prepare-doc"/>
<copy todir="${deploy.dir}/${webapp.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-target.dir}/${webapp.name}">
<include name="**/*"/>
</fileset>
</copy>
</target>
<!-- ==================================================================== -->
<!-- Creates a PHAR file for deployment -->
<!-- ==================================================================== -->
<target name="create-phar" depends="copy" description="Creates a PHAR file for deployment.">
<antcall target="prepare-doc"/>
<exec executable="phar">
<arg line="pack -l 0 -f ${php-target.dir}/${webapp.name}.phar ${php-target.dir}/${webapp.name}"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Generates the API documentation -->
<!-- ==================================================================== -->
<target name="apidoc" description="Generates the API documentation.">
<exec executable="phpdoc">
<arg line="-ct type -ue on -s on -t ${php-target.dir}/docs -o HTML:frames:earthli -d ${php-src.dir}/app/code/core"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Runs the code sniffer and generates a report -->
<!-- ==================================================================== -->
<target name="phpcs" description="Runs the code sniffer and generates a report.">
<exec executable="phpcs" failonerror="true">
<!-- call phpcs without report-file to get error message on build console -->
<arg line="-n --extensions=php --standard=phpcs.xml src"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Runs the copy and paste detection -->
<!-- ==================================================================== -->
<target name="phpcpd" description="Runs the copy and paste detection.">
<exec executable="phpcpd">
<arg line="--log-pmd ${php-target.dir}/reports/pmd-cpd.xml ${php-src.dir}"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Generate phploc.csv -->
<!-- ==================================================================== -->
<target name="phploc" description="Generate phploc.csv">
<exec executable="phploc">
<arg line="--log-xml ${php-target.dir}/reports/phploc.xml ${php-src.dir}"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Runs the PHPDepend tool and generats a graphs -->
<!-- ==================================================================== -->
<target name="pdepend" description="Runs the PHPDepend tool and generats a graphs.">
<exec executable="pdepend">
<arg line="--summary-xml=${php-target.dir}/reports/pdepend.xml --jdepend-xml=${php-target.dir}/reports/jdepend.xml --jdepend-chart=${php-target.dir}/reports/jdepend.svg --overview-pyramid=${php-target.dir}/reports/pdepend-pyramid.svg ${php-src.dir}" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Runs the PHP mess detector tool -->
<!-- ==================================================================== -->
<target name="phpmd" description="Runs the PHP Mess detector tool.">
<exec executable="phpmd">
<arg line="${php-src.dir} xml codesize,unusedcode --reportfile ${php-target.dir}/reports/pmd.xml" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Copies the test sources to the target directory -->
<!-- ==================================================================== -->
<target name="copy-tests" depends="copy" description="Copies the test sources to the target directory.">
<copy todir="${php-target.dir}">
<fileset dir="${php-test.dir}">
<include name="**/*" />
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
</target>
<!-- ==================================================================== -->
<!-- Runs the PHPUnit tests and generates a report -->
<!-- ==================================================================== -->
<target name="run-tests" depends="copy-tests" description="Runs the PHPUnit tests and generates a report.">
<exec executable="phpunit" dir="${php-target.dir}">
<arg line="--bootstrap bootstrap.php --configuration phpunit.xml.dist" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Compiles sass to css -->
<!-- ==================================================================== -->
<target name="sass-compile" if="${sass.compile}" description="Compiles sass to css">
<echo message="Compiling sass to css..." />
<!-- compile -->
<exec dir="${php-src.dir}" executable="compass" >
<arg value="compile"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Runs the PHPUnit tests and generates the code metrics -->
<!-- ==================================================================== -->
<target name="build" description="Runs the PHPUnit tests and generates the code metrics.">
<antcall target="phpcs"/>
<antcall target="run-tests"/>
<!--
<antcall target="apidoc"/>
<antcall target="phpcpd"/>
<antcall target="phploc"/>
<antcall target="pdepend"/>
<antcall target="phpmd"/>
-->
</target>
</project>