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

时间:2022-04-03 23:57:35

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?

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

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).

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

I will be grateful for any hints.

任何暗示我都会感激不尽。

Thank you

2 个解决方案

#1


9  

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.

它还需要像\\ resource这样的Windows路径。

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

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

#2


1  

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.

我没有一个有效的例子,但“Maven Assembly Plugin”应该可以胜任。您可以将其配置为在部署阶段自动运行。编写自己的程序集描述符时,可以指定应该将程序集写入的路径。我认为maven不应该关心它是本地还是偏远的路径。

#1


9  

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.

它还需要像\\ resource这样的Windows路径。

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

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

#2


1  

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.

我没有一个有效的例子,但“Maven Assembly Plugin”应该可以胜任。您可以将其配置为在部署阶段自动运行。编写自己的程序集描述符时,可以指定应该将程序集写入的路径。我认为maven不应该关心它是本地还是偏远的路径。