Utility for downloading artifacts from maven repo without mvn/poms [closed]

寵の児 提交于 2019-12-23 13:32:18

问题


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?


回答1:


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




回答2:


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).



回答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.




回答4:


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.




回答5:


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.




回答6:


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



来源:https://stackoverflow.com/questions/884808/utility-for-downloading-artifacts-from-maven-repo-without-mvn-poms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!