Normally, I have the following mirror configured in my Maven settings.xml
<mirror>
<id>internal-repository</id>
<url>http://build.idaho.local/wtp_repository</url>
<mirrorOf>*</mirrorOf>
</mirror>
My understanding is that this mirror prevents Maven from downloading dependencies from the internet, i.e. it will only look for them in this internal repository.
However, whenever I want to add a dependency that isn't in this internal repository, I have to comment out the text above and add the following to the project's pom.xml
<repository>
<id>internal-repository</id>
<url>http://build.idaho.local/wtp_repository</url>
</repository>
When I make these changes Maven will check for dependencies in the local repo, and if not found, download them from the internet to the local repo. Once I have the dependencies I need, I then change my configuration back.
Is there a way to get the behaviour I want - always check the internal repo, then the public (Internet) repos - without having to add the <repository>
to every project's pom.xml
?
Ideally I would like to specify this repository once in settings.xml
, but it seems that you can only configure mirrors there.
You can force Maven to use a single repository by having it mirror all repository requests. The repository must contain all of the desired artifacts, or be able to proxy the requests to other repositories.
Once you have created a proxy repository, you should configure Nexus to download artifacts from one or more mirrors. To configure mirrors, click on Repositories under the View/Repositories section of the Nexus menu, select the proxy repository you want to configure, and then select the Mirrors tab for this repository.
Solution. This issue can be resolved by adding mirror repositories (using mirrorOf) to the ~/. m2/settings. xml file to redirect the mirrors referenced in the Maven error to HTTPS.
There are 3 types of maven repository: Local Repository. Central Repository. Remote Repository.
You could try to configure maven to use the mirror only for the central repository or to exclude the repository identified by some id.
<mirror>
<id>internal-mirror</id>
<url>http://build.idaho.local/wtp_repository</url>
<mirrorOf>central</mirrorOf>
</mirror>
Or
<mirror>
<id>internal-mirror</id>
<url>http://build.idaho.local/wtp_repository</url>
<mirrorOf>*,!internal-repository</mirrorOf>
</mirror>
The examples were adapted from maven settings and guide to mirror settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With