|
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 http://github.com/appserver-io/appserver |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use Robo\Robo; |
|
22
|
|
|
use AppserverIo\RoboTasks\AbstractRoboFile; |
|
23
|
|
|
use AppserverIo\RoboTasks\ConfigurationKeys; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Defines the available appserver.io build tasks. |
|
27
|
|
|
* |
|
28
|
|
|
* @author Tim Wagner <[email protected]> |
|
29
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
31
|
|
|
* @link http://github.com/appserver-io/appserver |
|
32
|
|
|
* @link http://www.appserver.io |
|
33
|
|
|
* |
|
34
|
|
|
* @SuppressWarnings(PHPMD) |
|
35
|
|
|
*/ |
|
36
|
|
|
class RoboFile extends AbstractRoboFile |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Load the appserver.io base tasks. |
|
41
|
|
|
* |
|
42
|
|
|
* @var \AppserverIo\RoboTasks\Base\loadTasks |
|
43
|
|
|
*/ |
|
44
|
|
|
use AppserverIo\RoboTasks\Base\loadTasks; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Initializes the default configuration. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct() |
|
50
|
|
|
{ |
|
51
|
|
|
|
|
52
|
|
|
// call parent constructor |
|
53
|
|
|
parent::__construct(); |
|
54
|
|
|
|
|
55
|
|
|
// initialize the default configuration |
|
56
|
|
|
Robo::config()->setDefault(sprintf('%s.%s', ConfigurationKeys::DIRS, 'dist'), sprintf('%s/dist', getcwd())); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Run's the composer install command. |
|
61
|
|
|
* |
|
62
|
|
|
* @return void |
|
63
|
|
|
*/ |
|
64
|
|
|
public function composerInstall() |
|
65
|
|
|
{ |
|
66
|
|
|
// optimize autoloader with custom path |
|
67
|
|
|
$this->taskComposerInstall() |
|
68
|
|
|
->preferDist() |
|
69
|
|
|
->optimizeAutoloader() |
|
70
|
|
|
->run(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Run's the composer update command. |
|
75
|
|
|
* |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
public function composerUpdate() |
|
79
|
|
|
{ |
|
80
|
|
|
// optimize autoloader with custom path |
|
81
|
|
|
$this->taskComposerUpdate() |
|
82
|
|
|
->preferDist() |
|
83
|
|
|
->optimizeAutoloader() |
|
84
|
|
|
->run(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Clean up the environment for a new build. |
|
89
|
|
|
* |
|
90
|
|
|
* @return void |
|
91
|
|
|
*/ |
|
92
|
|
|
public function clean() |
|
93
|
|
|
{ |
|
94
|
|
|
$this->taskDeleteDir($this->getTargetDir())->run(); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Prepare's the environment for a new build. |
|
99
|
|
|
* |
|
100
|
|
|
* @return void |
|
101
|
|
|
*/ |
|
102
|
|
|
public function prepare() |
|
103
|
|
|
{ |
|
104
|
|
|
$this->taskFileSystemStack() |
|
105
|
|
|
->mkdir($this->getDistDir()) |
|
106
|
|
|
->mkdir($this->getTargetDir()) |
|
107
|
|
|
->mkdir($this->getReportsDir()) |
|
108
|
|
|
->run(); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Run's the PHPMD. |
|
113
|
|
|
* |
|
114
|
|
|
* @return void |
|
115
|
|
|
*/ |
|
116
|
|
|
public function runMd() |
|
117
|
|
|
{ |
|
118
|
|
|
|
|
119
|
|
|
// run the mess detector |
|
120
|
|
|
$this->_exec( |
|
121
|
|
|
sprintf( |
|
122
|
|
|
'%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit || exit 0', |
|
123
|
|
|
$this->getVendorDir(), |
|
124
|
|
|
$this->getSrcDir(), |
|
125
|
|
|
$this->getTargetDir() |
|
126
|
|
|
) |
|
127
|
|
|
); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Run's the PHPCPD. |
|
132
|
|
|
* |
|
133
|
|
|
* @return void |
|
134
|
|
|
*/ |
|
135
|
|
|
public function runCpd() |
|
136
|
|
|
{ |
|
137
|
|
|
|
|
138
|
|
|
// run the copy past detector |
|
139
|
|
|
$this->_exec( |
|
140
|
|
|
sprintf( |
|
141
|
|
|
'%s/bin/phpcpd --names-exclude=DirectoryParser.php,EntityManagerFactory.php,QueueManager.php %s --log-pmd %s/reports/pmd-cpd.xml', |
|
142
|
|
|
$this->getVendorDir(), |
|
143
|
|
|
$this->getSrcDir(), |
|
144
|
|
|
$this->getTargetDir() |
|
145
|
|
|
) |
|
146
|
|
|
); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Run's the PHPCodeSniffer. |
|
151
|
|
|
* |
|
152
|
|
|
* @return void |
|
153
|
|
|
*/ |
|
154
|
|
|
public function runCs() |
|
155
|
|
|
{ |
|
156
|
|
|
|
|
157
|
|
|
// run the code sniffer |
|
158
|
|
|
$this->_exec( |
|
159
|
|
|
sprintf( |
|
160
|
|
|
'%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s', |
|
161
|
|
|
$this->getVendorDir(), |
|
162
|
|
|
$this->getTargetDir(), |
|
163
|
|
|
$this->getSrcDir() |
|
164
|
|
|
) |
|
165
|
|
|
); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Run's the PHPUnit tests. |
|
170
|
|
|
* |
|
171
|
|
|
* @return void |
|
172
|
|
|
*/ |
|
173
|
|
|
public function runTests() |
|
174
|
|
|
{ |
|
175
|
|
|
|
|
176
|
|
|
// run PHPUnit |
|
177
|
|
|
$this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->getVendorDir())) |
|
178
|
|
|
->configFile('phpunit.xml') |
|
179
|
|
|
->run(); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* The complete build process. |
|
184
|
|
|
* |
|
185
|
|
|
* @return void |
|
186
|
|
|
*/ |
|
187
|
|
|
public function build() |
|
188
|
|
|
{ |
|
189
|
|
|
$this->clean(); |
|
190
|
|
|
$this->prepare(); |
|
191
|
|
|
$this->runCs(); |
|
192
|
|
|
$this->runCpd(); |
|
193
|
|
|
$this->runMd(); |
|
194
|
|
|
$this->runTests(); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Returns the distribution directory. |
|
199
|
|
|
* |
|
200
|
|
|
* @return string The distribution directory |
|
201
|
|
|
*/ |
|
202
|
|
|
protected function getDistDir() |
|
203
|
|
|
{ |
|
204
|
|
|
return Robo::config()->get(sprintf('%s.%s', ConfigurationKeys::DIRS, 'dist')); |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
|
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.