I work as a consultat for two different companies that both use maven and that both have their own nexus repository managers. I have used maven with both repository managers and it works fine but every time I switch customer I need to change my settings.xml file where the address for the repository manager is located.
Is there a way to go around this? To make Maven figure out what repository mangager to use based on what project I am building? I can easily edit the pom-files in both projects and activate different profiles if that is needed.
Thanks for all your answers, however I finally had a different approach, and that was to disable the central repository and add the projects nexus repository in each pom.
The downside of this is that if it is to work fully, it needs to be in every pom, not just the parent.
However, it is a one-time configuration for each project and the only thing each developer needs to add to their settings.xml is their credentials for the nexus repo which makes the startup for new developers simpler.
Another downside is that if I run maven outside of a project, like
archetype:generatemaven is not aware of my nexus repo and I need to specify that on the command line. I believe I could configure a default repo in my settings.xml but I haven’t explored that further.I also never have to think about which project I am working on, when I run maven the project knows which repository to use and this is very important to me.
I suspect that not everyone may agree that this is the best solution but it works for me and the overhead is acceptable.
This is how my configuration in each pom looks like