NAME
Maven::MvnAgent - An agent for downloading artifacts using the mvn command
VERSION
version 1.12
SYNOPSIS
use Maven::MvnAgent;
my $agent = Maven::Agent->new();
Or if you need to configure your own LWP
my $lwp = LWP::UserAgent->new();
$lwp->env_proxy();
my $agent = Maven::MvnAgent->new(agent => $lwp);
my $maybe_artifact = $agent->resolve(
'javax.servlet:servlet-api:2.5');
if ($maybe_artifact) {
# use it
}
my $artifact = $agent->resolve_or_die(
'javax.servlet:servlet-api:2.5');
my $servlet_api_jar = $agent->download('javax.servlet:servlet-api:2.5');
$agent->download('javax.servlet:servlet-api:2.5',
to => '/path/to/some/directory');
DESCRIPTION
This agent extends Maven::Agent in order to wrap download
with an mvn dependency:get
therby caching the artifact in the local repository so that later attempts to resolve the artifact will find it there. It also adds a couple additional functions to publish to repositories, both local, and remote.
CONSTRUCTORS
new([%options])
Creates a new agent. The available options are all options for "new([%options])" in Maven::Maven, plus:
- command_runner
-
A subroutine to run
mvn
commands. This subroutine will be called with a single argumentcommand
that must be executed. The subroutine MUST die if the command fails.
METHODS
deploy([\%maven_options], $artifact, $file, $repository_id, $repository_url, [%options])
Deploys $file
to $repository_url
as $artifact
. Generates the command from the arguments using deploy_command
deploy_command([\%maven_options], $artifact, $file, $repository_id, $repository_url, [%options])
Returns an mvn
command string to deploy $file
to $repository_url
as $artifact
. $repository_id
indicates a server id in the effective settings that contains the required credentials for the operation. %maven_options
and %options
are described on mvn_command)
download($artifact, [%options])
Downloads $artifact
, caching a copy in the local repository and returns the path to the file. The current options are:
- to
-
The path to download the artifact to. If the path is a directory, the download filename will be
artifactId.packaging
. Defaults to the proper location in the local repository.
get([\%maven_options], $artifact, [%options])
Downloads $artifact
to the local repository and returns an Maven::Artifact already resolved to its local location. Generates the command from the arguments using get_command
.
get_command([\%maven_options], $artifact, [%options])
Returns an mvn
command string to download $artifact
to the local repository. %maven_options
and %options
are described on mvn_command)
get_maven
Returns the Maven::Maven
object.
install([\%maven_options], $artifact, $file, [%options])
Installs $file
in the local repository as $artifact
. Generates the command from the arguments using install_command
.
install_command([\%maven_options], $artifact, $file, [%options])
Returns an mvn
command string to install $file
in the local repository. %maven_options
and %options
are described on mvn_command)
is_local($artifact)
Returns a truthy value if $artifact
is found in the local repository. This method expects $artifact
to have already been resolved.
resolve($artifact, [%parts])
Will attempt to resolve $artifact
. $artifact
can be either an instance of Maven::Artifact or a coordinate string of the form groupId:artifactId[:packaging[:classifier]]:version If resolution was successful, a new Maven::Artifact will be returned with its uri
set. Otherwise, undef
will be returned. If %parts
are supplied, their values will be used to override the corresponding values in $artifact
before resolution is attempted.
resolve_or_die($artifact)
Calls resolve, and, if resolution was successful, the new $artifact
will be returned, otherwise, croak
will be called.
AUTHOR
Lucas Theisen <lucastheisen@pastdev.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Lucas Theisen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
SEE ALSO
Please see those modules/websites for more information related to this module.