Create project-specific Maven settings

I think I have a solution to that problem, you need a recent maven version, I'm using maven 3.5.2 but the feature was introduced in maven 3.3.1 I believe, not sure.

The idea is to use the local .mvn folder (in the parent project's folder) where it is possible to configure several things like JVM options, maven options that are always used, etc.

For maven options just create a file maven.config inside the .mvn folder with the content --settings ./.mvn/local-settings.xml, and that should be about it. Of course the local-settings.xml should be a valid maven settings file.

Here's the structure within the maven project root folder :

parent-mvn-project
   ├── .mvn
   │   ├── local-settings.xml
   │   └── maven.config
   ├── submodule-A (if any submodules)
   └── submodule-B (if any submodules)

In IntelliJ you can set a different settings file for any project:

  1. Go to Settings -> Build, Execution, Deployment -> Build tools -> Maven
  2. Set the user settings file to local-settings.xml

After maven 3.3.1, use the project-settings-extension to load the project settings, and put project specific mirrors into ${basedir}/.mvn/settings.xml in each 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>

    <profiles>
      <!-- profiles for this project, such as corp internal repositories -->
    </profiles>

  </settings>

Just a sample settings.xml file in case anyone needs it.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/personal-wks/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>

change your <localRepository> accordingly.

Refer to this answer to set up the project specific seetings.xml.

detailed blog on baeldung