Every good Java programmer should know and use a build automation tool like Maven or Gradle.
Associated with one of these tools there is always a good repository from which the artifacts are downloaded and included automatically in the project.
Probably the most important repository for artifacts is Maven Central
But what if you want to run your self-hosted artifact repository?
Different choices are available on the market and sometimes are free or open source.
The most famous are:
I would like to share my personal idea about these tools.
First of all I tried to use Archiva. It’s easy to download and install, it doesn’t need much knowledge and also the post-installation is trivial.
Anyway I found some imperfections of the software that makes it a bit annoying, so I abandoned it.
Then I tried JFrog, a colossus in this field. I tried to install it but due to the huge size of the binary I found it absolutely uninstallable on my VPS with a small SSD capacity storage.
I uninstalled JFrog and I tried then another tool, Sonatype Nexus.
The installation package is really smaller then JFrog and the installation process is very easy.
You can find here the download page (free version) or run these commands:
$ wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
$ tar -xvf ./latest-unix.tar.gz
Once unpacked, just go inside the /bin folder and run:
$ cd /nexus-x-xx.x-xx/bin
$ ./nexus run
or if you want to run it in background you can run:
./nexus start
Remember that by default Nexus runs with about 2GB of RAM. To change it you just have to edit the /bin/nexus.vmoptions. Locate the following lines:
-Xms 2043m
-Xmx 2043m
-XX:MaxDirectMemorySize 2043m
and edit them with the MB you want to be used by your JVM.
The service by default starts on the port 8081 if it is available. Open your browser at http://localhost:8081 and find the Nexus homepage.
If the installation is done on a remote server, you probably want to have the service available behind a web server like Apache or Nginx (maybe also published on a specific subdomain?) (ex. https://myrepository.mydomain.com/ ).
If so, remember that you have to setup a reverse proxy. I personally use a third level domain with a HTTPS redirection with Apache as follows:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/$ / [R]
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName myrepository.mydomain.com
Redirect permanent / https://myrepository.mydomain.com/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin localhost@localhost
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8081/
ProxyPassReverse / http://127.0.0.1:8081/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName myrepository.mydomain.it
ServerAlias myrepository.mydomain.it
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.it/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.it/privkey.pem
</VirtualHost>
</IfModule>
Once setup the proxy you should be able to login with the “admin” username (the password is stored in a specific folder of the installation. The location will be prompted out when you will try to login.
You can find more information about this software and the user guide at this link: https://help.sonatype.com/repomanager3
Happy programming!
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.