Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I copy built artifact to a directory on remote Windows server in maven deploy phase?

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

like image 593
Petr Macek Avatar asked Dec 31 '22 08:12

Petr Macek


1 Answers

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.

like image 54
Petr Macek Avatar answered Jan 06 '23 03:01

Petr Macek