forked from zikula/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
296 lines (252 loc) · 16.3 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
292
293
294
295
296
<?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-${JOB_NAME}-${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/bootstrap-zikula.js,
javascript/helpers/form/form.js,
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/AdminModule/Resources/public/js/admin_admin_admintabs.js,
system/AdminModule/Resources/public/js/admin_admin_systemnotices.js,
system/AdminModule/Resources/public/js/jQuery.mmenu-5.6.3/dist/js/jquery.mmenu.all.min.js,
system/BlocksModule/Resources/public/js/Zikula.Blocks.Admin.Common.js,
system/BlocksModule/Resources/public/js/Zikula.Blocks.Admin.Modifyposition.js,
system/BlocksModule/Resources/public/js/contextmenu.js,
system/BlocksModule/Resources/public/js/functions.js,
system/BlocksModule/Resources/public/js/Zikula.Menutree.Tree.js,
system/CategoriesModule/Resources/public/js/categories_admin_edit.js,
system/CategoriesModule/Resources/public/js/categories_admin_view.js,
system/GroupsModule/Resources/public/js/groups.js,
system/PageLockModule/Resources/public/js/PageLock.js,
system/PermissionsModule/Resources/public/js/Zikula.Permission.Admin.View.js,
system/RoutesModule/Resources/public/js/ZikulaRoutesModule.EditFunctions.js,
system/RoutesModule/Resources/public/js/ZikulaRoutesModule.Finder.js,
system/RoutesModule/Resources/public/js/ZikulaRoutesModule.js,
system/RoutesModule/Resources/public/js/ZikulaRoutesModule.Validation.js,
system/SearchModule/Resources/public/js/ZikulaSearchModule.User.Form.js,
system/SecurityCenterModule/Resources/public/js/securitycenter_admin_allowedhtml.js,
system/SecurityCenterModule/Resources/public/js/securitycenter_admin_purifierconfig.js,
system/SettingsModule/Resources/public/js/ZikulaSettingsModule.Admin.Phpinfo.js,
system/ThemeModule/Resources/public/js/ZikulaThemeModule.Admin.ModifyConfig.js,
system/ThemeModule/Resources/public/js/ZikulaThemeModule.Admin.View.js,
system/ThemeModule/Resources/public/js/themeswitcher.js,
system/UsersModule/Resources/public/js/Zikula.Users.Admin.Config.js,
system/UsersModule/Resources/public/js/Zikula.Users.Admin.View.js,
system/UsersModule/Resources/public/js/Zikula.Users.Util.CapsLock.js,
system/UsersModule/Resources/public/js/ZikulaUsersModule.Admin.SearchResults.js,
system/ZAuthModule/Resources/public/js/Zikula.ZAuth.Admin.View.js,
system/ZAuthModule/Resources/public/js/Zikula.ZAuth.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-dev --optimize-autoloader" checkreturn="true" passthru="true" /><!-- no-scripts removed -->
</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}"/>
<!-- generate composer_vendors file -->
<exec command="${workspace}/source/build.php build:generate_vendor_doc --write-to '${packagepath}/docs/Composer_Vendors.md'" checkreturn="true" passthru="true"/>
<!-- generate less file -->
<exec command="${workspace}/source/build.php build:generate_less --write-to '${packagepath}/web/bootstrap-font-awesome.css'" checkreturn="true" passthru="true"/>
<!-- move doc files from repo root -->
<echo msg="Moving doc files to /docs/en ..."/>
<move file="${workspace}/source/README.md" tofile="${packagepath}/docs/en/README.md" overwrite="true"/>
<move file="${workspace}/source/INSTALL-1.4.md" tofile="${packagepath}/docs/en/INSTALL-1.4.md" overwrite="true"/>
<move file="${workspace}/source/UPGRADE-1.4.md" tofile="${packagepath}/docs/en/UPGRADE-1.4.md" overwrite="true"/>
<move file="${workspace}/source/CHANGELOG-1.3.md" tofile="${packagepath}/docs/en/CHANGELOG-1.3.md" overwrite="true"/>
<move file="${workspace}/source/CHANGELOG-1.4.md" tofile="${packagepath}/docs/en/CHANGELOG-1.4.md" overwrite="true"/>
<move file="${workspace}/source/composer.json" tofile="${packagepath}/docs/en/dev/composer.json" overwrite="true"/>
<move file="${workspace}/source/composer.lock" tofile="${packagepath}/docs/en/dev/composer.lock" overwrite="true"/>
<exec command="${workspace}/source/build.php build:purge_vendors --vendor-dir ${packagepath}/vendor" checkreturn="true" passthru="true"/>
<exec command="${workspace}/source/build.php build:fix_autoloader --vendor-dir ${packagepath}/vendor" checkreturn="true" passthru="true"/>
<!-- install assets -->
<!--<exec command="php ${packagepath}/app/console assets:install ${packagepath}/web" checkreturn="true" passthru="true"/>-->
<!-- create route translation dummy file -->
<exec command="php ${packagepath}/app/console translation:extract --enable-extractor=jms_i18n_routing --dir=${packagepath}/app/logs --output-dir=${packagepath}/app/Resources/translations template" checkreturn="true" passthru="true" />
<!-- Clear cache and log directories filled by the console command above -->
<delete includeEmptyDirs="true">
<fileset dir="${packagepath}/app/cache" defaultexcludes="false">
<exclude name=".htaccess" />
<include name="**/*" />
</fileset>
</delete>
<delete includeEmptyDirs="true">
<fileset dir="${packagepath}/app/logs" defaultexcludes="false">
<exclude name=".htaccess" />
<include name="**/*" />
</fileset>
</delete>
<!-- compress JS -->
<foreach list="${ownjslist}" param="filename" target="compressownjs"/>
<echo msg="Prepare permissions..."/>
<chmod file="${packagepath}/app/config" mode="0777"/>
<chmod file="${packagepath}/app/config/dynamic" mode="0777"/>
<chmod file="${packagepath}/app/cache" mode="0777"/>
<chmod file="${packagepath}/app/logs" mode="0777"/>
<chmod file="${packagepath}/config" mode="0777"/>
<chmod file="${packagepath}/userdata" 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">
<echo msg="Nothing to do in build delete target."/>
<!-- 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.8.jar -o ${packagepath}/$BAREFILENAME-min.js ${packagepath}/${filename}" /> -->
<exec command="/usr/bin/java -jar /var/lib/jenkins/yuicompressor-2.4.8.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>