| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
14385
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
41
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::MvnAgent; |
|
5
|
|
|
|
|
|
|
$Maven::MvnAgent::VERSION = '1.12'; |
|
6
|
|
|
|
|
|
|
# ABSTRACT: An agent for downloading artifacts using the mvn command |
|
7
|
|
|
|
|
|
|
# PODNAME: Maven::MvnAgent |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
385
|
use parent qw(Maven::Agent); |
|
|
1
|
|
|
|
|
234
|
|
|
|
1
|
|
|
|
|
4
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Carp qw(croak); |
|
12
|
|
|
|
|
|
|
use File::Copy qw(copy); |
|
13
|
|
|
|
|
|
|
use Log::Any; |
|
14
|
|
|
|
|
|
|
use Maven::Command qw( |
|
15
|
|
|
|
|
|
|
mvn_artifact_params |
|
16
|
|
|
|
|
|
|
mvn_command |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _artifact_command { |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# [\%maven_options] $artifact @_ |
|
24
|
|
|
|
|
|
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
my $maven_options = ref( $_[0] ) eq 'HASH' ? shift : {}; |
|
26
|
|
|
|
|
|
|
my $artifact = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if ( !$artifact->isa('Maven::Artifact') ) { |
|
29
|
|
|
|
|
|
|
$artifact = Maven::Artifact->new($artifact); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
if ( !$maven_options->{'--settings'} ) { |
|
33
|
|
|
|
|
|
|
my $file = $self->{maven}->dot_m2('settings.xml'); |
|
34
|
|
|
|
|
|
|
$maven_options->{'--settings'} = |
|
35
|
|
|
|
|
|
|
$^O eq 'cygwin' |
|
36
|
|
|
|
|
|
|
? Cygwin::posix_to_win_path($file) |
|
37
|
|
|
|
|
|
|
: $file; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
if ( !$maven_options->{'--global-settings'} ) { |
|
40
|
|
|
|
|
|
|
my $file = $self->{maven}->m2_home( 'conf', 'settings.xml' ); |
|
41
|
|
|
|
|
|
|
$maven_options->{'--global-settings'} = |
|
42
|
|
|
|
|
|
|
$^O eq 'cygwin' |
|
43
|
|
|
|
|
|
|
? Cygwin::posix_to_win_path($file) |
|
44
|
|
|
|
|
|
|
: $file; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
if ( !$maven_options->{'-Duser.home'} ) { |
|
47
|
|
|
|
|
|
|
my $path = $self->{maven}->get_property('user.home'); |
|
48
|
|
|
|
|
|
|
$maven_options->{'-Duser.home'} = |
|
49
|
|
|
|
|
|
|
$^O eq 'cygwin' |
|
50
|
|
|
|
|
|
|
? Cygwin::posix_to_win_path($path) |
|
51
|
|
|
|
|
|
|
: $path; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return $self, $maven_options, $artifact, @_; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub deploy { |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# [\%maven_options], $artifact, $file, $repository_id, $repository_url, [%options] |
|
60
|
|
|
|
|
|
|
my ( $self, @args ) = _artifact_command(@_); |
|
61
|
|
|
|
|
|
|
$self->_run_or_die( $self->deploy_command(@args) ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub deploy_command { |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# [\%maven_options], $artifact, $file, $repository_id, $repository_url, [%options] |
|
67
|
|
|
|
|
|
|
my ( $self, $maven_options, $artifact, $file, $repository_id, $repository_url, %options ) = |
|
68
|
|
|
|
|
|
|
_artifact_command(@_); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $maven_deploy_plugin_version = $options{maven_deploy_plugin_version} || '2.8.2'; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return mvn_command( |
|
73
|
|
|
|
|
|
|
$maven_options, |
|
74
|
|
|
|
|
|
|
"org.apache.maven.plugins:maven-deploy-plugin:$maven_deploy_plugin_version:deploy-file", |
|
75
|
|
|
|
|
|
|
{ mvn_artifact_params($artifact), |
|
76
|
|
|
|
|
|
|
file => $^O eq 'cygwin' |
|
77
|
|
|
|
|
|
|
? Cygwin::posix_to_win_path($file) |
|
78
|
|
|
|
|
|
|
: $file, |
|
79
|
|
|
|
|
|
|
repositoryId => $repository_id, |
|
80
|
|
|
|
|
|
|
url => $repository_url |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _download_remote { |
|
86
|
|
|
|
|
|
|
my ( $self, $artifact, $file ) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $uri = $self->get($artifact)->get_uri(); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
if ($file) { |
|
91
|
|
|
|
|
|
|
copy( $uri->path(), $file ) |
|
92
|
|
|
|
|
|
|
|| croak('failed to copy file $!'); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
else { |
|
95
|
|
|
|
|
|
|
$file = $uri->path(); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
return $file; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub get { |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# [\%maven_options], $artifact, [%options] |
|
104
|
|
|
|
|
|
|
my ( $self, $maven_options, $artifact, %options ) = _artifact_command(@_); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$self->_run_or_die( $self->get_command( $maven_options, $artifact, %options ) ); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
return $self->resolve_or_die( $artifact->get_coordinate() ); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_command { |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# [\%maven_options], $artifact, [%options] |
|
114
|
|
|
|
|
|
|
my ( $self, $maven_options, $artifact, %options ) = _artifact_command(@_); |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $maven_dependency_plugin_version = $options{maven_dependency_plugin_version} || '2.10'; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my @repositories = (); |
|
119
|
|
|
|
|
|
|
foreach my $repository ( @{ $self->{maven}->get_repositories()->get_repositories() } ) { |
|
120
|
|
|
|
|
|
|
next if ( $repository->isa('Maven::LocalRepository') ); |
|
121
|
|
|
|
|
|
|
push( @repositories, $repository->get_url() ); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return mvn_command( |
|
125
|
|
|
|
|
|
|
$maven_options, |
|
126
|
|
|
|
|
|
|
"org.apache.maven.plugins:maven-dependency-plugin:$maven_dependency_plugin_version:get", |
|
127
|
|
|
|
|
|
|
{ mvn_artifact_params($artifact), remoteRepositories => join( ',', @repositories ) } |
|
128
|
|
|
|
|
|
|
); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub _init { |
|
132
|
|
|
|
|
|
|
my ( $self, %options ) = @_; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$self->Maven::Agent::_init(%options); |
|
135
|
|
|
|
|
|
|
$self->{command_runner} = $options{command_runner}; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
return $self; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub install { |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# [\%maven_options], $artifact, $file, [%options] |
|
143
|
|
|
|
|
|
|
my ( $self, @args ) = _artifact_command(@_); |
|
144
|
|
|
|
|
|
|
$self->_run_or_die( $self->install_command(@args) ); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub install_command { |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# [\%maven_options], $artifact, $file, [%options] |
|
150
|
|
|
|
|
|
|
my ( $self, $maven_options, $artifact, $file, %options ) = _artifact_command(@_); |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $maven_install_plugin_version = $options{maven_install_plugin_version} || '2.5.2'; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
return mvn_command( |
|
155
|
|
|
|
|
|
|
$maven_options, |
|
156
|
|
|
|
|
|
|
"org.apache.maven.plugins:maven-install-plugin:$maven_install_plugin_version:install-file", |
|
157
|
|
|
|
|
|
|
{ mvn_artifact_params($artifact), |
|
158
|
|
|
|
|
|
|
file => $^O eq 'cygwin' |
|
159
|
|
|
|
|
|
|
? Cygwin::posix_to_win_path($file) |
|
160
|
|
|
|
|
|
|
: $file |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub _run_or_die { |
|
166
|
|
|
|
|
|
|
my ( $self, $command ) = @_; |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
if ( $self->{command_runner} ) { |
|
169
|
|
|
|
|
|
|
&{ $self->{command_runner} }($command); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
else { |
|
172
|
|
|
|
|
|
|
my $output = `$command`; |
|
173
|
|
|
|
|
|
|
$logger->tracef( "%s\n---- STDOUT ----\n%s\n---- END STDOUT ----", $command, $output ); |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
croak( "Command [$command] failed: " . ( $? >> 8 ) ) if ($?); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
__END__ |