The concept of inheritance of from generic to specific, where the more specific overrides the values of its ancestors.

In general, we see three levels, also described at Maven – Guide to Configuring Maven (apache.org): it uses the terms user, installation, project

Just to give a hint: when you're working with multiple Maven installations on your system, they all share "user" configuration. Think of server credentials, you don't want to specify these per installation.



userinstallationprojectcommand line
JVMMAVEN_OPTS
.mvn/jvm.config
Maven arguments

.mvn/maven.config-$ / --$$
Settings$user.home/.m2/settings.xml (--settings)$maven.home/conf/settings.xml (--global-settings)

Toolchains$user.home/.m2/toolchains.xml (--toolchains)$maven.home/conf/toolchains.xml (--global-toolchains)


Looking at the settings and toolchains there's something odd with the name of the flags: --global-x is AFTER --x. This is an inconsistency as nothing should be more global than "global".


I see a couple of options how to solve this:

1.  Switch the flags. This breaks compatibility in 2 ways: The flag overrides a different file and --settings will now override --global-settings.


userinstallationprojectcommand line
JVMMAVEN_OPTS
.mvn/jvm.config
Maven arguments

.mvn/maven.config-$ / --$$
Settings$user.home/.m2/settings.xml (--global-settings)$maven.home/conf/settings.xml (--settings)

Toolchains$user.home/.m2/toolchains.xml (--global-toolchains)$maven.home/conf/toolchains.xml (--toolchains)


2. Preserve user, and fix everything around it. This means that IF you use --global-settings, it's the new base. It can be overridden with user settings, which can be overridden with installation settings (maybe we don't need --maven-settings).


globaluserinstallationprojectcommand line
JVM
MAVEN_OPTS
.mvn/jvm.config
Maven arguments


.mvn/maven.config-$ / --$$
Settings(--global-settings)$user.home/.m2/settings.xml (--settings)$maven.home/conf/settings.xml (--maven-settings)

Toolchains(--global-toolchains)$user.home/.m2/toolchains.xml (--toolchains)$maven.home/conf/toolchains.xml (--maven-toolchains)


3.  Deprecate --global-settings and replace it with --maven-settings


userinstallationprojectcommand line
JVMMAVEN_OPTS
.mvn/jvm.config
Maven argumentsMAVEN_ARGS (MNG-7193)
.mvn/maven.config-$ / --$$
Settings$user.home/.m2/settings.xml (--settings)$maven.home/conf/settings.xml (--maven-settings)

Toolchains$user.home/.m2/toolchains.xml (--toolchains)$maven.home/conf/toolchains.xml (--maven-toolchains)


4.  Rename the flags and use the terms from the configuration-page


userinstallationprojectcommand line
JVMMAVEN_OPTS
.mvn/jvm.config
Maven argumentsMAVEN_ARGS (MNG-7193)
.mvn/maven.config-$ / --$$
Settings$user.home/.m2/settings.xml (--user-settings)$maven.home/conf/settings.xml (--installation-settings)

Toolchains$user.home/.m2/toolchains.xml (--user-toolchains)$maven.home/conf/toolchains.xml (--installation-toolchains)


5.  Drop flags for replacing existing settings, and use --settings as the one overriding the merge result of user+installation


userinstallationprojectcommand line
JVMMAVEN_OPTS
.mvn/jvm.config
Maven argumentsMAVEN_ARGS (MNG-7193)
.mvn/maven.config-$ / --$$
Settings$user.home/.m2/settings.xml$maven.home/conf/settings.xml
--settings
Toolchains$user.home/.m2/toolchains.xml$maven.home/conf/toolchains.xml
--toolchains

6. Switch installation and user, so installation becomes global and can be overridden by user.


installation

user

project

command line

JVM
MAVEN_OPTS.mvn/jvm.config
Maven arguments
MAVEN_ARGS (MNG-7193).mvn/maven.config-$ / --$$
Settings$maven.home/conf/settings.xml (--global-settings)$user.home/.m2/settings.xml (--settings)

Toolchains$maven.home/conf/toolchains.xml (--global-toolchains)$user.home/.m2/toolchains.xml (--toolchains)

7.  Drop flags for replacing existing settings, and use --settings as the one overriding the merge result of installation + user (these will be switched!)


installation

user

project

command line

JVM
MAVEN_OPTS.mvn/jvm.config
Maven arguments
MAVEN_ARGS (MNG-7193).mvn/maven.config-$ / --$$
Settings$maven.home/conf/settings.xml$user.home/.m2/settings.xml
--settings
Toolchains$maven.home/conf/toolchains.xml$user.home/.m2/toolchains.xml
--toolchains
  • No labels