4

I have set up nexus on a server and now I would like to ensure that my local machine only uses nexus to get any dependencies and never goes to its local .m2 directory.

Is there a recommended way to do this and in fact is this even recommended at all?

Thanks

berimbolo
  • 3,319
  • 8
  • 43
  • 78
  • why do you want to do this? This isn't really how Maven works. I'm also not sure if it is really possible to do what you want (although I don't mind being corrected). This question - http://stackoverflow.com/q/7959499/1570834 - (and its answers) give you a few possible options: 1. delete your local repo, thereby forcing a download of everything. 2. using the dependency plugin to purge your local repository etc – DB5 Mar 19 '14 at 10:06
  • I will tell you why I wanted to do this though, I have been having issues with eclipse and its maven repo browser not reflecting the true state of the remote repo even after updating the indexes and also some jars which were in the repo were not being downloaded at all to the local so it was really for test purposes. Thanks for the help. – berimbolo Mar 19 '14 at 10:27
  • Are you using a repository manager ? If yes the creation of that index is the cause. – khmarbaise Mar 19 '14 at 11:15
  • Hi @khmarbaise yes I am using nexus repository manager. Do you think I should completely rebuild the remote repo and then rebuild the indexes in Eclipse? It seemed that rebuilding the indexes still didnt reflect the true state of the repo. – berimbolo Mar 20 '14 at 10:54

1 Answers1

7

You always have to use your local .m2 directory, because otherwise Java would not be able to put the JARs to classpath.

If you always want to update your local repositories with the versions from e.g. Nexus, then use "mvn -U" or "mvn --update-snapshots" which "Forces a check for updated releases and snapshots on remote repositories" according to http://books.sonatype.com/mvnref-book/reference/running-sect-options.html.

Otherwise remote repositories are only checked daily if there is already an artifact within local repository.

Tom Feiner
  • 164
  • 12
  • 1
    Well I guess youre right, I didnt think like that, I am only just starting to use Maven and have just realised the jarsin my project are actually just references to the local repository which as you said need to be local to be placed on the class path. What I want then is what you suggested which is to enforce checking of the remote repository, I just need to do this in Eclipse. Thanks for the help. – berimbolo Mar 19 '14 at 10:29