How to download a jar using maven programmatically

I am writing an application that requires me to download a jar based on mavens groupid / artifactid / version.

I am currently starting with

public Model pomToModel(String pomUrl) throws Exception {
URL url = new URL(pomUrl);
    InputStream stream = url.openStream();
    try {
        Model model = new MavenXpp3Reader().read(stream);
        return model;
    } finally {
        stream.close();
    }
}

Therefore, given the POM URL, I now have a maven Model object representing it. This seems to work well.

What I would like to know are two things:

  • find the jar artifact url that the model represents in the maven repository that the maven plugin used
  • based on the model, find the file representing the jar in the local repository

: mvnrepository.com , URL-, ~/.m2/repository . , , , , maven.

, , maven.

google, - maven jars ( stackoverflow) , , maven, maven.

+5
2

1

, khmarbaise.

, Maven 3.0

2

Maven script, Apache ivy standalone jar.

:

IVY

3

Maven , .

, log4j Maven Central:

curl -O http://search.maven.org/remotecontent?filepath=log4j/log4j/1.2.17/log4j-1.2.17.jar

Nexus, API REST

API Nexus rest groupid/artifactId

+5

All Articles