From be5caccaff3d00ffca4b3cefe9665b6106bc44bf Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 9 Oct 2016 21:00:42 +0200 Subject: [PATCH] [MNG-6102] Introduce ${maven.conf} in m2.conf Set maven.conf to default ${maven.home}/conf in ${maven.home}/bin/m2.conf to have a canonical property pointing to global configuration files from within Java code. This also helps package maintainers to decouple the Maven installation from a global configuration by solely modifying m2.conf instead of using dirty hacks, if possible at all. --- apache-maven/src/bin/m2.conf | 4 +++- apache-maven/src/conf/settings.xml | 2 +- apache-maven/src/conf/toolchains.xml | 2 +- .../apache/maven/settings/DefaultMavenSettingsBuilder.java | 2 +- .../src/main/java/org/apache/maven/cli/MavenCli.java | 2 +- .../cli/configuration/SettingsXmlConfigurationProcessor.java | 4 ++-- maven-embedder/src/site/apt/logging.apt | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apache-maven/src/bin/m2.conf b/apache-maven/src/bin/m2.conf index 346554cdd4..2235f820f5 100644 --- a/apache-maven/src/bin/m2.conf +++ b/apache-maven/src/bin/m2.conf @@ -1,6 +1,8 @@ main is org.apache.maven.cli.MavenCli from plexus.core +set maven.conf default ${maven.home}/conf + [plexus.core] -load ${maven.home}/conf/logging +load ${maven.conf}/logging optionally ${maven.home}/lib/ext/*.jar load ${maven.home}/lib/*.jar diff --git a/apache-maven/src/conf/settings.xml b/apache-maven/src/conf/settings.xml index 19d7a97799..e27c579cf6 100644 --- a/apache-maven/src/conf/settings.xml +++ b/apache-maven/src/conf/settings.xml @@ -32,7 +32,7 @@ under the License. | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in - | ${maven.home}/conf/settings.xml. + | ${maven.conf}/settings.xml. | | NOTE: This location can be overridden with the CLI option: | diff --git a/apache-maven/src/conf/toolchains.xml b/apache-maven/src/conf/toolchains.xml index aefddd8aa5..b737c179bd 100644 --- a/apache-maven/src/conf/toolchains.xml +++ b/apache-maven/src/conf/toolchains.xml @@ -32,7 +32,7 @@ under the License. | 2. Global Level. This toolchains.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in - | ${maven.home}/conf/toolchains.xml. + | ${maven.conf}/toolchains.xml. | | NOTE: This location can be overridden with the CLI option: | diff --git a/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java b/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java index 820d886e29..207b9aa472 100644 --- a/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java @@ -66,7 +66,7 @@ public class DefaultMavenSettingsBuilder throws IOException, XmlPullParserException { File globalSettingsFile = - getFile( "${maven.home}/conf/settings.xml", "maven.home", + getFile( "${maven.conf}/settings.xml", "maven.conf", MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION ); SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 2b9f099c23..9da7c4d36c 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -142,7 +142,7 @@ public class MavenCli public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" ); public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = - new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/toolchains.xml" ); + new File( System.getProperty( "maven.conf" ), "toolchains.xml" ); private static final String EXT_CLASS_PATH = "maven.ext.class.path"; diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java index 791a226747..d9a69548be 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java @@ -59,8 +59,8 @@ public class SettingsXmlConfigurationProcessor public static final File DEFAULT_USER_SETTINGS_FILE = new File( USER_MAVEN_CONFIGURATION_HOME, "settings.xml" ); - public static final File DEFAULT_GLOBAL_SETTINGS_FILE = new File( System.getProperty( "maven.home", System - .getProperty( "user.dir", "" ) ), "conf/settings.xml" ); + public static final File DEFAULT_GLOBAL_SETTINGS_FILE = + new File( System.getProperty( "maven.conf" ), "settings.xml" ); @Requirement private Logger logger; diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt index cc9257d304..d1eb53af6b 100644 --- a/maven-embedder/src/site/apt/logging.apt +++ b/maven-embedder/src/site/apt/logging.apt @@ -54,7 +54,7 @@ Maven Logging Logging configuration loading is actually done by logging implementation, without any Maven extensions to support merging Maven installation configuration with per-user configuration for example: - `${maven.home}/conf/logging` directory was added to core's classpath (see `${maven.home}/bin/m2.conf`). See your implementation + <<<$\{maven.conf}/logging>>> directory was added to core's classpath (see <<<$\{maven.home}/bin/m2.conf>>>). See your implementation documentation for details on file names, formats, and so on. During Maven initialization, Maven tweaks default root logging level to match CLI verbosity choice. Since such feature isn't available