使用 Maven 2 将程序集部署到 FTP 服务器
我有一个项目分为几个子模块(每个子模块都是 jar
库):
myapp
myapp-commons
myapp-client
myapp-server
我已经配置了 pom.xml
以创建 3 个程序集(>client.zip
、oracle.tar.gz
和 server.tar.gz
),最终存储在 myapp/target
中> 目录。 我现在想要的是使用 FTP 将其中两个(oracle.tar.gz
和 server.tar.gz
)分发到服务器。
即使我还没有尝试过,我知道我可以使用 pom.xml
中的一些 Ant 行轻松地做到这一点,但我不太喜欢这个选项(我会解决我的问题)仅当没有其他解决方案时,Ant 才会出现问题)。 有一些问题(此处或此处)为此提供了解决方案。
我的问题是知道是否有更好的方法来做到这一点?我知道 Wagon Maven2 插件,但我没有成功配置它以部署程序集(并且不是创建的 JAR)。
I have a project divided into several sub-modules (each of them are jar
libraries):
myapp
myapp-commons
myapp-client
myapp-server
I've configured my pom.xml
in order to create 3 assemblies (client.zip
, oracle.tar.gz
and server.tar.gz
) that are finally stored in the myapp/target
directory.
I want now is to distribute two of them (oracle.tar.gz
and server.tar.gz
) to a server using FTP.
Even if I didn't try yet, I know that I can do that quite easily using some lines of Ant inside my pom.xml
, but I don't really like this option (I will solve my problem with Ant only if there are no other solution).
There are some SO questions (here or here) that offer solutions for that.
My question is to know if there is a better way to do that? I know about the Wagon Maven2 plugin but I didn't succeed in configuring it in order to deploy the assemblies (and not the JAR created).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您在问题中所说,Ant 方法并不理想,但如果您找不到替代方案,这个答案展示了如何使用antrun插件通过FTP进行部署。更新
,根据您更新的问题,这部分不太相关,但我会将其保留以帮助其他人。
wagon-ftp 插件 允许您连接到 FTP 服务器。我还没有尝试过这个,但是您也许可以绑定部署插件的 部署文件目标到适当的阶段,将文件传送到 FTP 服务器(此博客)。
As you say in your question, the Ant approach is not ideal, but if you don't find an alternative, this answer shows how to use the antrun plugin to deploy with FTP. The
Update, based on your updated question this part is less relevant, I'll leave it in to help others though.
The wagon-ftp plugin allows you to connect to FTP servers. I've not tried this, but you may then be able to bind the deploy-plugin's deploy-file goal to an appropriate phase to deliver the files to the FTP server (some hints on usage at this blog).
使用 FTP 部署工件的方法记录在 部署使用 FTP 生成的工件:
现在,我的理解是您只想对生成的程序集的子集使用此类设置。为此,我将创建一个专用模块来生成要使用 FTP 分发的程序集,并仅使用此模块中的 FTP 设置来覆盖
distributionManagement
元素。The way to deploy artifacts using FTP is documented in Deployment of artifacts with FTP:
Now, my understanding is that you want to use such settings for a subset of the produced assemblies only. To do so, I'd create a dedicated module to produced the assemblies to be distributed using FTP and override the
distributionManagement
element with the FTP setup in this module only.