1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* RoboFile.php |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/robo-tasks |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use AppserverIo\RoboTasks\AbstractRoboFile; |
22
|
|
|
use Robo\Robo; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Defines the available build tasks. |
26
|
|
|
* |
27
|
|
|
* @author Tim Wagner <[email protected]> |
28
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
29
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
30
|
|
|
* @link https://github.com/appserver-io/robo-tasks |
31
|
|
|
* @link http://www.appserver.io |
32
|
|
|
* |
33
|
|
|
* @SuppressWarnings(PHPMD) |
34
|
|
|
*/ |
35
|
|
|
class RoboFile extends AbstractRoboFile |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Run's the composer install command. |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function composerInstall() |
44
|
|
|
{ |
45
|
|
|
// optimize autoloader with custom path |
46
|
|
|
$this->taskComposerInstall() |
47
|
|
|
->preferDist() |
48
|
|
|
->optimizeAutoloader() |
49
|
|
|
->run(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Run's the composer update command. |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function composerUpdate() |
58
|
|
|
{ |
59
|
|
|
// optimize autoloader with custom path |
60
|
|
|
$this->taskComposerUpdate() |
61
|
|
|
->preferDist() |
62
|
|
|
->optimizeAutoloader() |
63
|
|
|
->run(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Clean up the environment for a new build. |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function clean() |
72
|
|
|
{ |
73
|
|
|
$this->taskDeleteDir($this->getTargetDir())->run(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Prepare's the environment for a new build. |
78
|
|
|
* |
79
|
|
|
* @return void |
80
|
|
|
*/ |
81
|
|
|
public function prepare() |
82
|
|
|
{ |
83
|
|
|
$this->taskFileSystemStack() |
84
|
|
|
->mkdir($this->getTargetDir()) |
85
|
|
|
->mkdir($this->getReportsDir()) |
86
|
|
|
->run(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Run's the PHPMD. |
91
|
|
|
* |
92
|
|
|
* @return void |
93
|
|
|
*/ |
94
|
|
|
public function runMd() |
95
|
|
|
{ |
96
|
|
|
|
97
|
|
|
// run the mess detector |
98
|
|
|
$this->_exec( |
99
|
|
|
sprintf( |
100
|
|
|
'%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit', |
101
|
|
|
$this->getVendorDir(), |
102
|
|
|
$this->getSrcDir(), |
103
|
|
|
$this->getTargetDir() |
104
|
|
|
) |
105
|
|
|
); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Run's the PHPCPD. |
110
|
|
|
* |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public function runCpd() |
114
|
|
|
{ |
115
|
|
|
|
116
|
|
|
// run the copy past detector |
117
|
|
|
$this->_exec( |
118
|
|
|
sprintf( |
119
|
|
|
'%s/bin/phpcpd %s --log-pmd %s/reports/pmd-cpd.xml', |
120
|
|
|
$this->getVendorDir(), |
121
|
|
|
$this->getSrcDir(), |
122
|
|
|
$this->getTargetDir() |
123
|
|
|
) |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Run's the PHPCodeSniffer. |
129
|
|
|
* |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
|
|
public function runCs() |
133
|
|
|
{ |
134
|
|
|
|
135
|
|
|
// run the code sniffer |
136
|
|
|
$this->_exec( |
137
|
|
|
sprintf( |
138
|
|
|
'%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s', |
139
|
|
|
$this->getVendorDir(), |
140
|
|
|
$this->getTargetDir(), |
141
|
|
|
$this->getSrcDir() |
142
|
|
|
) |
143
|
|
|
); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Run's the PHPUnit tests. |
148
|
|
|
* |
149
|
|
|
* @return void |
150
|
|
|
*/ |
151
|
|
|
public function runTests() |
152
|
|
|
{ |
153
|
|
|
|
154
|
|
|
// run PHPUnit |
155
|
|
|
$this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->getVendorDir())) |
156
|
|
|
->configFile('phpunit.xml') |
157
|
|
|
->run(); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* The complete build process. |
162
|
|
|
* |
163
|
|
|
* @return void |
164
|
|
|
*/ |
165
|
|
|
public function build() |
166
|
|
|
{ |
167
|
|
|
$this->clean(); |
168
|
|
|
$this->prepare(); |
169
|
|
|
$this->runCs(); |
170
|
|
|
$this->runCpd(); |
171
|
|
|
$this->runMd(); |
172
|
|
|
$this->runTests(); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.