用于从没有mvn / poms的maven repo下载工件的实用程序

时间:2021-01-07 23:57:03

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?

是否有一个不是mvn的maven客户端(maven发行版中包含的二进制文件)我可以用来从maven存储库中下载一个工件而不使用pom?我想使用maven存储库作为我们的ops团队的repo来获取构建(包括构建的快照),但我不希望他们不得不乱写pom并在其中声明依赖。理想情况下,我正在寻找一个cli客户端,我可以通过repo url传递并协调和下载给定的工件。这样的事情是存在还是我最好为此写一个一次性的脚本?

6 个解决方案

#1


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

使用Nexus。它提供了一个Web界面,其他团队可以使用它来下载工件。 http://nexus.sonatype.org/

#2


I see 3 easy options:

我看到3个简单的选择:

  1. Just send them a link pointing on your artifact in your repository and have them use their browser.
  2. 只需向他们发送指向您的存储库中的工件的链接,并让他们使用他们的浏览器。

  3. Install and use wget (wget http://path/to/artifact.extension).
  4. 安装并使用wget(wget http://path/to/artifact.extension)。

  5. Install and use mvn dependency:get (requires mvn but doesn't require a pom.xml, see this answer for more details).
  6. 安装并使用mvn依赖项:get(需要mvn但不需要pom.xml,请参阅此答案以获取更多详细信息)。

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

使用maven嵌入器。更重要的是,使用maven嵌入器内部的功能来解析和下载jar。虽然如果您只是想编写一个简单的CLI,但是存储库结构并不复杂,您可以轻松编写一个脚本,该脚本接受maven repo url,工件ID,组ID和版本以生成jar的完整URL。

#4


This is how we do it in jcabi-aether:

这就是我们在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.

您需要为此lib提供的只是1)远程存储库列表,2)本地存储库的位置,以及3)工件的Maven坐标。该库使用Sonatype的Apache Aether。

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

从技术上讲,存储库是通过HTTP访问的,因此在给定存储库位置,工件和坐标的情况下,应该可以为您的运营团队提供他们可以在任何浏览器中访问的工件的URL。

#6


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

考虑一下Pax URL,它允许您使用普通URL来引用maven工件,如下所示:

mvn:groupId/artifactId/version

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

有关详细信息,请参阅PAX URL网站(MVN协议处理程序)。

Toni

#1


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

使用Nexus。它提供了一个Web界面,其他团队可以使用它来下载工件。 http://nexus.sonatype.org/

#2


I see 3 easy options:

我看到3个简单的选择:

  1. Just send them a link pointing on your artifact in your repository and have them use their browser.
  2. 只需向他们发送指向您的存储库中的工件的链接,并让他们使用他们的浏览器。

  3. Install and use wget (wget http://path/to/artifact.extension).
  4. 安装并使用wget(wget http://path/to/artifact.extension)。

  5. Install and use mvn dependency:get (requires mvn but doesn't require a pom.xml, see this answer for more details).
  6. 安装并使用mvn依赖项:get(需要mvn但不需要pom.xml,请参阅此答案以获取更多详细信息)。

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

使用maven嵌入器。更重要的是,使用maven嵌入器内部的功能来解析和下载jar。虽然如果您只是想编写一个简单的CLI,但是存储库结构并不复杂,您可以轻松编写一个脚本,该脚本接受maven repo url,工件ID,组ID和版本以生成jar的完整URL。

#4


This is how we do it in jcabi-aether:

这就是我们在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.

您需要为此lib提供的只是1)远程存储库列表,2)本地存储库的位置,以及3)工件的Maven坐标。该库使用Sonatype的Apache Aether。

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

从技术上讲,存储库是通过HTTP访问的,因此在给定存储库位置,工件和坐标的情况下,应该可以为您的运营团队提供他们可以在任何浏览器中访问的工件的URL。

#6


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

考虑一下Pax URL,它允许您使用普通URL来引用maven工件,如下所示:

mvn:groupId/artifactId/version

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

有关详细信息,请参阅PAX URL网站(MVN协议处理程序)。

Toni