使用 Maven 2 将程序集部署到 FTP 服务器

发布于 2024-08-08 10:51:37 字数 806 浏览 4 评论 0原文

我有一个项目分为几个子模块(每个子模块都是 jar 库):

myapp
    myapp-commons
    myapp-client
    myapp-server

我已经配置了 pom.xml 以创建 3 个程序集(>client.ziporacle.tar.gzserver.tar.gz),最终存储在 myapp/target 中> 目录。 我现在想要的是使用 FTP 将其中两个(oracle.tar.gzserver.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌上青苔 2024-08-15 10:51:37

正如您在问题中所说,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).

眼前雾蒙蒙 2024-08-15 10:51:37

使用 FTP 部署工件的方法记录在 部署使用 FTP 生成的工件

为了使用 FTP 部署工件
您必须首先指定使用
FTP 服务器位于
分布管理元素
你的 POM 以及指定
构建元素中的扩展
这将拉入 FTP 工件
需要使用 FTP 进行部署:

<前><代码> ...


<分销管理>
<存储库>
ftp-存储库
ftp://repository.mycompany.com/repository

<构建>
<扩展>
<扩展>
org.apache.maven.wagon;
wagon-ftp
<版本>1.0-alpha-6


您的 settings.xml 将包含一个 server 元素,其中该元素的 id 与服务器的 id 相匹配上面 POM 中指定的 FTP 存储库:

<前><代码><设置>;

...

<服务器>
<服务器>
ftp-存储库
<用户名>用户
<密码>pass

...

现在,我的理解是您只想对生成的程序集的子集使用此类设置。为此,我将创建一个专用模块来生成要使用 FTP 分发的程序集,并仅使用此模块中的 FTP 设置来覆盖 distributionManagement 元素。

The way to deploy artifacts using FTP is documented in Deployment of artifacts with FTP:

In order to deploy artifacts using FTP
you must first specify the use of an
FTP server in the
distributionManagement element of
your POM as well as specifying an
extension in your build element
which will pull in the FTP artifacts
required to deploy with FTP:

  ...

  <!-- Enabling the use of FTP -->
  <distributionManagement>
    <repository>
    <id>ftp-repository</id>
    <url>ftp://repository.mycompany.com/repository</url>
    </repository>
  </distributionManagement>

  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-ftp</artifactId>
         <version>1.0-alpha-6</version>
      </extension>
    </extensions>
  </build>

Your settings.xml would contain a server element where the id of that element matches id of the FTP repository specified in the POM above:

<settings>

  ...

  <servers>
    <server>
      <id>ftp-repository</id>
      <username>user</username>
      <password>pass</password>
    </server>

  </servers>

  ...

</settings>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文