-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.xml
160 lines (135 loc) · 7.84 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="magento2-gateway" default="build" basedir=".">
<property name="vendor-dir" value="${project.basedir}/vendor/"/>
<property name="global-vendor-dir" value="~/.composer/vendor/"/>
<property file="./build.properties" />
<property name="magento2.base_dir" value="${project.basedir}/magento2" />
<property name="bin.composer" value="${global-vendor-dir}bin/composer" />
<property name="bin.magento" value="${magento2.base_dir}/bin/magento" />
<property name="bin.phpunit" value="${global-vendor-dir}bin/phpunit" />
<property name="magento2.phpunit" value="${magento2.base_dir}/vendor/bin/phpunit" />
<property name="db.safe_name" refid="db.name">
<filterchain>
<replaceregexp>
<regexp pattern="[^0-9a-zA-Z$_]" replace="_" ignoreCase="true"/>
</replaceregexp>
</filterchain>
</property>
<target name="validate-build-properties" description="Ensure all require properties are defined">
<if>
<not><isset property="magento2.version"/></not>
<then><fail>magento.version is not specified</fail></then>
</if>
<if>
<not><isset property="magento2.base_url"/></not>
<then><fail>magento.base_url is not specified</fail></then>
</if>
<if>
<not><isset property="magento2.language"/></not>
<then><fail>db.language is not specified</fail></then>
</if>
<if>
<not><isset property="magento2.currency"/></not>
<then><fail>db.currency is not specified</fail></then>
</if>
<if>
<not><isset property="magento2.timezone"/></not>
<then><fail>db.timezone is not specified</fail></then>
</if>
<if>
<not><isset property="db.name"/></not>
<then><fail>db.name is not specified</fail></then>
</if>
<if>
<not><isset property="db.user"/></not>
<then><fail>db.user is not specified</fail></then>
</if>
<if>
<not><isset property="db.pass"/></not>
<then><fail>db.password is not specified</fail></then>
</if>
</target>
<target name="install" depends="create-db,download-magento2,install-magento2" description="Install Magento 2 and Extension" />
<target name="create-db" depends="validate-build-properties" description="Create database ${db.name}">
<exec command="mysql -u ${db.user} --password=${db.pass} -h ${db.host} -e 'CREATE DATABASE IF NOT EXISTS ${db.name}' " passthru="true" checkreturn="true" />
</target>
<target name="download-magento2" depends="validate-build-properties" description="Install Magento2 in the ${magento2.base_dir} directory">
<if>
<not><available type="dir" file="${magento2.base_dir}" /></not>
<then>
<exec command="${bin.composer} create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2" passthru="true" checkreturn="true" />
</then>
<else>
<echo message="Magento 2 is already downloaded in ${magento2.base_dir}" />
</else>
</if>
</target>
<target name="install-magento2" depends="validate-build-properties" description="Install Magento2 in the ${magento2.base_dir} directory">
<exec command="php ${bin.magento} setup:install --base-url=${magento2.base_url} --db-host=${db.host} --db-name=${db.name} --db-user=${db.user} --db-password=${db.pass} --admin-firstname=Magento --admin-lastname=User [email protected] --admin-user=admin --admin-password=admin123 --language=${magento2.language} --currency=${magento2.currency} --timezone=${magento2.timezone} --use-rewrites=1" passthru="true" checkreturn="true" />
<exec command="php ${bin.magento} deploy:mode:set developer" passthru="true" checkreturn="true" />
</target>
<target name="install-deps" description="Install all required dependencies">
<exec command="${bin.composer} install" passthru="true" checkreturn="true" />
</target>
<target name="install-extension-ecomdev-phpunit">
<exec command="${bin.mage-ci} install-module ${magento.base_dir} https://github.com/EcomDev/EcomDev_PHPUnit.git" passthru="true" checkreturn="true" />
</target>
<target name="test-phpunit">
<exec command="${magento2.phpunit} -c ./magento2/dev/tests/unit/phpunit.xml.dist ./magento2/app/code/ZipMoney/ZipMoneyPayment/Test/" passthru="true" checkreturn="true" />
</target>
<target name="cache-clean">
<exec command="php ${bin.magento} cache:clean" passthru="true" checkreturn="true" />
</target>
<target name="cache-flush">
<exec command="php ${bin.magento} cache:flush" passthru="true" checkreturn="true" />
</target>
<target name="reindexall" depends="cache-clean">
<exec command="php ${bin.magento} index:reindex" passthru="true" checkreturn="true" />
</target>
<target name="uninstall-magento" description="Remove composer install dependencies, Magento directory and Magento database">
<exec command="php ${bin.magento} uninstall" passthru="true" checkreturn="true" />
<delete dir="${magento2.base_dir}" />
<delete dir="${project.basedir}/vendor" />
</target>
<target name="info">
<echo message="magento2.base_dir = ${magento2.base_dir} .. ${bin.magento}" />
</target>
<target name="clean" description="Remove Magento directory">
<delete dir="${magento2.base_dir}" />
</target>
<target name="test" depends="setup-extension, install" description="Remove Magento directory">
<exec command="php ${magento2.base_dir} dev:tests:run unit " passthru="true" checkreturn="true" />
</target>
<target name="setup-extension" description="Creates symlink in the app/code/">
<exec command="mkdir -p ${magento2.base_dir}/app/code/ZipMoney/ZipMoneyPayment" passthru="true" checkreturn="true" />
<exec command="cp -R $(pwd)/Block/ $(pwd)/Controller/ $(pwd)/etc/ $(pwd)/Helper/ $(pwd)/Gateway/ $(pwd)/Logger/ $(pwd)/Model/ $(pwd)/Setup/ $(pwd)/Test/ $(pwd)/view/ $(pwd)/registration.php $(pwd)/composer.json ./magento2/app/code/ZipMoney/ZipMoneyPayment/" passthru="true" checkreturn="true" />
<exec dir="${magento2.base_dir}" command="${bin.composer} require zipmoney/merchantapi-php:1.0.*" passthru="true" checkreturn="true" />
<exec command="php ${magento2.base_dir} module:enable ZipMoney_ZipMoneyPayment" passthru="true" checkreturn="true" />
<exec command="php ${magento2.base_dir} setup:upgrade" passthru="true" checkreturn="true" />
</target>
<target name="create_package" description="Package module into a magento connect package">
<exec command="tar -zcvf ${package.name}-v${env.branch}.tar.gz -C ${magento2.base_dir}/app/code/ZipMoney/ZipMoneyPayment ." passthru="true" checkreturn="true" />
</target>
<target name="publish_to_s3">
<exec command="aws s3 cp ${package.name}-v${env.branch}.tar.gz s3://zm-software-assets/Plugins-Libraries/Plugins/Magento2/${package.name}-v${env.branch}.tar.gz --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers" passthru="true" checkreturn="true" />
</target>
<target name="package" description="Package module into a magento package">
<propertyregex property="tagname" subject="${env.branch}" pattern="^(\*|\d+(\.\d+){0,2}(\.\*)?)$" match="$1" casesensitive="false" defaultvalue="false"/>
<echo msg="${tagname}" />
<if>
<ispropertytrue property="tagname" />
<then>
<echo msg="Is a tag" />
<phingcall target="create_package"/>
<phingcall target="publish_to_s3"/>
</then>
<else>
<echo msg="Is not a tag, so not creating a package" />
</else>
</if>
</target>
<target name="really-clean" description="Remove composer install dependencies, Magento directory">
<delete dir="${magento2.base_dir}" />
<delete dir="${project.basedir}/vendor" />
</target>
</project>