Question

I have this mirror in my settings.xml file :

<mirrors>
    <mirror>
      <id>internal-repository</id>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://nexus_server.mycompany.com/nexus/XXX</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

Now I need a plugin and a dependency that I can't find in this repository. I'll request for adding them. But first I need to test them.

So here, I need to add other repositories http:\NEW_REP_URL in settings.xml . And so I want Maven to get the dependency/plugin from the repository that I add if it doesn't find it in the company's nexus.

In other words, how to make priorities between the repositories : if not found in local cache then in company's nexus. If not found in our company's nexus then in http:\NEW_REP_URL ?

Can you give me a sample code with some explainations?

Thank you a lot!

Was it helpful?

Solution

You should create a proxy repo in Nexus and add it to the group you use to access Nexus. This is described in more detail in the Nexus book e.g. in the chapter about Maven configuration.

The main advantage is that you can have a whole bunch of developers, CI servers and so on, that do NOT have to change the settings file and you can just add more proxy repositories and artifacts for all of them by just adding more to the group.

Resolving these repositories via a group in Nexus is also quite a bit faster than having Maven do all the resolving on the client.

And btw. the priority of the repositories is determined by the order of the repositories in the group.

OTHER TIPS

It sounds like what you're saying is, you want to pull in some dependency non_public_project.jar which is only available on http://non_public_nexus_repo and cannot be found on the 3 default repos:

  • apache snapshots
  • codehaus snapshots
  • Maven central

If so, then your settings.xml is fine: a single mirror pointing to your company's Nexus server.

It's the Nexus server itself that needs to be configured to declare a proxy repository (aka external repo or remote repo). If Nexus can't find the jar in question either locally or on Apache/Codehaus/Central, then it looks in the NEW_REP_URL location you specify.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top