forked from esendex/esendex-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
173 lines (151 loc) · 6.17 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="EsendexSDK" default="test" phingVersion="2.4.2">
<target name="check-access"
description="Validate your credentials">
<input propertyName="username" message="Esendex Username " promptChar="?"/>
<input propertyName="password" message="Esendex Password " promptChar="?"/>
<input propertyName="reference" message="Account Reference" promptChar="?"/>
<check-access username="${username}" password="${password}" reference="${reference}"/>
</target>
<target name="test"
depends="prepare"
description="Run all the tests">
<exec executable="./vendor/bin/phpunit" dir="." checkreturn="true" logoutput="true">
<arg line="--log-junit"/>
<arg file="./build/TestResult.xml"/>
<arg line="./test/"/>
</exec>
</target>
<target name="package"
depends="build"
description="Package build output">
<load-version prefix="versions"/>
<echo message="Creating packages..."/>
<exec executable="php" dir="./build" checkreturn="true">
<arg file="./pear_generator.php"/>
<arg line="make"/>
</exec>
<echo message="Building PEAR package"/>
<exec executable="pear" dir="./build" checkreturn="true">
<arg line="package"/>
</exec>
<move todir="./build/pear">
<fileset dir="./build">
<include name="package.xml"/>
<include name="*.tgz"/>
</fileset>
</move>
<copy todir="./build/src">
<fileset dir="./build/Esendex">
<include name="**"/>
</fileset>
</copy>
<delete dir="./build/Esendex" includeemptydirs="true" failonerror="true"/>
<property name="gzip.file" value="esendex-php-sdk-${versions.version}.tgz"/>
<tar destfile="./build/${gzip.file}" prefix="esendex-php-sdk" compression="gzip">
<fileset dir="./build">
<include name="**"/>
<exclude name="TestResult.xml"/>
<exclude name="pear/**"/>
</fileset>
</tar>
<move file="./build/${gzip.file}" tofile="./build/gzip/${gzip.file}"/>
<echo message="Files copied and compressed in build directory OK!"/>
<echo message="Tidying up build directory"/>
<delete includeemptydirs="true">
<fileset dir="./build">
<include name="**"/>
<exclude name="gzip/**"/>
<exclude name="pear/**"/>
<exclude name="TestResult.xml"/>
</fileset>
</delete>
<exec executable="git" dir="./build" checkreturn="true">
<arg line="rev-parse HEAD >version.info"/>
</exec>
</target>
<target name="prepare">
<delete dir="./build"/>
<echo message="Making directory ./build"/>
<mkdir dir="./build"/>
</target>
<target name="build" depends="test">
<copy todir="./build/">
<fileset dir="./">
<include name="test/**"/>
<exclude name="*"/>
</fileset>
<filelist dir="./" files="build.xml,composer.json,LICENSE"/>
</copy>
<mkdir dir="./build/Esendex"/>
<copy todir="./build/Esendex">
<fileset dir="./src">
<include name="**"/>
</fileset>
</copy>
</target>
<adhoc-task name="load-version">
<![CDATA[
class LoadVersionTask extends Task
{
private $prefix = "version";
function setPrefix($prefix)
{
$this->prefix = $prefix;
}
function init()
{
require_once $this->project->getProperty("project.basedir") . "/vendor/autoload.php";
}
function main()
{
$this->project->setProperty($this->prefix . ".version",
\Esendex\Model\Api::getVersion());
$this->project->setProperty($this->prefix . ".apiversion",
\Esendex\Model\Api::getApiVersion());
}
}
]]>
</adhoc-task>
<adhoc-task name="check-access">
<![CDATA[
class CheckAccessTask extends Task
{
private $username;
private $password;
private $reference;
function setUsername($value)
{
$this->username = (string)$value;
}
function setPassword($value)
{
$this->password = (string)$value;
}
function setReference($value)
{
$this->reference = (string)$value;
}
function init()
{
require_once $this->project->getProperty("project.basedir") . "/vendor/autoload.php";
}
function main()
{
if (strlen($this->username) == 0 ||
strlen($this->password) == 0 ||
strlen($this->reference) == 0) {
print "\n\tCould not check access, need to provide Username, Password and Account Reference\n";
return;
}
$service = new \Esendex\CheckAccessService();
if ($service->checkAccess($this->reference, $this->username, $this->password)) {
print "\n\tAccount credentials OK!\n";
return;
}
print "\n\tCould not validate your credentials, check your input and retry\n";
}
}
]]>
</adhoc-task>
</project>