如何在 Maven 部署阶段将构建的工件复制到远程 Windows 服务器上的目录?

发布于 2024-07-08 07:24:19 字数 219 浏览 10 评论 0原文

有人可以提供工作示例(完整的 Maven 插件配置)如何在部署阶段将构建的 jar 文件复制到特定服务器吗?

我尝试查看 wagon 插件,但它没有大量文档记录,我无法设置它。 该构建生成了部署到 Nexus 的标准 jar,但我还需要通过本地网络(\someserver\testapp\bin)自动将 jar 放入测试服务器。

我将不胜感激任何提示。

谢谢

could someone provide working example (full maven plugin configuration) how to copy built jar file to a specific server(s) at the time of deploy phase?

I have tried to look at wagon plugin, but it is hugely undocumented and I was not able to set it up. The build produces standard jar that is being deployed to Nexus, but I need to put the jar also to the test server automatically over local network (\someserver\testapp\bin).

I will be grateful for any hints.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

枯寂 2024-07-15 07:24:19

其实我找到了一种不同的方法:
依赖插件!

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>copy-to-ebs</id>
      <phase>deploy</phase>
      <goals>
          <goal>copy</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>${project.groupId}</groupId>
            <artifactId>${project.artifactId}</artifactId>
            <version>${project.version}</version>
            <type>${project.packaging}</type>
          </artifactItem>
        </artifactItems>
        <outputDirectory>\\someserver\somedirectory</outputDirectory>
        <stripVersion>true</stripVersion>                    
      </configuration>
    </execution>                        
  </executions>
</plugin>

它还采用 Windows 路径,如 \\resource。

请注意,\\someserver\somedirectory 仅适用于 Windows 客户端。

Actually I have found a different way:
Dependency plugin!

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>copy-to-ebs</id>
      <phase>deploy</phase>
      <goals>
          <goal>copy</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>${project.groupId}</groupId>
            <artifactId>${project.artifactId}</artifactId>
            <version>${project.version}</version>
            <type>${project.packaging}</type>
          </artifactItem>
        </artifactItems>
        <outputDirectory>\\someserver\somedirectory</outputDirectory>
        <stripVersion>true</stripVersion>                    
      </configuration>
    </execution>                        
  </executions>
</plugin>

It also takes windows path like \\resource.

Note that \\someserver\somedirectory works from windows client only.

动听の歌 2024-07-15 07:24:19

I don't have a working example but the "Maven Assembly Plugin" should do the job. You can configure it to run automatically in the deploy phase.
When you write your own assembly descriptor you can specify a path where the assembly should be written to. I think maven shouldn't care about whether it's a local or remote path.

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