Maven 原型目录:指定自定义位置
我正在为 Maven 部署 Nexus 存储库,并在其上部署自定义原型。
我想执行 mvn archetype:generate
并提示内部 + 自定义原型列表。
我发现提示自定义原型的唯一方法(以符合人体工程学的方式,意味着没有 URL)是将原型目录路径定义为设置中的属性。这不是一个有效的解决方案,因为我想要多个目录(并且无法在 CLI 中覆盖此属性)。
有人知道如何做到这一点吗?
预先感谢,
[编辑] 我发现了相关的问题报告:http://jira.codehaus.org/browse/ARCHETYPE-273< /a>
我注意到在 archetype:generate
期间,maven 尝试访问中央存储库:
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2
它以“连接超时”结束,因为我没有(也不想)指定代理...
我不明白为什么maven不检查nexus目录...
I'm deploying a Nexus repository for Maven, and custom archetypes on it.
I would like to execute mvn archetype:generate
and be prompted a list of internal + custom archetypes.
The only way I found to prompt custom archetypes (in an ergonomic way, meaning no URL) is to define the archetype-catalog path as a property in the settings. This is not a valid solution because I want several catalogs (and this property cannot be overriden in CLI).
Does anybody have a clue on how to do that ?
Thanks in advance,
[EDIT]
I found an issue report related : http://jira.codehaus.org/browse/ARCHETYPE-273
And I noticed that during archetype:generate
, maven tries to reach the central repository :
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2
It ends by a "Connection Timed out" because I did not (and don't want to) specify a proxy...
I don't understand why maven doesn't check nexus catalog...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还配置了一个 Nexus 来镜像 Maven 存储库,从而镜像远程目录。
并且:
只有当我使用以下 Maven 命令行时,我才能访问远程目录:
如果我没有定义
archetypeCatalog
变量,我会得到与您相同的行为:尝试访问回购1。 ...虽然配置了一些镜像。I also have a Nexus configured to mirror the Maven repositories and thus the remote catalog too.
and:
I am able to access the remote catalog only when I use the following Maven command line:
If I don't define the
archetypeCatalog
variable, I get the same behavior as you do: trying to access the repo1. ... although some mirrors are configured.您需要
属性archetypeRepository
存储库和pluginRepositories重定向到您的镜像,位于相同的ID“central”上。
当然,镜像定义
archetype 插件上镜像定义的 Apache maven 文档指定 archetypeRepository 是可定义的用户属性:
http://maven.apache.org/archetype/maven-archetype -plugin/generate-mojo.html
您的 .m2/settings.xml 应该包含这些最少的元素
You need to have
the property archetypeRepository defined in the active profile in your .m2/settings.xml
the repositories and pluginRepositories redirected to your mirror, on the same id "central".
and of course, the mirror defined
Apache maven documentation on archetype plugin specifies that archetypeRepository is definable user property:
http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html
Your .m2/settings.xml should have these minimal elements
使用
maven-archetype-plugin:3.1.1
,您必须archetype-catalog.xml
,以列出您的自定义原型设置。使用 id archetype 添加此存储库。
从 https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html:
With
maven-archetype-plugin:3.1.1
you have toarchetype-catalog.xml
on your repo to list your custom archetypessettings.xml
to add this repo with id archetype.mvn archetype:generate -DarchetypeCatalog=remote
From https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html :