1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Phing\Exception\BuildException; |
4
|
|
|
use Phing\Type\Path; |
5
|
|
|
use Phing\Type\Reference; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
9
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
11
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
12
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
13
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
14
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
15
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
16
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
17
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
18
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
19
|
|
|
* |
20
|
|
|
* This software consists of voluntary contributions made by many individuals |
21
|
|
|
* and is licensed under the LGPL. For more information please see |
22
|
|
|
* <http://phing.info>. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
trait ClasspathAware |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var Path $classpath |
29
|
|
|
*/ |
30
|
|
|
protected $classpath; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Refid to already defined classpath |
34
|
|
|
*/ |
35
|
|
|
protected $classpathId; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns the classpath. |
39
|
|
|
* |
40
|
|
|
* @return Path|null |
41
|
|
|
*/ |
42
|
|
|
public function getClasspath(): ?Path |
43
|
|
|
{ |
44
|
|
|
return $this->classpath; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param Path $classpath |
49
|
|
|
* |
50
|
|
|
* @throws \Phing\Exception\BuildException |
51
|
|
|
*/ |
52
|
14 |
|
public function setClasspath(Path $classpath): void |
53
|
|
|
{ |
54
|
14 |
|
if ($this->classpath === null) { |
55
|
14 |
|
$this->classpath = $classpath; |
56
|
|
|
} else { |
57
|
|
|
$this->classpath->append($classpath); |
58
|
|
|
} |
59
|
14 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return Path |
63
|
|
|
* |
64
|
|
|
* @throws \Phing\Exception\BuildException |
65
|
|
|
*/ |
66
|
13 |
|
public function createClasspath(): Path |
67
|
|
|
{ |
68
|
13 |
|
if ($this->classpath === null) { |
69
|
13 |
|
$this->classpath = new Path(); |
70
|
|
|
} |
71
|
|
|
|
72
|
13 |
|
return $this->classpath->createPath(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Reference to a classpath to use when loading the files. |
77
|
|
|
* |
78
|
|
|
* @param Reference $r |
79
|
|
|
* |
80
|
|
|
* @throws BuildException |
81
|
|
|
*/ |
82
|
|
|
public function setClasspathRef(Reference $r): void |
83
|
|
|
{ |
84
|
|
|
$this->classpathId = $r->getRefId(); |
85
|
|
|
$this->createClasspath()->setRefid($r); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|