Petr Macek
Petr Macek

Reputation: 1473

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

Upvotes: 4

Views: 5180

Answers (2)

Petr Macek
Petr Macek

Reputation: 1473

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.

Upvotes: 8

Roland Schneider
Roland Schneider

Reputation: 3635

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.

Upvotes: 1

Related Questions