I have a few projects with LOTS of maven dependencies. When I invoke the command mvn deploy (or some variation of it), I would like to not only have the project itself depl
Here's how it works in a nutshell, assuming your remote repository (Nexus, or Artifactory, or the like) and settings.xml are configured correctly.
Let's say you have a project with one dependency on commons-logging
. When Maven resolves your project's dependencies as part of a build, it does these steps:
commons-logging
. commons-logging
in the remote repo. commons-logging
. Then it's available for Maven to download to local repo. Done; continue with build.At the end of these steps, commons-logging
should be in both your local and remote repos with nothing further to do. If this is not the case, then either your settings.xml
is not configured to connect to the remote repo when searching for dependencies (is it contacting central directly?) or Nexus isn't configured correctly.
---- Edit ----
Here's a snippet of my settings.xml that works. @Raghuram gave you a good tip when he suggested you enable both profiles; if you somehow enabled only the public-snapshots
profile your builds would continue to hit maven central directly.
....
maven2
*
http://repository.someCompany.com/maven2RepoOrGroupInNexus
....
repo-profile
central
http://gotoNexus
true
daily
true
daily
repo-profile
Note the activeProfiles
element at the bottom; that's how to ensure you'll use Nexus instead of Maven central with every mvn
command.
You still need to make sure Nexus is configured so that the URL defined in the
includes content from Maven central, but how to configure Nexus would be a separate question.
Reference: Nexus docs for Maven configuration