Uploading Maven Artifacts to a Ftp Location Using SFTP Protocol.

Posted on the 30 October 2017 by Araldam @araldam
Apache Maven Wagon is a set of plugins developed to provides a transport abstraction for handling maven artifacts and repositories. Shown below is the way to use 'wagon-ssh' plugin to upload maven artifacts to a ftp location using the SFTP protocol.
This is quite straight forward and requires few elements to be configured in the pom.xml as follows.
1. Configure repository location of the wagon-git plugin.


synergian-repo
https://raw.github.com/synergian/wagon-git/releases


2. Include the 'wagon-ssh' plugin extension configuration inside the 'build' element.



org.apache.maven.wagon
wagon-ssh
2.8



3. Finally we need to include our ftp location using the 'distributionmanagement' element. During the build process artifacts will be uploaded in to following location.


mvn-ftp-server
sftp://ftp.aravinda-sites.com/my-ftp-repo


In order to use SFTP protocol maven settings.xml need to be updated with the ftp server access keys. Here the 'id' defined in the repository should match with the server id.


mvn-ftp-server
/Users/aravinda/.ssh/id_rsa
passPhrase


Now you can execute,
'
mvn deploy

command to upload the artifacts.