Configure Your Own Maven Repository using FTP/SCP/SSH in Ubuntu Server

Running your own Maven repository is dirt simple. All you need is a web server where you can upload files
Maven supports FTP, SCP, WebDAV, and more exotic protocols like Subversion to publish artifacts to remote maven repository.

[1] Install and Configure web server

Install a web server (Apache HTTP Server or Nginx )

$ sudo apt-get install apache2
$ mkdir /var/www/maven-repo

[2] Install FTP server

Install FTP server (VSFTPD)

$ sudo apt-ge install vsftpd
$ sudo vim /etc/vsftpd.conf (edit on your behalf)
$ sudo service vsftpd restart

[3] Configure Your Project Deployment

Open up your awesome software project and edit the pom.xml file. You’re going to add two new sections, ending up with a file that looks like this:
<project ...="">
...
<groupid>test.maven</groupid>
<artifactid>awesome</artifactid>
<name>The Awesome Library</name>
<version>1.0-SNAPSHOT</version>
...

<build>
...
<extensions>
<extension>
<groupid>org.apache.maven.wagon</groupid>
<artifactid>wagon-ftp</artifactid>
<version>1.0-alpha-6</version>
</extension>
</extensions>
...
</build>

...
<distributionmanagement>
<repository>
<id>maven-repo</id>
<url>ftp://localhost/var/www/maven-repo</url>
</repository>
</distributionmanagement>
</project>

[4] Configure Your Server Credentials

You can find settings.xml in your personal Maven cache directory. On Unix-like systems, it should be at ~/.m2/settings.xml. You may have to create the file if it doesn’t already exist. Here’s what it should contain:
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>maven-repo</id>
<username>hacker</username>
<password>cracker</password>
</server>
</servers>
</settings>
The is the same as in our pom.xml. The user name and password are the credentials for your FTP server.

[5] Deploy


$ mvn deploy

[6] Make your library available to user

Now, anyone who wants to use your awesome library can just add a dependency to their pom.xml, like this:
...
<dependencies>
...
<dependency>
<groupid>test.maven</groupid>
<artifactid>awesome</artifactid>
<version>1.0-SNAPSHOT</version>
</dependency>
...

</dependencies>
...

<repositories>
...
<repository>
<id>maven-repo</id>
<name>My Private Repository</name>
<url>http://localhost/maven-repo</url>
</repository>
...

</repositories>
..

Now have fun :)