line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
1702
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
113
|
|
2
|
5
|
|
|
5
|
|
12
|
use warnings; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
367
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::Repository; |
5
|
|
|
|
|
|
|
$Maven::Repository::VERSION = '1.12'; |
6
|
|
|
|
|
|
|
# ABSTRACT: An repository from which to resolve artifacts |
7
|
|
|
|
|
|
|
# PODNAME: Maven::Repository |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
25
|
use parent qw(Class::Accessor); |
|
5
|
|
|
|
|
4
|
|
|
5
|
|
|
|
|
30
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice; |
11
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(agent url)); |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
302
|
use Carp; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
245
|
|
14
|
5
|
|
|
5
|
|
23
|
use Log::Any; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
23
|
|
15
|
5
|
|
|
5
|
|
1971
|
use Maven::Artifact; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
46
|
|
16
|
5
|
|
|
5
|
|
2555
|
use Maven::Xml::Metadata; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
|
|
|
|
|
|
return bless( {}, shift )->_init(@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _build_url { |
25
|
|
|
|
|
|
|
my ( $self, $artifact ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my @url = |
28
|
|
|
|
|
|
|
( $self->{url}, split( /\./, $artifact->get_groupId() ), $artifact->get_artifactId() ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $artifact_name; |
31
|
|
|
|
|
|
|
if ( !$artifact->get_version() ) { |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# no version specified, detect latest |
34
|
|
|
|
|
|
|
$logger->trace('version not specified, detecting...'); |
35
|
|
|
|
|
|
|
my $version = $self->_detect_latest_version( join( '/', @url ) ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return if ( !$version ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$artifact->set_version($version); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
if ( $artifact->get_version() =~ /^.*-SNAPSHOT$/ ) { |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# snapshot version, detect most recent timestamp |
44
|
|
|
|
|
|
|
my $snapshotVersion = $self->_detect_latest_snapshotVersion( |
45
|
|
|
|
|
|
|
join( '/', @url, $artifact->get_version() ), |
46
|
|
|
|
|
|
|
$artifact->get_packaging(), |
47
|
|
|
|
|
|
|
$artifact->get_classifier() |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return if ( !$snapshotVersion ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$artifact_name = join( '-', $artifact->get_artifactId(), $snapshotVersion->get_value() ); |
53
|
|
|
|
|
|
|
if ( $artifact->get_classifier() ) { |
54
|
|
|
|
|
|
|
$artifact_name .= '-' . $artifact->get_classifier(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
$artifact_name .= '.' . $artifact->get_packaging(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
|
|
|
|
|
|
$artifact_name = join( '-', $artifact->get_artifactId(), $artifact->get_version() ); |
60
|
|
|
|
|
|
|
if ( $artifact->get_classifier() ) { |
61
|
|
|
|
|
|
|
$artifact_name .= '-' . $artifact->get_classifier(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
$artifact_name .= '.' . $artifact->get_packaging(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
$artifact->set_artifact_name($artifact_name); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $url = join( '/', @url, $artifact->get_version(), $artifact_name ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# verify version is available in repo |
70
|
|
|
|
|
|
|
$logger->tracef( |
71
|
|
|
|
|
|
|
'verifying version %s is available on %s', |
72
|
|
|
|
|
|
|
$artifact->get_version(), |
73
|
|
|
|
|
|
|
$self->to_string() |
74
|
|
|
|
|
|
|
) if ( $logger->is_trace() ); |
75
|
|
|
|
|
|
|
return $self->_has_version($url) ? $url : undef; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub contains { |
79
|
|
|
|
|
|
|
my ( $self, $url ) = @_; |
80
|
|
|
|
|
|
|
return $self->{url} eq substr( $url, 0, length( $self->{url} ) ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _detect_latest_snapshotVersion { |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _detect_latest_version { |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _has_version { |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _init { |
93
|
|
|
|
|
|
|
my ( $self, $url, %args ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->{url} = $url; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return $self; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub resolve { |
101
|
|
|
|
|
|
|
my ( $self, $artifact, @parts ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
if ( ref($artifact) eq 'Maven::Artifact' ) { |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# already resolved, no need to do so again |
106
|
|
|
|
|
|
|
return $artifact if ( $artifact->get_url() ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else { |
109
|
|
|
|
|
|
|
$artifact = Maven::Artifact->new( $artifact, @parts ); |
110
|
|
|
|
|
|
|
$logger->trace( 'resolving ', $artifact ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
croak('invalid artifact, no groupId') if ( !$artifact->get_groupId() ); |
113
|
|
|
|
|
|
|
croak('invalid artifact, no artifactId') if ( !$artifact->get_artifactId() ); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $url = $self->_build_url($artifact); |
116
|
|
|
|
|
|
|
if ( defined($url) ) { |
117
|
|
|
|
|
|
|
$artifact->set_url($url); |
118
|
|
|
|
|
|
|
return $artifact; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub to_string { |
124
|
|
|
|
|
|
|
my ($self) = @_; |
125
|
|
|
|
|
|
|
return $self->{url}; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |