Is it possible to specify mirror in pom.xml ? For example I am want to make one my own repo like central repo. And I want disable requests to the central repo and make all requests to my own repo. Is it possible to disable default central repo in Maven?
It's important to note that values from an active profile in settings. xml will override any equivalent profile values in a pom. xml or profiles.
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.
The mirror to http://a.com:8081 will be used when Maven will try to fetch a dependency from one of the repository that it mirrors.
In the pom it's not possible to define mirror entries furthermore it would be bad practice if definition of mirrors were possible (which is not the case). Similar for repositories definition in pom's (which are possible, but considered bad practice).
Best solution for such kind of thing is to install a repository manager which acts like a "own central repository."
Mirror can't be in the pom.xml. but it can be put add to your project's files.
When using maven 3.3.1+, you can use the core extension project-settings-extension to load the project settings, and put project specific mirrors into ${basedir}/.mvn/settings.xml
in your project.
in ${basedir}/.mvn/extensions.xml
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd"> <extension> <groupId>com.github.gzm55.maven</groupId> <artifactId>project-settings-extension</artifactId> <version>0.1.1</version> </extension> </extensions>
in ${basedir}/.mvn/settings.xml
<settings> <mirrors> <mirror> <id>id</id> <url>https://url-for-this-project/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> </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