-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.xml
291 lines (256 loc) · 14.7 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?xml version="1.0" encoding="UTF-8"?>
<project name="proclaim" default="build" basedir=".">
<autoloader autoloaderpath="${project.basedir}/libraries/vendor/autoload.php"/>
<property name="basedir" value="${project.basedir}"/>
<property name="project.name" value="Proclaim"/>
<!-- Joomla version to run the unit tests against -->
<property name="joomla.version" value="4.2.4"/>
<property name="config_path" value="${basedir}/tests/system/servers"/>
<property name="src.test" value="${basedir}/tests/test"/>
<property name="dest.test" value="${basedir}/admin/views/test"/>
<target name="init" description="Create artifact directories">
<mkdir dir="${basedir}/build/reports"/>
<mkdir dir="${basedir}/docs"/>
</target>
<!-- List of all files that are packaged and distributed -->
<fileset dir="${basedir}" id="distributed_files">
<include name="admin/**/*.php"/>
<include name="media/**/*.php"/>
<include name="modules/**/*.php"/>
<include name="plugins/**/*.php"/>
<include name="site/**/*.php"/>
<exclude name=".git"/>
</fileset>
<!-- Validate syntax -->
<target name="lint" description="Perform syntax check of sourcecode files">
<phplint haltonfailure="true">
<fileset refid="distributed_files"/>
</phplint>
</target>
<!-- <target name="phpunit" depends="init"-->
<!-- description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">-->
<!-- <phpunit haltonfailure="true" haltonerror="true" bootstrap="${basedir}/tests/unit/bootstrap.php">-->
<!-- <!– We can only use one formatter at a time –>-->
<!-- <formatter todir="${basedir}/build/reports" type="plain" outfile="test-brief.txt"/>-->
<!-- <batchtest>-->
<!-- <fileset dir="${basedir}/tests/unit/suites/" includes="**/*.php"/>-->
<!-- </batchtest>-->
<!-- </phpunit>-->
<!-- </target>-->
<!-- Measure the size of the project -->
<!-- <target name="size" description="Measures the size of the project">-->
<!-- <phploc countTests="true" reportType="txt" reportName="project-size" reportDirectory="${basedir}/build/reports">-->
<!-- <fileset refid="distributed_files"/>-->
<!-- </phploc>-->
<!-- </target>-->
<!-- Detect violations in coding standards -->
<target name="phpcs" depends="init" description="Generate checkstyle.xml using PHP_CodeSniffer">
<phpcodesniffer standard="PEAR" format="summary" showSniffs="true" showWarnings="true" haltonerror="true">
<fileset refid="distributed_files"/>
<formatter type="checkstyle" outfile="${basedir}/build/reports/phpcs-checkstyle.xml"/>
</phpcodesniffer>
</target>
<!-- Code analyzer and metric tool -->
<target name="pdepend" depends="init"
description="Generate jdepend.xml and software metrics charts using PHP_Depend">
<phpdepend haltonerror="true">
<fileset refid="distributed_files"/>
<logger type="jdepend-xml" outfile="${basedir}/build/reports/jdepend.xml"/>
<logger type="jdepend-chart" outfile="${basedir}/build/reports/jdepend-dependencies.svg"/>
<logger type="overview-pyramid" outfile="${basedir}/build/reports/jdepend-pyramid.svg"/>
<analyzer type="coderank-mode" value="method"/>
</phpdepend>
</target>
<!-- PHP Mess Detector -->
<target name="pmd" depends="init" description="Detect messy code, and generate report">
<phpmd rulesets="${basedir}/build/phpmd.xml">
<fileset refid="distributed_files"/>
<formatter type="html" outfile="${basedir}/build/reports/pmd.html"/>
</phpmd>
</target>
<!-- Create com_proclaim-x.x.x.zip -->
<target name="component" depends="init,dev.clean" description="Builds the component">
<input message="Enter the version you are building." propertyName="version" defaultValue="10.0.x"/>
<delete file="${basedir}/build/com_proclaim-${version}.zip"/>
<zip destfile="${basedir}/build/com_proclaim-${version}.zip">
<fileset defaultexcludes="true" dir=".">
<include name="admin/**"/>
<include name="media/**"/>
<include name="modules/**"/>
<include name="plugins/**"/>
<include name="site/**"/>
<include name="*.php"/>
<exclude name="build.xml"/>
<include name="*.xml"/>
<include name="*.txt"/>
<include name="*.md"/>
</fileset>
</zip>
<!--Reset back to a development state-->
<phingcall target="dev.init"/>
</target>
<!-- Setup config file for running the Selenium Webdriver tests -->
<target name="test.setup">
<input message="Enter the path to your Joomla! root directory" propertyName="server_root"
defaultValue="/Applications/MAMP/htdocs"/>
<input message="Enter the sever host" propertyName="host" defaultValue="localhost"/>
<input message="Enter database host" propertyName="db_host" defaultValue="localhost"/>
<input message="Enter Database username" propertyName="db_user" defaultValue="root"/>
<input message="Enter database password" propertyName="db_pass" defaultValue="root"/>
<input message="Enter Database name" propertyName="db_name" defaultValue="joomla-dev"/>
<input message="Enter an initial Joomla username" propertyName="joomla_username" defaultValue="admin"/>
<input message="Enter an initial Joomla password" propertyName="joomla_password" defaultValue="password"/>
<input message="Enter an initial Joomla email" propertyName="joomla_email" defaultValue="[email protected]"/>
<copy file="${config_path}/configuration.php.dist" tofile="${config_path}/configuration.php" overwrite="true">
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="SERVER_ROOT" value="${server_root}"/>
<token key="HOST" value="${host}"/>
<token key="DB_HOST" value="${db_host}"/>
<token key="DB_USER" value="${db_user}"/>
<token key="DB_PASS" value="${db_pass}"/>
<token key="DB_NAME" value="${db_name}"/>
<token key="JOOMLA_USERNAME" value="${joomla_username}"/>
<token key="JOOMLA_PASSWORD" value="${joomla_password}"/>
<token key="JOOMLA_EMAIL" value="${joomla_email}"/>
</replacetokens>
</filterchain>
</copy>
<!-- Setup the joomla test environment -->
<phingcall target="stage_joomla">
<property name="joomla-stage-dir" value="tests/.joomla-dev-test"/>
</phingcall>
<!-- Link Joomla to the webserver's root directory -->
<symlink target="${basedir}/tests/.joomla-dev" link="${server_root}/joomla-dev-test" overwrite="true"/>
</target>
<target name="test.clean">
<delete dir="${basedir}/tests/.joomla-dev" includeemptydirs="true"/>
</target>
<!-- <target name="test.system" depends="init"-->
<!-- description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">-->
<!-- <phpunit haltonfailure="true" haltonerror="true" bootstrap="${basedir}/tests/system/servers/configdef.php">-->
<!-- <!– We can only use one formatter at a time –>-->
<!-- <formatter todir="${basedir}/build/reports" type="plain" outfile="test-brief.txt"/>-->
<!-- <batchtest>-->
<!-- <fileset dir="${basedir}/tests/system/tests/installation" includes="**/*.php"/>-->
<!-- </batchtest>-->
<!-- </phpunit>-->
<!-- </target>-->
<!-- Set the default joomla path and create symbolic links -->
<target name="dev.setup">
<input message="Enter the path to your Joomla! root directory" propertyName="joomla_path"
defaultValue="/Applications/MAMP/htdocs/"/>
<input message="Enter Joomla folder name" propertyName="joomla_dir" defaultValue="joomla-dev"/>
<input message="Stage Joomla?" propertyName="stage_joomla" defaultValue="n"/>
<if>
<equals arg1="${stage_joomla}" arg2="y"/>
<then>
<phingcall target="stage_joomla">
<property name="joomla-stage-dir" value=".joomla-dev"/>
<!-- Force a stage if its already staged -->
<property name="force" value="${stage_joomla"/>
</phingcall>
<!--Link Joomla to the webserver's root directory -->
<symlink target="${basedir}/.joomla-dev" link="${joomla_path}/${joomla_dir}" overwrite="true"/>
</then>
</if>
<echo message="Joomla path set to: ${joomla_path}${joomla_dir}"/>
<echo message="Linking component to Joomla!"/>
<!-- Create symbolic links for component in the Joomla directory -->
<symlink target="${basedir}/media" link="${joomla_path}${joomla_dir}/media/com_proclaim" overwrite="true"/>
<symlink target="${basedir}/admin" link="${joomla_path}${joomla_dir}/administrator/components/com_proclaim"
overwrite="true"/>
<symlink target="${basedir}/site" link="${joomla_path}${joomla_dir}/components/com_proclaim"
overwrite="true"/>
<symlink target="${basedir}/modules/site/mod_proclaim"
link="${joomla_path}${joomla_dir}/modules/mod_proclaim" overwrite="true"/>
<symlink target="${basedir}/modules/site/mod_proclaim_podcast"
link="${joomla_path}${joomla_dir}/modules/proclaim_podcast" overwrite="true"/>
<symlink target="${basedir}/plugins/system/proclaimbackup"
link="${joomla_path}${joomla_dir}/plugins/system/proclaimbackup" overwrite="true"/>
<symlink target="${basedir}/plugins/finder/proclaim"
link="${joomla_path}${joomla_dir}/plugins/finder/proclaim" overwrite="true"/>
<symlink target="${basedir}/plugins/system/proclaimpodcast"
link="${joomla_path}${joomla_dir}/plugins/system/proclaimpodcast" overwrite="true"/>
<phingcall target="dev.init"/>
</target>
<!-- Set the default joomla path and create symbolic links -->
<target name="dev.setup_Symbolic_Links">
<input message="Enter the path to your Joomla! root directory" propertyName="joomla_path"
defaultValue="/Applications/MAMP/htdocs/"/>
<input message="Stage Joomla?" propertyName="joomla_dir" defaultValue="n"/>
<propertyprompt propertyName="joomla_dir" defaultValue="joomla-dev" promptText="Set Joomla folder name"/>
<echo message="Joomla path set to: ${joomla_path}${joomla_dir}"/>
<echo message="Linking component, modules, and plugins to Joomla!"/>
<!-- Create symbolic links for component in the Joomla directory -->
<symlink target="${basedir}/media" link="${joomla_path}${joomla_dir}/media/com_proclaim" overwrite="true"/>
<symlink target="${basedir}/admin" link="${joomla_path}${joomla_dir}/administrator/components/com_proclaim"
overwrite="true"/>
<symlink target="${basedir}/site" link="${joomla_path}${joomla_dir}/components/com_proclaim"
overwrite="true"/>
<symlink target="${basedir}/modules/site/mod_proclaim"
link="${joomla_path}${joomla_dir}/modules/mod_proclaim" overwrite="true"/>
<symlink target="${basedir}/modules/site/mod_proclaim_podcast"
link="${joomla_path}${joomla_dir}/modules/mod_proclaim_podcast" overwrite="true"/>
<symlink target="${basedir}/plugins/finder/proclaim"
link="${joomla_path}${joomla_dir}/plugins/finder/proclaim" overwrite="true"/>
<symlink target="${basedir}/plugins/task/proclaim"
link="${joomla_path}${joomla_dir}/plugins/task/proclaim" overwrite="true"/>
<phingcall target="dev.init"/>
</target>
<!-- Create symbolic links for the development state -->
<target name="dev.init">
<echo message="Initializing a development state"/>
<symlink target="${basedir}/proclaim.xml" link="${basedir}/admin/proclaim.xml" overwrite="true"/>
<symlink target="${basedir}/proclaim.script.php" link="${basedir}/admin/proclaim.script.php"
overwrite="true"/>
<mkdir dir="${basedir}/media/css/site"/>
<symlink target="${basedir}/media/css/cwmcore.css" link="${basedir}/media/css/site/cwmcore.css"
overwrite="true"/>
</target>
<!-- Clean up symbolic links from the development state -->
<target name="dev.clean">
<echo message="Cleaning up development state"/>
<delete file="${basedir}/admin/proclaim.xml"/>
<delete file="${basedir}/admin/proclaim.script.php"/>
<delete file="${basedir}/media/css/site/cwmcore.css"/>
</target>
<!-- Stage Joomla for bootstrapping unit tests -->
<target name="stage_joomla" description="Stage Joomla in specified path">
<!-- Only stage it if its not already staged -->
<available file="${joomla-stage-dir}" type="dir" property="joomla-staged"/>
<!-- Possible conditions for staging-->
<condition property="staged_but_not_forced">
<and>
<istrue value="${joomla-stage-dir}"/>
<equals arg1="${force}" arg2="n"/>
</and>
</condition>
<condition property="staged_but_forced">
<and>
<istrue value="${joomla-stage-dir}"/>
<equals arg1="${force}" arg2="y"/>
</and>
</condition>
<if>
<or>
<isfalse value="${joomla-stage-dir}"/>
<isfalse value="#{staged_but__not_forced}"/>
<istrue value="#{staged_but_forced}"/>
</or>
<then>
<delete dir="${joomla-stage-dir}" includeemptydirs="true" verbose="true"/>
<echo message="Staging Joomla ${joomla.version}. This will take a few minutes"/>
<gitclone repository="https://github.com/joomla/joomla-cms.git" targetPath="${joomla-stage-dir}"
branch="staging"/>
<!-- Switch to the Joomla version that we want to test on -->
<gitcheckout repository="${joomla-stage-dir}" branchname="${joomla.version}" create="false"/>
</then>
<else>
<echo message="Joomla ${joomla.version} is already staged"/>
</else>
</if>
</target>
<!-- This target should exit gracefully in order for a pull request is approved. -->
<target name="build" depends="init,lint,component"/>
</project>