line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
24
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
148
|
|
2
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
253
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::Repositories; |
5
|
|
|
|
|
|
|
$Maven::Repositories::VERSION = '1.13'; |
6
|
|
|
|
|
|
|
# ABSTRACT: An ordered collection of repositories from which to resolve artifacts |
7
|
|
|
|
|
|
|
# PODNAME: Maven::Repositories |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
1478
|
use parent qw(Class::Accessor); |
|
5
|
|
|
|
|
813
|
|
|
5
|
|
|
|
|
49
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice; |
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(repositories)); |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
10542
|
use Carp; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
336
|
|
14
|
5
|
|
|
5
|
|
24
|
use Log::Any; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
36
|
|
15
|
5
|
|
|
5
|
|
2133
|
use Maven::LocalRepository; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Maven::RemoteRepository; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
|
|
|
|
|
|
return bless( {}, shift )->_init(@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub add_central { |
25
|
|
|
|
|
|
|
my ( $self, @args ) = @_; |
26
|
|
|
|
|
|
|
$logger->debug('adding central'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return $self->add_repository( 'http://repo.maven.apache.org/maven2', @args ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _artifact_not_found { |
32
|
|
|
|
|
|
|
my ( $self, $coordinate_or_artifact, $options ) = @_; |
33
|
|
|
|
|
|
|
my $artifact = |
34
|
|
|
|
|
|
|
ref($coordinate_or_artifact) |
35
|
|
|
|
|
|
|
&& UNIVERSAL::isa( $coordinate_or_artifact, 'Maven::Artifact' ) |
36
|
|
|
|
|
|
|
? $coordinate_or_artifact |
37
|
|
|
|
|
|
|
: Maven::Artifact->new( $coordinate_or_artifact, %$options )->get_coordinate(); |
38
|
|
|
|
|
|
|
return "artifact $artifact not found"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub add_local { |
42
|
|
|
|
|
|
|
my ( $self, $local_repository_path, @args ) = @_; |
43
|
|
|
|
|
|
|
$logger->debugf( 'adding local %s', $local_repository_path ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
push( |
46
|
|
|
|
|
|
|
@{ $self->{repositories} }, |
47
|
|
|
|
|
|
|
Maven::LocalRepository->new( $local_repository_path, @args ) |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add_repository { |
54
|
|
|
|
|
|
|
my ( $self, $url, @args ) = @_; |
55
|
|
|
|
|
|
|
$logger->debugf( 'adding repo %s', $url ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
push( @{ $self->{repositories} }, Maven::RemoteRepository->new( $url, @args ) ); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _init { |
63
|
|
|
|
|
|
|
my ( $self, @args ) = @_; |
64
|
|
|
|
|
|
|
$logger->trace('initializing repositories'); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$self->{repositories} = []; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_repository { |
72
|
|
|
|
|
|
|
my ( $self, $url ) = @_; |
73
|
|
|
|
|
|
|
foreach my $repository ( @{ $self->{repositories} } ) { |
74
|
|
|
|
|
|
|
if ( $repository->contains($url) ) { |
75
|
|
|
|
|
|
|
return $repository; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub resolve { |
82
|
|
|
|
|
|
|
my ( $self, $coordinate_or_artifact, @parts ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $artifact; |
85
|
|
|
|
|
|
|
foreach my $repository ( @{ $self->{repositories} } ) { |
86
|
|
|
|
|
|
|
last if ( $artifact = $repository->resolve( $coordinate_or_artifact, @parts ) ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
return $artifact; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub resolve_or_die { |
93
|
|
|
|
|
|
|
my ( $self, $coordinate_or_artifact, %parts ) = @_; |
94
|
|
|
|
|
|
|
my $resolved = $self->resolve( $coordinate_or_artifact, %parts ); |
95
|
|
|
|
|
|
|
croak( $self->_artifact_not_found( $coordinate_or_artifact, \%parts ) ) if ( !$resolved ); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return $resolved; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |