line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
23
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
154
|
|
2
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
310
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::LocalRepository; |
5
|
|
|
|
|
|
|
$Maven::LocalRepository::VERSION = '1.13'; |
6
|
|
|
|
|
|
|
# ABSTRACT: An local repository from which to resolve artifacts |
7
|
|
|
|
|
|
|
# PODNAME: Maven::LocalRepository |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
22
|
use parent qw(Maven::Repository); |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
26
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice; |
11
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(url)); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Log::Any; |
14
|
|
|
|
|
|
|
use Maven::Xml::Metadata; |
15
|
|
|
|
|
|
|
use Maven::Xml::Settings; |
16
|
|
|
|
|
|
|
use Sort::Versions; |
17
|
|
|
|
|
|
|
use URI::file; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _by_maven_version { |
22
|
|
|
|
|
|
|
if ( $a =~ /^$b-SNAPSHOT$/ ) { |
23
|
|
|
|
|
|
|
return -1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif ( $b =~ /^$a-SNAPSHOT$/ ) { |
26
|
|
|
|
|
|
|
return 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
else { |
29
|
|
|
|
|
|
|
return versioncmp( $a, $b ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _detect_latest_snapshotVersion { |
34
|
|
|
|
|
|
|
my ( $self, $base_url, $extension, $classifier ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$logger->tracef( 'loading snapshot metadata from %s', $base_url ); |
37
|
|
|
|
|
|
|
my @versions = sort _by_maven_version $self->_list_versions( $base_url, 1 ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return pop(@versions); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _detect_latest_version { |
43
|
|
|
|
|
|
|
my ( $self, $base_url ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$logger->tracef( 'loading metadata from %s', $base_url ); |
46
|
|
|
|
|
|
|
my @versions = sort _by_maven_version $self->_list_versions($base_url); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return pop(@versions); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _has_version { |
52
|
|
|
|
|
|
|
my ( $self, $url ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $has_version = ( -f $self->_path_from_url($url) ); |
55
|
|
|
|
|
|
|
$logger->debugf( 'version %s at %s', ( $has_version ? 'found' : 'not found' ), $url ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return $has_version; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _init { |
61
|
|
|
|
|
|
|
my ( $self, $local_repository_path, @args ) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$self->Maven::Repository::_init( |
64
|
|
|
|
|
|
|
URI::file->new( |
65
|
|
|
|
|
|
|
$^O =~ /^cygwin$/i |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#? Cygwin::win_to_posix_path($local_repository_path) |
68
|
|
|
|
|
|
|
? `cygpath -u $local_repository_path` |
69
|
|
|
|
|
|
|
: $local_repository_path |
70
|
|
|
|
|
|
|
)->as_string() |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return $self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _list_versions { |
77
|
|
|
|
|
|
|
my ( $self, $base_url, $snapshot ) = @_; |
78
|
|
|
|
|
|
|
my $base_path = $self->_path_from_url($base_url); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my ( $artifact, $version ); |
81
|
|
|
|
|
|
|
if ($snapshot) { |
82
|
|
|
|
|
|
|
my @parts = File::Spec->splitdir($base_path); |
83
|
|
|
|
|
|
|
$version = pop(@parts); |
84
|
|
|
|
|
|
|
$artifact = pop(@parts); |
85
|
|
|
|
|
|
|
$version =~ s/-SNAPSHOT$//; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my @versions = (); |
89
|
|
|
|
|
|
|
opendir( my $dir_handle, $base_path ) || return (); |
90
|
|
|
|
|
|
|
while ( my $entry = readdir($dir_handle) ) { |
91
|
|
|
|
|
|
|
next if ( $entry =~ /^\.+$/ ); |
92
|
|
|
|
|
|
|
my $path = File::Spec->catdir( $base_path, $entry ); |
93
|
|
|
|
|
|
|
if ($snapshot) { |
94
|
|
|
|
|
|
|
if ( $path =~ /.*\/$artifact-$version-(.*)/ ) { |
95
|
|
|
|
|
|
|
my $rest = $1; |
96
|
|
|
|
|
|
|
if ( $rest =~ /^SNAPSHOT(?:-(.*?))?\.([^\.]*)$/ ) { |
97
|
|
|
|
|
|
|
my $snapshotVersion = Maven::Xml::Metadata::SnapshotVersion->new(); |
98
|
|
|
|
|
|
|
$snapshotVersion->{value} = "$version-SNAPSHOT"; |
99
|
|
|
|
|
|
|
$snapshotVersion->{extension} = $2; |
100
|
|
|
|
|
|
|
$snapshotVersion->{classifier} = $1; |
101
|
|
|
|
|
|
|
push( @versions, $snapshotVersion ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
|
|
|
|
|
|
if ( -d $path ) { |
107
|
|
|
|
|
|
|
push( @versions, $entry ); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
closedir($dir_handle); |
112
|
|
|
|
|
|
|
return @versions; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _path_from_url { |
116
|
|
|
|
|
|
|
my ( $self, $url ) = @_; |
117
|
|
|
|
|
|
|
my $path = URI->new($url)->path(); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# if windows, we have to strip the leading / |
120
|
|
|
|
|
|
|
# from /C:/... |
121
|
|
|
|
|
|
|
$path =~ s/^\/([A-Za-z]:)/$1/; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
return $path; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |