如何分享Maven原型? [英] How to share Maven archetypes?

查看:96
本文介绍了如何分享Maven原型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Maven原型,希望在公司内部共享.为此,我将其部署到了Nexus服务器上,并且可以从那里使用它,但是由于它似乎不在其他计算机上的已知原型目录中,因此有些不便.解决方法是像这样使用它:

I've created a Maven archetype which I want to share within my company. To do so, I deployed it to our Nexus server and it can be used from there, but it is somewhat inconvenient since it seems not to be in the catalog of known archetyps on other machines. The workaround is to use it like this:

mvn archetype:generate -DarchetypeCatalog=http://nexus/content/repositories/releases/

是否可以在不显式给出archtype目录的情况下使用maven?我想像其他任何公共可用原型一样使用这种内部原型.

Would it be possible to use maven without explicitly giving the archtype catalog? I want to use this internal archetype like any other public available archetype.

推荐答案

这是我的方法:

我在$HOME/.m2/settings.xml中将Maven配置为将Nexus服务器用作所有内容的镜像:

I configure Maven in $HOME/.m2/settings.xml to use the Nexus server as mirror for everything:

  <mirrors>
    <mirror>
      <id>Nexus</id>
      <name>Nexus Server</name>
      <url>http://nexus/content/repositories/groups/public</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>

然后我将开发人员应使用的所有存储库放在组public中(即Maven Central的代理存储库,我的快照和发布存储库等).

I then put all repos which developers should use in the group public (i.e. the proxy repo for Maven Central, my snapshot and release repos, etc).

然后Nexus将所有目录(来自Maven Central的目录和来自公司回购目录的目录)合并到一个目录中.这样就可以在默认URL下看到所有原型.

Nexus will then merge all catalogs (the one from Maven central and the ones from the company repos) into one. That makes all archetypes visible under the default URL.

这篇关于如何分享Maven原型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆