forked from zikula/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
271 lines (231 loc) · 14.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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="zikula" default="clean">
<!-- invokation
phing -f $WORKSPACE/source/build.xml clean prepare phpcs phpcb phpcpd phpunit pdepend phpmd docblox jsdoc build build_delete -Dworkspace=$WORKSPACE -Djob_name=$JOB_NAME -Dbuild_number=$BUILD_NUMBER -Dbuild_tag=$BUILD_TAG -Dbuild_id=$BUILD_ID -Dsvn_revision=$SVN_REVISION
# note phpcb must follow phpcs
-->
<!--
BUILD_NUMBER - The current build number, such as "153"
BUILD_ID - The current build id, (YYYY-MM-DD_hh-mm-ss)
JOB_NAME - Name of the project of this build, such as "foo"
BUILD_TAG - String of "jenkins-${JOBNAME}-${BUILD_NUMBER}".
WORKSPACE - The absolute path of the workspace.
SVN_REVISION - The revision this build is based on.
-->
<property name="builddir" value="${workspace}/build"/>
<property name="sourcedir" value="${workspace}/source"/>
<property name="package" value="${job_name}.build${build_number}"/>
<property name="exportdir" value="${builddir}/export"/>
<property name="archivedir" value="${builddir}/archive"/>
<property name="packagepath" value="${exportdir}/${job_name}"/>
<property name="checksumpath" value="${archivedir}/${package}-checksums"/>
<property name="patchdir" value="${builddir}/patch"/>
<property name="tmpdir" value="${builddir}/tmp"/>
<property name="ignorepaths" value="lib/vendor/*,javascript/*,system/*,themes/*,install/*,lib/legacy,plugins/*"/>
<property name="ownjslist" value="
javascript/helpers/Zikula.js,
javascript/helpers/Zikula.ImageViewer.js,
javascript/helpers/Zikula.Tree.js,
javascript/helpers/Zikula.itemlist.js,
javascript/helpers/Zikula.UI.js,
system/Zikula/Module/AdminModule/Resources/public/js/admin_admin_ajax.js,
system/Zikula/Module/AdminModule/Resources/public/js/admin_admin_modifyconfig.js,
system/Zikula/Module/BlocksModule/Resources/public/js/blocks.js,
system/Zikula/Module/BlocksModule/Resources/public/js/contextmenu.js,
system/Zikula/Module/BlocksModule/Resources/public/js/functions.js,
system/Zikula/Module/BlocksModule/Resources/public/js/Zikula.Menutree.Tree.js,
system/Zikula/Module/CategoriesModule/Resources/public/js/categories_admin_edit.js,
system/Zikula/Module/CategoriesModule/Resources/public/js/categories_admin_view.js,
system/Zikula/Module/ExtensionsModule/Resources/public/js/hookui.js,
system/Zikula/Module/GroupsModule/Resources/public/js/groups.js,
system/Zikula/Module/MailerModule/Resources/public/js/mailer_admin_modifyconfig.js,
system/Zikula/Module/MailerModule/Resources/public/js/mailer_admin_testconfig.js,
system/Zikula/Module/PageLockModule/Resources/public/js/pagelock.js,
system/Zikula/Module/PermissionsModule/Resources/public/js/permissions.js,
system/Zikula/Module/SearchModule/Resources/public/js/search_user_form.js,
system/Zikula/Module/SecurityCenterModule/Resources/public/js/securitycenter_admin_allowedhtm.js,
system/Zikula/Module/SecurityCenterModule/Resources/public/js/securitycenter_admin_modifyconfig.js,
system/Zikula/Module/SecurityCenterModule/Resources/public/js/securitycenter_admin_purifierconfig.js,
system/Zikula/Module/SettingsModule/Resources/public/js/settings_admin_modifyconfig.js,
system/Zikula/Module/SettingsModule/Resources/public/js/settings_admin_multilingual.js,
system/Zikula/Module/ThemeModule/Resources/public/js/form/form.js,
system/Zikula/Module/ThemeModule/Resources/public/js/form/form_tabbedpanelset.js,
system/Zikula/Module/ThemeModule/Resources/public/js/themeswitcher.js,
system/Zikula/Module/ThemeModule/Resources/public/js/theme_admin_modifyconfig.js,
system/Zikula/Module/UsersModule/Resources/public/js/users.js,
system/Zikula/Module/UsersModule/Resources/public/js/users_admin_modifyregistration.js,
system/Zikula/Module/UsersModule/Resources/public/js/Zikula.Users.NewUser.js,
system/Zikula/Module/UsersModule/Resources/public/js/Zikula.Users.LoginBlock.js,
system/Zikula/Module/UsersModule/Resources/public/js/Zikula.Users.PassMeter.js"/>
<!-- need a second property since phpdoc doesn't respect wildcard patterns -->
<property name="docbloxignorepaths" value="lib/vendor/,javascript/,system/"/>
<property name="ignorefiletypes" value="*.css,*.js"/>
<target name="clean">
<echo msg="Clean..."/>
<delete dir="${builddir}" includeemptydirs="true"/>
<delete dir="${sourcedir}/src/vendor" includeemptydirs="true"/>
<delete file="${workspace}/source/composer.lock"/>
<delete file="${workspace}/source/composer.phar"/>
</target>
<target name="prepare">
<echo msg="Prepare..."/>
<mkdir dir="${builddir}"/>
<mkdir dir="${builddir}/logs"/>
<mkdir dir="${builddir}/coverage"/>
<mkdir dir="${builddir}/docs"/>
<mkdir dir="${builddir}/phpcb"/>
<mkdir dir="${builddir}/archive"/>
<mkdir dir="${builddir}/export"/>
<mkdir dir="${builddir}/patch"/>
<mkdir dir="${builddir}/tmp"/>
<mkdir dir="${builddir}/jsdoc"/>
<exec command="curl -s https://getcomposer.org/installer | php;mv composer.phar ${workspace}/source"/>
<exec command="${workspace}/source/composer.phar install --prefer-dist --no-scripts"/>
</target>
<!-- Build archives -->
<target name="build" depends="prepare">
<echo msg="Exporting for build..."/>
<!-- ATTN export urls require manual edit -->
<exec command="cp -a ${workspace}/source/src ${packagepath}"/>
<exec command="svn export https://github.com/zikula-modules/Legal.git/branches/master
${builddir}/tmp/Legal"/>
<exec command="mv ${builddir}/tmp/Legal ${packagepath}/modules"/>
<exec command="svn export https://github.com/zikula-modules/Profile.git/branches/master
${builddir}/tmp/Profile"/>
<exec command="mv ${builddir}/tmp/Profile ${packagepath}/modules"/>
<exec command="${workspace}/source/build.php build:purge_vendors --vendor-dir ${packagepath}/vendor"/>
<exec command="${workspace}/source/build.php build:fix_autoloader --vendor-dir ${packagepath}/vendor"/>
<!-- compress JS -->
<foreach list="${ownjslist}" param="filename" target="compressownjs"/>
<echo msg="Prepare permissions..."/>
<chmod file="${packagepath}/app/cache" mode="0777"/>
<chmod file="${packagepath}/app/logs" mode="0777"/>
<chmod file="${packagepath}/config/config.php" mode="0666"/>
<chmod file="${packagepath}/userdata" mode="0777"/>
<chmod file="${packagepath}/ztemp" mode="0777"/>
<chmod file="${packagepath}/ztemp/error_logs" mode="0777"/>
<chmod file="${packagepath}/ztemp/view_cache" mode="0777"/>
<chmod file="${packagepath}/ztemp/view_compiled" mode="0777"/>
<chmod file="${packagepath}/ztemp/Theme_cache" mode="0777"/>
<chmod file="${packagepath}/ztemp/Theme_compiled" mode="0777"/>
<chmod file="${packagepath}/ztemp/Theme_Config" mode="0777"/>
<chmod file="${packagepath}/ztemp/idsTmp" mode="0777"/>
<chmod file="${packagepath}/ztemp/purifierCache" mode="0777"/>
<echo msg="Creating archive..."/>
<!-- zip's don't play nicely in Phing - using direct command -->
<!-- exec escape="false" command="cd ${exportdir}; zip -D -r ${archivedir}/${package}.zip ." / -->
<zip destfile="${archivedir}/${package}.zip">
<fileset dir="${exportdir}">
<include name="**/**"/>
</fileset>
</zip>
<!-- Use tar at commandline because phing tarballs don't support file chmod -->
<exec escape="false"
command="cd ${exportdir}; tar cp ${job_name} > ${archivedir}/${package}.tar; gzip ${archivedir}/${package}.tar"/>
<!-- tar destfile="${archivedir}/${package}.tar.gz" compression="gzip">
<fileset dir="${exportdir}/${job_name}">
<include name="**/**" />
</fileset>
</tar -->
<echo msg="Files copied and compressed in build directory OK!"/>
<!-- ATTN phingcall target="build_patch" / -->
<phingcall target="build_checksums"/>
</target>
<target name="build_delete">
<!-- clean up export dir, this is not needed (unless we are debugging) -->
<!-- delete dir="${packagepath}" includeemptydirs="true" -->
</target>
<target name="build_checksums">
<echo msg="Creating MD5 and SHA1 checksums..."/>
<exec escape="false" command="echo -----------------md5sums----------------- > ${checksumpath}.tmp"/>
<exec escape="false" command="md5sum ${archivedir}/*.tar.gz ${archivedir}/*.zip >> ${checksumpath}.tmp"/>
<exec escape="false" command="echo -----------------sha1sums----------------- >> ${checksumpath}.tmp"/>
<exec escape="false" command="sha1sum ${archivedir}/*.tar.gz ${archivedir}/*.zip >> ${checksumpath}.tmp"/>
<exec escape="false" command="cat ${checksumpath}.tmp | sed 's!${archivedir}/!!g' > ${checksumpath}.txt"/>
<delete file="${checksumpath}.tmp"/>
</target>
<target name="build_patch">
<echo msg="Making patches...."/>
<!-- get diffs for releases and save in ${tmpdir}/CHANGES file -->
<!-- ATTN urls require manual edit -->
<exec escape="false"
command="svn diff https://code.zikula.org/svn/core/tags/Zikula-1.3.0 https://code.zikula.org/svn/core/branches/zikula-1.3/src@${svn_revision} --summarize | sort|uniq > ${tmpdir}/CHANGES"/>
<!-- Remove lines that start with space (which means only a property change), or contain paths to deleted files -->
<exec escape="false" command="cat ${tmpdir}/CHANGES | sed -e '/^[ D]/d' >${tmpdir}/AM"/>
<!-- List deleted files -->
<exec escape="false" command="cat ${tmpdir}/CHANGES | grep -e '^D' >${tmpdir}/DELETED.tmp"/>
<!-- this needs to be the regex escaped of the OLD branch -->
<!-- ATTN url requires manual edit -->
<property name="patchregex" value="https://code.zikula.org/svn/core/tags/Zikula-1.3.0/"/>
<!-- A or M, ignoring svn-property changes (2nd char), strip the svn-path from the remaining lines, store in ${tmpdir}/FILES -->
<exec escape="false" command="cat ${tmpdir}/AM | sed -e 's!^[AM]. *${patchregex}!!g' > ${tmpdir}/FILES"/>
<exec escape="false" command="cat ${tmpdir}/DELETED.tmp | sed -e 's!${patchregex}!!g' > ${tmpdir}/DELETED"/>
<!-- assemble patch -->
<exec escape="false"
command="cd ${packagepath};for FILE in `cat ${tmpdir}/FILES`;do cp --parents $FILE ${patchdir};done"/>
<!-- install folder is always required -->
<exec escape="false"
command="svn export --force https://code.zikula.org/svn/core/branches/zikula-1.3/src/install@${svn_revision} ${patchdir}/install"/>
<!-- zip's don't play nicely in Phing - using direct command -->
<exec escape="false" command="cd ${patchdir}; zip -D -r ${archivedir}/${package}.patch.zip ."/>
</target>
<!-- Docblox documentor -->
<target name="docblox">
<echo msg="DocBlox..."/>
<exec command="docblox project:run --directory ${sourcedir}/src/lib/dbobject,${sourcedir}/src/lib/i18n,${sourcedir}/src/lib/viewplugins,${sourcedir}/src/lib/StreamReader,${sourcedir}/src/lib/util,${sourcedir}/src/lib/Zikula --target ${builddir}/docs"
escape="false"/>
</target>
<!-- PHPDocumentor -->
<target name="phpdoc">
<echo msg="PHPDocumentor..."/>
<exec command="phpdoc --directory ${sourcedir}/src/lib/dbobject,${sourcedir}/src/lib/i18n,${sourcedir}/src/lib/viewplugins,${sourcedir}/src/lib/StreamReader,${sourcedir}/src/lib/util,${sourcedir}/src/lib/Zikula --target ${builddir}/docs"
escape="false"/>
</target>
<!-- PHP copy/paste analysis -->
<target name="phpcpd">
<echo msg="PHP Copy/Paste..."/>
<exec command="phpcpd --log-pmd ${builddir}/logs/phpcpd.xml --suffixes php --exclude ${ignorepaths} ${sourcedir}/src"
escape="false"/>
</target>
<!-- PHP MD analysis -->
<target name="phpmd">
<echo msg="PHP_MD..."/>
<exec command="phpmd ${sourcedir}/src xml codesize --reportfile ${builddir}/logs/pmd.xml --ignore ${ignorepaths}"
escape="false"/>
</target>
<!-- PHP dependency checker -->
<target name="pdepend">
<!-- PHP dependency checker -->
<echo msg="PHP_Depend..."/>
<exec command="pdepend --jdepend-xml=${builddir}/logs/jdepend.xml --jdepend-chart=${builddir}/logs/jdepend.png --phpunit-xml=${builddir}/logs/pdepend_phpunit.xml --overview-pyramid=${builddir}/logs/pdepend_pyramid.png --summary-xml=${builddir}/logs/pdepend_summary.xml --ignore=${ignorepaths} --optimization=best --suffix=php ${sourcedir}/src"
escape="false"/>
</target>
<!-- PHP CodeSniffer -->
<target name="phpcs">
<echo msg="PHP_CodeSniffer..."/>
<exec command="phpcs --extensions=php --report=checkstyle --standard=Zikula --ignore=${ignorepaths} ${sourcedir}/src > ${builddir}/logs/phpcs.xml"
escape="false"/>
</target>
<!-- Unit Tests & coverage analysis -->
<target name="phpunit">
<echo msg="PHPUnit..."/>
<exec command="phpunit --log-junit ${builddir}/logs/phpunit.xml --coverage-clover ${builddir}/coverage/clover.xml --coverage-html ${builddir}/coverage/ ${sourcedir}/tests"/>
</target>
<!-- JSDoc -->
<target name="jsdoc">
<echo msg="JSDoc..."/>
<exec command="cd /opt/jsdoc-toolkit; /opt/jsdoc-toolkit/jsrun.sh -t=/opt/jsdoc-toolkit/templates/jsdoc --directory=${builddir}/jsdoc ${sourcedir}/src/javascript/helpers"/>
<!-- exec command="cd ${builddir}/jsdoc;/opt/jsdoc-toolkit ${sourcedir}/src/javascript/helpers"/ -->
</target>
<!-- Code Browser -->
<target name="phpcb">
<echo msg="PHP_CodeBrowser on XML for voilations..."/>
<exec command="phpcb --log ${builddir}/logs --output ${builddir}/phpcb"/>
</target>
<!-- Compress own JS -->
<target name="compressownjs">
<echo msg="YUI_Compressor for JS files..."/>
<!-- <exec command="BAREFILENAME=`echo ${filename}|sed 's/.js//g'`; /usr/bin/java -jar /var/lib/jenkins/yuicompressor-2.4.2.jar -o ${packagepath}/$BAREFILENAME-min.js ${packagepath}/${filename}" /> -->
<exec command="/usr/bin/java -jar /var/lib/jenkins/yuicompressor-2.4.2.jar -o ${packagepath}/${filename}.tmp ${packagepath}/${filename};echo '// Copyright Zikula Foundation 2010 - license GNU/LGPLv3 (or at your option, any later version).' > ${packagepath}/${filename};cat ${packagepath}/${filename}.tmp >> ${packagepath}/${filename};rm -f ${packagepath}/${filename}.tmp"/>
</target>
</project>