Maven:如何使用部署文件和自定义 Wagon 进行部署
我正在尝试使用自定义 Maven Wagon 扩展将 jar 部署到我自己的存储库。 我是否可以在 settings.xml 中进行配置,使其识别与特定货车一起使用的自定义 url 方案,或者我是否必须始终修改 pom 文件以包含货车扩展?
使用部署文件时不需要有基础 pom 或任何可用的 pom。 Settings.xml 是唯一保证存在的地方,但我不知道如何使用它来定义扩展。
I'm trying to use a custom maven wagon extension to deploy a jar to my own repository. Can I somehow configure in settings.xml that it recognizes the custom url scheme to be used with the specific wagon or do I have to always modify pom files to contain the wagon extension?
There doesn't need to be a base pom or any pom available when using the deploy-file. Settings.xml is the only place which is guaranteed to be there, but I can't figure out how to use it to define extensions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道上面的评论是否为Brian Fox 在 2013 年仍然有效。但最终我不得不在我尝试上传工件以启用 wagon 构建扩展的目录中创建一个最小的 pom.xml。
我必须将 groupId、artifactId 和 version 添加到 pom.xml,这样 Maven 就不会抱怨,尽管我将它们提供给了命令行上的部署文件目标(不过我猜部署文件只会关心命令行参数)
:这个简单的“pom.xml”就位,我最终可以使用 scp 作为协议来执行部署文件:
I don't know if the comment above by Brian Fox is still valid in 2013. But in the end I had to create a minimal pom.xml in the directory where I tried to upload the artifact to enable the wagon build extension.
I had to add groupId, artifactId and version to the pom.xml so that Maven would not complain although I provided them to the deploy-file goal on the commandline (I guess deploy-file would only care about the commandline parameters though):
With this simple "pom.xml" in place I could execute the deploy-file finally using scp as the protocol:
好的,好的,更正一下:您不能在
settings.xml
中定义的
中定义
元素。 您可以在settings.xml
中激活配置文件,但在base-pom
中定义它。抱歉,我能想到的唯一其他方法(可能是您正在寻找的方法)是将扩展 jar 直接复制到
$M2_HOME/lib
下。 所有$M2_HOME/lib/*.jar
都放在类路径中,因此这实际上必须具有与
相同的效果。然而,该扩展更好,因为您可以更轻松地控制使用哪个版本的扩展(例如通过 base-pom)。
好的,尝试将扩展 jar 复制到下面
OK, ok, a correction: you cannot define the
<build>
element inside a<profile>
defined insettings.xml
. You could activate the profile insettings.xml
, but define it in yourbase-pom
.Sorry, the only other way I could think of (probably what are you looking for), is to copy the extension jar directly under
$M2_HOME/lib
. All$M2_HOME/lib/*.jar
are put in the classpath, so this must virtually have the same effect as an<extension>
.The extension however is better, because you can more easily control which version of the extension is used (e.g. trough the base-pom).
OK just try copying the extension jar under
您需要 将 wagon 扩展添加到您的顶级 pom.xml 。 大多数环境在所有项目的顶部都有一个公司的 pom(最佳实践),因此这对于个人开发人员来说通常不会太痛苦 - 他们只是从公司的 pom 继承。
我相信,当您注册提供商时,它也会注册协议模式。 您可以在此处查看现有提供程序的完整列表。
我相信是 getScmType() 方法注册了扩展,但我不能 100% 确定。
可以在此处找到 Git 提供程序源的链接。
You need to add the wagon extension to your top level pom.xml. Most environments have a corporate one at the top of all their projects (best practice), so this generally isn't too painful for individual developers -- they just inherit from the corporate pom.
When you register your provider, it also registers the protocol pattern as well I believe. You can see a full list of the existing providers here.
I believe it is the getScmType() method that registers the extension, but I'm not 100% certain.
The link to the Git provider's source can be found here.
siddhadev 是对的,但还有一些额外的事情......
(我会把它放在评论中,但我没有足够的声誉)
你可以通过将 JAR 放在以下位置来将它们干净地分开:
$M2_HOME/lib/ext
您需要所有依赖项,因此请执行以下操作:
siddhadev is right, but there are few additional things...
(I'd put this in a comment but I don't have enough reputation)
You can keep your JARs cleanly separated by putting them under:
$M2_HOME/lib/ext
You need all of the dependencies, so do something like: