GeeCON Prague 2014*
The moose likes Other Application Frameworks and the fly likes Maven Local repository Vs nexus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Maven Local repository Vs nexus" Watch "Maven Local repository Vs nexus" New topic
Author

Maven Local repository Vs nexus

RamandeepS Singh
Ranch Hand

Joined: Aug 25, 2009
Posts: 63
Hi

I am new to maven , can anybody tell me what is the difference between the maven local repository and nexus repository manager??

As in local repo we also cache the artifacts in our local system.. hpoing we can do it also in our network server, As i read nexus also do the same..
please correct me if i am wrong

Thanks in advance
Ramandeep S.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi RamandeepS,

the Maven local repository is only a per-user directory (at least with Linux and Windows) where artifacts are stored after you have downloaded them once. For release versions (in contrast to snapshot versions) this means you have to download these files never again.

Nexus or any other Maven repository manager on the other hand does more than just this and I would definitely recommend to use such a repository manager if you want to have fun and work without too much trouble with Maven Some typical use cases / features of a repository manager are:

shared cache: It does not only cache artifacts you have used once but it also enables you to share artifacts with other users or computers in your network. That way only one user have to download the artifact and all the others can use the artifact from the central cache.

proxy: Nexus not only allows you to cache artifacts it also allows you to act as a proxy for public remote repositories. That makes it easy to hide several public repository URLs behind the repository manager URL. Otherwise you would have to specify all needed additional repositories inside your settings.xml file or in every project POM (a bad practice!). Nexus also can be configured to download remote indexes and index the local artifacts for faster access from inside your network.

share artifacts: A repository manager is not limited to be used as a proxy cache. Additionally it allows you to upload and distribute your own artifacts. This way you can publish your own library or project JARs, WARs, EARs etc. with your repository manager. Then other users/computers can easily access these artifacts from the central repository manager. Of course this makes it a lot easier to manage and handle artifacts in a single place instead of copying and moving them manually. It's also easier to make backups of your artifacts.

speed: Some of the public repositories are really slow from time to time. A repository manager helps you to speed up your development experience because you don't have to contact all remote repositories during your builds. For release versions this is not a big deal, because they are only downloaded once. But for snapshot versions the remote repositories are contacted each day (by default) to look or newer versions. There are several options to configure this behavior for the repository manager. For example if you know that artifacts don't change often for a remote repository Nexus doesn't need to check for it every 24h. Additionally it can download remote indexes at night so that you have the newest indexes but don't have to wait for it during development.

There are more features depending on the repository manager you choose but I guess you now have an idea what the advantages are.

Marco


RamandeepS Singh
Ranch Hand

Joined: Aug 25, 2009
Posts: 63
Marco Ehrentreich wrote:Hi RamandeepS,

the Maven local repository is only a per-user directory (at least with Linux and Windows) where artifacts are stored after you have downloaded them once. For release versions (in contrast to snapshot versions) this means you have to download these files never again.

Nexus or any other Maven repository manager on the other hand does more than just this and I would definitely recommend to use such a repository manager if you want to have fun and work without too much trouble with Maven Some typical use cases / features of a repository manager are:

shared cache: It does not only cache artifacts you have used once but it also enables you to share artifacts with other users or computers in your network. That way only one user have to download the artifact and all the others can use the artifact from the central cache.

proxy: Nexus not only allows you to cache artifacts it also allows you to act as a proxy for public remote repositories. That makes it easy to hide several public repository URLs behind the repository manager URL. Otherwise you would have to specify all needed additional repositories inside your settings.xml file or in every project POM (a bad practice!). Nexus also can be configured to download remote indexes and index the local artifacts for faster access from inside your network.

share artifacts: A repository manager is not limited to be used as a proxy cache. Additionally it allows you to upload and distribute your own artifacts. This way you can publish your own library or project JARs, WARs, EARs etc. with your repository manager. Then other users/computers can easily access these artifacts from the central repository manager. Of course this makes it a lot easier to manage and handle artifacts in a single place instead of copying and moving them manually. It's also easier to make backups of your artifacts.

speed: Some of the public repositories are really slow from time to time. A repository manager helps you to speed up your development experience because you don't have to contact all remote repositories during your builds. For release versions this is not a big deal, because they are only downloaded once. But for snapshot versions the remote repositories are contacted each day (by default) to look or newer versions. There are several options to configure this behavior for the repository manager. For example if you know that artifacts don't change often for a remote repository Nexus doesn't need to check for it every 24h. Additionally it can download remote indexes at night so that you have the newest indexes but don't have to wait for it during development.

There are more features depending on the repository manager you choose but I guess you now have an idea what the advantages are.

Marco





First of all i want to thank you Marco

this was highly beneficial for me

but what actually i was thinking is

Shared Cache:

like in our network server if i install maven then in my local system maven configuration i set the local repo the path to the server local repo, i have not done this before but i think this could be done
please let me know where i am wrong.. Cant we do the above configuration?

Thanks
Ramandeep S.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi RamandeepS,

I'm glad that my information were helpful
like in our network server if i install maven then in my local system maven configuration i set the local repo the path to the server local repo, i have not done this before but i think this could be done
please let me know where i am wrong.. Cant we do the above configuration?

Well, after all the reason to have something like a shared cache is to actually use it

Of course you can configure to use your local repository manager inside your network! As I wrote above it's basically possible to add additional remote repositories in different places for Maven projects.

You can list the needed remote repositories directly inside the POM file for a project. This is considered a bad practice. Just imagine that you would have a project where you would configure your local repository manager inside the POM. If you then decided to share this project with someone who doesn't have access to your repo manager he would have to manually change this for his own needs maybe in his network with his own repository manager. This scenario should make it clear that the repository manager is nothing which is project specific.

Alternatively you can add the repository manager URL to the Maven settings.xml file - either the global one inside the Maven installation directory or the (initially non-existent) one insided $HOME/.m2/ which is user specific. An example (which works perfectly for me) is here:


Of course you have to change the information to match your own setup Btw. the suffix of my repo manager URL shows that I am using the "group" feature of Nexus. It allows you to group multiple remote repositories behind one Nexus URL so that you just have to remember and configure this one.


Marco
 
GeeCON Prague 2014
 
subject: Maven Local repository Vs nexus