Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving Maven Artifact from Repository using Maven Java API

If I have a Maven Artifact information (GroupId, ArtifactId, Version) how can I programmatically (using Java) retrieve that Artifact from my local repository?

Specifically, I need to be able to connect to the Maven Repository and create/retrieve a org.apache.maven.artifact.Artifact so I can retrieve the file associated with the Artifact.

I have looked into m2e source code, but the MavenImpl.java (which provides Artifact resolution) is way more complex than what I need and it is difficult to understand how the connection to the repository works.

like image 490
davdic Avatar asked Jul 26 '12 17:07

davdic


People also ask

How do I download artifacts from Artifactory using Maven?

Once you have created your Maven repository, go to Application | Artifactory | Artifacts, select your Maven repository and click Set Me Up. In the Set Me Up dialog, click Generate Maven Settings. You can now specify the repositories you want to configure for Maven.

How do I access a Maven repository?

Where is the Maven Central repository? Maven Central can be accessed from https://repo.maven.apache.org/maven2/.

Where does Maven store artifacts downloaded from remote repository?

the local repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.


1 Answers

You'll probably want to look at Aether. See the Wiki for examples.

like image 156
Philippe Marschall Avatar answered Sep 19 '22 14:09

Philippe Marschall