views:

1847

answers:

3

Can Maven copy local file to a remote server server using SSH?

I want to specify location in maven configuration file and to copy that file(or files) to server each time deploy phase is executed.

+1  A: 

Maven is not a generic tool, it's a tool to make your build process reusable. I suggest to use an embedded antrun build step. In this step, you can do anything using the normal ant syntax which you'd use in build.xml.

Aaron Digulla
+2  A: 

Why not use the Ant SCP task, which you can run within Maven ?

Brian Agnew
+3  A: 

The maven-deploy-plugin allows you to configure the deploy phase to deploy to a server using scp. There is a page in the documentation that describes how it can be done.

I believe this will replace the normal deployment instead of add to it, so it may not be what you're after.

If you need to deploy to a traditional Maven repository as well as deliver the file to the remote server, you will need to use the scp task as the other answers suggest.

In this answer I've described how to configure the ftp task, the scp task is almost identical except you may need to add the keyfile and passphrase attributes (and change the task name from ftp to scp obviously).

Rich Seller