4

Is there a maven client that isn't mvn (the binary included with the maven distribution) I could use to pull down an artifact from a maven repository without using a pom? I'd like to use a maven repository as the repo for our ops team to pick up builds (including snapshots of builds) but I don't want them to have to mess around with writing poms and declaring dependencies in them. Ideally, I'm looking for just a cli client that I could just pass in a repo url and coordinates and download a given artifact. Does such a thing exist or am I better off writing a one-off script for this?

yegor256
  • 102,010
  • 123
  • 446
  • 597
whaley
  • 16,075
  • 10
  • 57
  • 68
  • I believe this is the api whaley is referring to http://nexus.sonatype.org/nexus-faq.html#25 –  Jul 30 '10 at 21:22

6 Answers6

8

I see 3 easy options:

  1. Just send them a link pointing on your artifact in your repository and have them use their browser.
  2. Install and use wget (wget http://path/to/artifact.extension).
  3. Install and use mvn dependency:get (requires mvn but doesn't require a pom.xml, see this answer for more details).
Community
  • 1
  • 1
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
4

Use Nexus. It provides a web interface that other teams can use to download artifacts. http://nexus.sonatype.org/

Taylor Leese
  • 51,004
  • 28
  • 112
  • 141
  • I was already using Nexus and I just found out about their url api for yanking down artifacts based on coordinates. One of the nexus devs informed me of it on their irc channel yesterday. thanks for the answer though. – whaley May 21 '09 at 16:18
3

Use the maven embedder. More to the point, use the functionality inside the maven embedder for resolving and downloading jars. Although if you're trying to just write a simple CLI, the repository structure isn't complex and you could easily write a script that takes a maven repo url, artifact ID, group ID and version to generate the full URL to the jar.

Tobias Schulte
  • 3,765
  • 1
  • 29
  • 33
Jherico
  • 28,584
  • 8
  • 61
  • 87
1

This is how we do it in jcabi-aether:

final File repo = this.session.getLocalRepository().getBasedir();
final Collection<Artifact> deps = new Aether(this.getProject(), repo).resolve(
  new DefaultArtifact("junit", "junit-dep", "", "jar", "4.10"),
  JavaScopes.RUNTIME
);

All you need to provide to this lib is 1) a list of remote repositories, 2) location of a local repo, and 3) Maven coordinates of the artifact. The library uses Apache Aether from Sonatype.

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • can we use this plugin to download a requested artifact in to user desired location and any feature to extract it to a given location? – gihan-maduranga Apr 28 '17 at 16:50
0

Think about Pax URL which lets you use plain URLs to reference maven artifacts like so:

mvn:groupId/artifactId/version

See PAX URL Website for more info (MVN Protocol Handler).

Toni

Toni Menzel
  • 764
  • 3
  • 10
0

Well technically the repository is accessed over HTTP, so given the repository location, artifact and coordinates, it should just be possible to give your ops team a URL to the artifact that they can hit in any browser.

matt b
  • 138,234
  • 66
  • 282
  • 345
  • That gets a little hairy with snapshots, since the actual artifact filename in the repository has a timestamp and I wanted them to be able to pull down any artifact in a programmatic fashion. I was already using nexus and it turns out they have an api for this already. – whaley May 21 '09 at 16:19
  • Gotcha - good to know about nexus – matt b May 21 '09 at 17:15
  • 1
    @whaley can you post a link to the Nexus API? – Rich Seller Jul 03 '09 at 12:03