Maven::MvnAgent - An agent for downloading artifacts using the mvn command
version 1.03
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');
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.
download
mvn dependency:get
Creates a new agent. %options is passed through to "new([%options])" in Maven::Maven.
%options
Deploys $file to $repository_url as $artifact. Generates the command from the arguments using deploy_command
$file
$repository_url
$artifact
deploy_command
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)
mvn
$repository_id
%maven_options
Downloads $artifact, caching a copy in the local repository and returns the path to the file. The current options are:
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.
artifactId.packaging
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
Returns an mvn command string to download $artifact to the local repository. %maven_options and %options are described on mvn_command)
Returns the Maven::Maven object.
Maven::Maven
Installs $file in the local repository as $artifact. Generates the command from the arguments using install_command.
install_command
Returns an mvn command string to install $file in the local repository. %maven_options and %options are described on mvn_command)
Returns a truthy value if $artifact is found in the local repository. This method expects $artifact to have already been resolved.
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.
uri
undef
%parts
Calls resolve, and, if resolution was successful, the new $artifact will be returned, otherwise, croak will be called.
croak
Lucas Theisen <lucastheisen@pastdev.com>
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.
Please see those modules/websites for more information related to this module.
Maven::Agent
Maven::MvnAgent
Maven::Artifact
To install Maven::Agent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Maven::Agent
CPAN shell
perl -MCPAN -e shell install Maven::Agent
For more information on module installation, please visit the detailed CPAN module installation guide.