Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the latest version of an artifact from a maven repository

As part of an automated deployment I need a script to download the latest version of an artifact from our internal repository.

Ideally this script will be with ant or a unix shell script.

So for example:

I have myArtifact.war and it has versions 1.0 , 1.1 and 2.0 - I need the script given the correct group id and artifact id to retrieve version 2.0 from our maven repository (currently using artifactory).

Is there any easy way to do this?

like image 357
Pablojim Avatar asked Jul 29 '09 10:07

Pablojim


People also ask

How do I mention the latest version of POM?

versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version. versions:use-latest-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the latest release version.

What is artifact version?

An artifact is a file, usually a JAR, that gets deployed to a Maven repository. A Maven build produces one or more artifacts, such as a compiled JAR and a "sources" JAR. Each artifact has a group ID (usually a reversed domain name, like com. example. foo), an artifact ID (just a name), and a version string.

Is Maven an artifact repository?

As a Maven repository, Artifactory is both a source for artifacts needed for a build, and a target to deploy artifacts generated in the build process. Maven is configured using a settings. xml file located under your Maven home directory (typically, this will be /user.

How do I view Maven repository?

To browse Maven repositories and to manipulate repository indexes open the Maven Repositories view by selecting Windows, Show View, Other... Once you select Other... Eclipse will display a dialog containing all available views. Select the Maven Repositories view under the Maven folder in the Show View dialog.


1 Answers

You can use the Maven Dependency Plugin goal get together with LATEST as version for your artifact:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get     -DremoteRepositories=<URL_to_your_maven_repo>     -Dartifact=<group_id>:<artifact_id>:LATEST     -Dpackaging=jar     -Ddest=<target_dir>/<artifact_name>.jar 
like image 66
Michael Tamm Avatar answered Oct 01 '22 21:10

Michael Tamm