-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.xml
226 lines (211 loc) · 9.1 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 2013-2020 Nosto Solutions Ltd
~
~ NOTICE OF LICENSE
~
~ This source file is subject to the Academic Free License (AFL 3.0)
~ that is bundled with this package in the file LICENSE.txt.
~ It is also available through the world-wide-web at this URL:
~ http://opensource.org/licenses/afl-3.0.php
~ If you did not receive a copy of the license and are unable to
~ obtain it through the world-wide-web, please send an email
~ to [email protected] so we can send you a copy immediately.
~
~ DISCLAIMER
~
~ Do not edit or add to this file if you wish to upgrade PrestaShop to newer
~ versions in the future. If you wish to customize PrestaShop for your
~ needs please refer to http://www.prestashop.com for more information.
~
~ @author Nosto Solutions Ltd <[email protected]>
~ @copyright 2013-2020 Nosto Solutions Ltd
~ @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-->
<!--suppress XmlUnboundNsPrefix -->
<project name="nostotagging" default="dist">
<php expression="include('./libs/autoload.php')"/>
<property name="package" value="${phing.project.name}" override="true"/>
<property name="buildstatic" value="./build/static" override="false"/>
<property name="zipbase" value="./build/src/" override="false"/>
<property name="buildsrc" value="./build/src/nostotagging" override="false"/>
<property name="buildbin" value="./build/bin" override="false"/>
<property name="buildroot" value="./build" override="true"/>
<property name="builddest" value="./build/package" override="true"/>
<property name="idea" value="./build/src/nostotagging/.idea" override="true"/>
<property name="srcdir" value="${project.basedir}" override="true"/>
<property name="packagename" value="${project.basedir}" override="true"/>
<!-- ============================================ -->
<!-- Target: prepare -->
<!-- ============================================ -->
<target name="prepare">
<echo msg="Cleaning up directory ./build"/>
<delete dir="${builddest}"/>
<delete dir="${buildsrc}"/>
<delete dir="${zipbase}"/>
<delete dir="${idea}"/>
<mkdir dir="${builddest}"/>
<mkdir dir="${zipbase}"/>
<mkdir dir="${buildsrc}"/>
<copy todir="${buildsrc}">
<fileset refid="sourcefiles"/>
</copy>
<phingcall target="updatedependencies"/>
<phingcall target="cleandependencies"/>
<phingcall target="fixcompatibility"/>
<phingcall target="autoindex"/>
</target>
<target name="phpcpd">
<exec executable="./libs/bin/phpcpd" passthru="true">
<arg value="--min-lines=1"/>
<arg value="."/>
</exec>
</target>
<target name="phpcbf">
<exec executable="./libs/bin/phpcbf" passthru="true">
<arg value="--colors"/>
<arg value="--report-width=auto"/>
<arg value="--standard=ruleset.xml"/>
<arg value="."/>
</exec>
</target>
<target name="phpcs">
<exec executable="./libs/bin/phpcs" passthru="true">
<arg value="--colors"/>
<arg value="--report-width=auto"/>
<arg value="--standard=ruleset.xml"/>
<arg value="."/>
</exec>
</target>
<target name="fixcompatibility">
<echo msg="Making PHP compatibility fixes"/>
<exec executable="sed">
<arg value="-i"/>
<arg value="-e"/>
<arg value="s/__DIR__/dirname\(__FILE__\)/g"/>
<arg value="${buildsrc}/libs/autoload.php"/>
</exec>
<delete file="${buildsrc}/libs/autoload.php-e"/>
<echo msg="Making Prestashop validator compatibility hacks"/>
<exec executable="sed">
<arg value="-i" />
<arg value="-e" />
<arg value="s#// autoload.php @generated by Composer#/* autoload.php @generated by Composer(\altered by Nosto Phing\) */#" />
<arg value="${buildsrc}/libs/autoload.php"/>
</exec>
<delete file="${buildsrc}/libs/autoload.php-e"/>
<exec executable="sed">
<arg value="-i"/>
<arg value="-e"/>
<arg value="s/$this->name = self::MODULE_NAME/$this->name = 'nostotagging'/g"/>
<arg value="${buildsrc}/nostotagging.php"/>
</exec>
<delete file="${buildsrc}/nostotagging.php-e"/>
<exec executable="sed">
<arg value="-i" />
<arg value="-e" />
<arg value="s/$this->version = self::PLUGIN_VERSION/$this->version = '${version}'/g" />
<arg value="${buildsrc}/nostotagging.php" />
</exec>
<delete file="${buildsrc}/nostotagging.php-e"/>
</target>
<target name="phpmd">
<echo msg="Checking code messes"/>
<phpmd rulesets="unusedcode">
<fileset dir="${buildsrc}">
<exclude name="**lib**"/>
<exclude name="**backward_compatibility**"/>
</fileset>
<formatter type="text" useFile="false" outfile="."/>
</phpmd>
</target>
<target name="cleandependencies">
<delete dir="${buildsrc}/libs/nosto/php-sdk/tests"/>
<delete file="${buildsrc}/libs/nosto/php-sdk/codeception.yml"/>
<delete file="${buildsrc}/libs/nosto/php-sdk/.gitignore"/>
<delete file="${buildsrc}/libs/nosto/php-sdk/Gruntfile.js"/>
<delete file="${buildsrc}/libs/nosto/php-sdk/package.json"/>
<delete file="${buildsrc}/libs/nosto/php-sdk/composer.json"/>
<delete dir="${buildsrc}/libs/nosto/php-sdk/.github"/>
<delete dir="${buildsrc}/libs/nosto/php-sdk/.idea"/>
<delete file="${buildsrc}/.env"/>
</target>
<target name="updatedependencies">
<echo msg="Updating dependencies"/>
<exec executable="composer" dir="${buildsrc}">
<arg value="install"/>
<arg value="--no-dev"/>
</exec>
<echo msg="Files copied and compressed"/>
</target>
<target name="phan">
<exec executable="./libs/bin/phan" passthru="true">
<arg value="--progress-bar"/>
<arg value="--signature-compatibility"/>
<arg value="--config-file=phan.php"/>
<arg value="--dead-code-detection"/>
<arg value="."/>
</exec>
</target>
<target name="autoindex">
<echo msg="Copying modified index with copyright headers"/>
<exec executable="cp">
<arg value="-iv" />
<arg value="${srcdir}/index.php" /> <!-- @TODO: this might break stuff-->
<arg value="${buildsrc}/libs/prestashop/autoindex/assets/index.php"/>
</exec>
<delete file="${buildsrc}/libs/prestashop/autoindex/assets/index.php-e"/>
<delete file="${buildsrc}/libs/autoload.php-e"/>
<exec executable="./libs/bin/autoindex" passthru="true">
<arg value="prestashop:add:index"/>
<arg value="${buildsrc}"/>
</exec>
<exec executable="./libs/bin/autoindex" passthru="true">
<arg value="prestashop:add:index"/>
<arg value="./libs"/>
</exec>
</target>
<fileset dir="${srcdir}" id="sourcefiles">
<patternset id="nostotagging.sources">
<include name="**"/>
<exclude name="*.DS_STORE"/>
<exclude name="phan.php"/>
<exclude name="Dockerfile"/>
<exclude name="Jenkinsfile"/>
<exclude name="**/.idea/**"/>
<exclude name="**/.github/**"/>
<exclude name="**/.phan/**"/>
<exclude name="**/tests/**"/>
<exclude name="**/phing/**"/>
<exclude name="**/build/**"/>
<exclude name="**/build.xml"/>
<exclude name="**/ruleset.xml"/>
<exclude name="**/*Gruntfile*"/>
<exclude name="**/*codeception*"/>
<exclude name="libs/**"/>
<exclude name="**/*package.json*"/>
<exclude name="config*.xml"/>
</patternset>
</fileset>
<!-- ============================================ -->
<!-- Target: build -->
<!-- ============================================ -->
<target name="build" depends="fixcompatibility, prepare, phpcs, phpmd">
<exec command="xmllint --nocdata --xpath 'module/version/text()' config.xml" outputProperty="version" />
<echo msg="Building version ${version}"/>
<exec executable="zip" dir="${zipbase}">
<arg value="-r"/>
<arg value="nostotagging.zip"/>
<arg value="nostotagging"/>
</exec>
<move file="${zipbase}/nostotagging.zip"
tofile="${builddest}/${version}-Nosto.-.Personalization.for.PrestaShop.zip"/>
<echo msg="Files copied and compressed"/>
</target>
<!-- ============================================ -->
<!-- (DEFAULT) Target: dist -->
<!-- ============================================ -->
<target name="dist" depends="build">
<echo msg="${version} built. All done."/>
</target>
</project>