diff --git a/apache-maven/src/assembly/maven/bin/m2.conf b/apache-maven/src/assembly/maven/bin/m2.conf
index 15e0f5df2ed6..b14417163ff4 100644
--- a/apache-maven/src/assembly/maven/bin/m2.conf
+++ b/apache-maven/src/assembly/maven/bin/m2.conf
@@ -1,6 +1,7 @@
main is org.apache.maven.cli.MavenCli from plexus.core
set maven.conf default ${maven.home}/conf
+set maven.installation.conf default ${maven.conf}
[plexus.core]
load ${maven.conf}/logging
diff --git a/apache-maven/src/assembly/maven/conf/maven.properties b/apache-maven/src/assembly/maven/conf/maven.properties
new file mode 100644
index 000000000000..7c1d76bf563e
--- /dev/null
+++ b/apache-maven/src/assembly/maven/conf/maven.properties
@@ -0,0 +1,40 @@
+#
+# Maven user properties
+#
+
+maven.installation.conf = ${maven.home}/conf
+maven.user.conf = ${user.home}/.m2
+maven.project.conf = ${session.rootDirectory}/.mvn
+
+# Comma-separated list of files to include.
+# Each item may be enclosed in quotes to gracefully include spaces. Items are trimmed before being loaded.
+# If the first character of an item is a question mark, the load will silently fail if the file does not exist.
+${includes} = ?"${maven.user.conf}/maven.properties", \
+ ?"${maven.project.conf}/maven.properties"
+
+#
+# Settings
+#
+# Define the default three levels for settings.
+# The '-is' flag will override the 'maven.installation.settings' property.
+# The '-ps' flag will override the 'maven.project.settings' property.
+# The '-s' flag will override the 'maven.user.settings' property.
+maven.installation.settings = ${maven.installation.conf}/settings.xml
+maven.project.settings = ${maven.project.conf}/settings.xml
+maven.user.settings = ${maven.user.conf}/settings.xml
+
+#
+# Toolchains
+#
+# Define the default three levels for toolchains.
+# The '-it' flag will override the 'maven.installation.toolchains' property.
+# The '-t' flag will override the 'maven.user.toolchains' property.
+maven.installation.toolchains = ${maven.installation.conf}/toolchains.xml
+maven.user.toolchains = ${maven.user.conf}/toolchains.xml
+
+#
+# Extensions
+#
+maven.installation.extensions = ${maven.installation.conf}/extensions.xml
+maven.project.extensions = ${maven.project.conf}/extensions.xml
+maven.user.extensions = ${maven.user.conf}/extensions.xml
diff --git a/apache-maven/src/assembly/maven/conf/settings.xml b/apache-maven/src/assembly/maven/conf/settings.xml
index 1ffdca9f497c..2291dd2e3853 100644
--- a/apache-maven/src/assembly/maven/conf/settings.xml
+++ b/apache-maven/src/assembly/maven/conf/settings.xml
@@ -29,14 +29,15 @@ under the License.
|
| -s /path/to/user/settings.xml
|
- | 2. Global Level. This settings.xml file provides configuration for all Maven
+ | 2. Installation 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.conf}/settings.xml.
+ | ${maven.installation.conf}/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
- | -gs /path/to/global/settings.xml
+ | -is /path/to/installation/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
diff --git a/apache-maven/src/assembly/maven/conf/toolchains.xml b/apache-maven/src/assembly/maven/conf/toolchains.xml
index 75862b4fd099..d8aa088b6a9d 100644
--- a/apache-maven/src/assembly/maven/conf/toolchains.xml
+++ b/apache-maven/src/assembly/maven/conf/toolchains.xml
@@ -29,14 +29,15 @@ under the License.
|
| -t /path/to/user/toolchains.xml
|
- | 2. Global Level. This toolchains.xml file provides configuration for all Maven
+ | 2. Installation 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.conf}/toolchains.xml.
+ | ${maven.installation.conf}/toolchains.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
- | -gt /path/to/global/toolchains.xml
+ | -it /path/to/installation/toolchains.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation.
diff --git a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java b/apache-maven/src/test/java/org/apache/maven/settings/InstallationSettingsTest.java
similarity index 93%
rename from apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
rename to apache-maven/src/test/java/org/apache/maven/settings/InstallationSettingsTest.java
index cf1bf066c417..5ed07bee210b 100644
--- a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
+++ b/apache-maven/src/test/java/org/apache/maven/settings/InstallationSettingsTest.java
@@ -29,10 +29,10 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- * Tests that the global settings.xml shipped with the distribution is in good state.
+ * Tests that the installation settings.xml shipped with the distribution is in good state.
*
*/
-class GlobalSettingsTest {
+class InstallationSettingsTest {
@Test
void testValidGlobalSettings() throws Exception {
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java
new file mode 100644
index 000000000000..d1f27cca0dcf
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api;
+
+import org.apache.maven.api.annotations.Config;
+
+/**
+ * Configuration constants.
+ */
+public final class Constants {
+
+ /**
+ * Maven home.
+ *
+ * @since 3.0.0
+ */
+ @Config(readOnly = true)
+ public static final String MAVEN_HOME = "maven.home";
+
+ /**
+ * Maven installation configuration directory.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.home}/conf")
+ public static final String MAVEN_INSTALLATION_CONF = "maven.installation.conf";
+
+ /**
+ * Maven user configuration directory.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${user.home}/.m2")
+ public static final String MAVEN_USER_CONF = "maven.user.conf";
+
+ /**
+ * Maven project configuration directory.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${session.rootDirectory}/.mvn")
+ public static final String MAVEN_PROJECT_CONF = "maven.project.conf";
+
+ /**
+ * Maven local repository.
+ *
+ * @since 3.0.0
+ */
+ @Config(defaultValue = "${maven.user.conf}/repository")
+ public static final String MAVEN_REPO_LOCAL = "maven.repo.local";
+
+ /**
+ * Maven installation settings.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.installation.conf}/settings.xml")
+ public static final String MAVEN_INSTALLATION_SETTINGS = "maven.installation.settings";
+
+ /**
+ * Maven user settings.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.user.conf}/settings.xml")
+ public static final String MAVEN_USER_SETTINGS = "maven.user.settings";
+
+ /**
+ * Maven project settings.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.project.conf}/settings.xml")
+ public static final String MAVEN_PROJECT_SETTINGS = "maven.project.settings";
+
+ /**
+ * Maven installation extensions.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.installation.conf}/extensions.xml")
+ public static final String MAVEN_INSTALLATION_EXTENSIONS = "maven.installation.extensions";
+
+ /**
+ * Maven user extensions.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.user.conf}/extensions.xml")
+ public static final String MAVEN_USER_EXTENSIONS = "maven.user.extensions";
+
+ /**
+ * Maven project extensions.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.project.conf}/extensions.xml")
+ public static final String MAVEN_PROJECT_EXTENSIONS = "maven.project.extensions";
+
+ /**
+ * Maven installation toolchains.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.installation.conf}/toolchains.xml")
+ public static final String MAVEN_INSTALLATION_TOOLCHAINS = "maven.installation.toolchains";
+
+ /**
+ * Maven user toolchains.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "${maven.user.home}/toolchains.xml")
+ public static final String MAVEN_USER_TOOLCHAINS = "maven.user.toolchains";
+
+ /**
+ * Extensions class path.
+ */
+ @Config
+ public static final String MAVEN_EXT_CLASS_PATH = "maven.ext.class.path";
+
+ /**
+ * Maven output color mode.
+ * Allowed values are auto, always, never.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "auto")
+ public static final String MAVEN_STYLE_COLOR_PROPERTY = "maven.style.color";
+
+ /**
+ * Build timestamp format.
+ *
+ * @since 3.0.0
+ */
+ @Config(source = Config.Source.MODEL, defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX")
+ public static final String MAVEN_BUILD_TIMESTAMP_FORMAT = "maven.build.timestamp.format";
+
+ /**
+ * User controlled relocations.
+ * This property is a comma separated list of entries with the syntax GAV>GAV.
+ * The first GAV can contain * for any elem (so *:*:* would mean ALL, something
+ * you don't want). The second GAV is either fully specified, or also can contain *,
+ * then it behaves as "ordinary relocation": the coordinate is preserved from relocated artifact.
+ * Finally, if right hand GAV is absent (line looks like GAV>), the left hand matching
+ * GAV is banned fully (from resolving).
+ *
+ * Note: the > means project level, while >> means global (whole session level,
+ * so even plugins will get relocated artifacts) relocation.
+ *
+ * For example,
+ *
+ * means: 3 entries, ban org.foo group (exactly, so org.foo.bar is allowed),
+ * relocate org.here to org.there and finally globally relocate (see >> above)
+ * javax.inject:javax.inject:1 to jakarta.inject:jakarta.inject:1.0.5.
+ *
+ * @since 4.0.0
+ */
+ @Config
+ public static final String MAVEN_RELOCATIONS_ENTRIES = "maven.relocations.entries";
+
+ /**
+ * User property for version filters expression, a semicolon separated list of filters to apply. By default, no version
+ * filter is applied (like in Maven 3).
+ *
+ * Supported filters:
+ *
+ *
"h" or "h(num)" - highest version or top list of highest ones filter
+ *
"l" or "l(num)" - lowest version or bottom list of lowest ones filter
+ *
"s" - contextual snapshot filter
+ *
"e(G:A:V)" - predicate filter (leaves out G:A:V from range, if hit, V can be range)
+ *
+ * Example filter expression: "h(5);s;e(org.foo:bar:1) will cause: ranges are filtered for "top 5" (instead
+ * full range), snapshots are banned if root project is not a snapshot, and if range for org.foo:bar is
+ * being processed, version 1 is omitted.
+ *
+ * @since 4.0.0
+ */
+ @Config
+ public static final String MAVEN_VERSION_FILTERS = "maven.versionFilters";
+
+ /**
+ * User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with
+ * {@code org.eclipse.aether.util.repository.ChainedLocalRepositoryManager}.
+ * Default value: null, no chained LRM is used.
+ *
+ * @since 3.9.0
+ */
+ @Config
+ public static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail";
+
+ /**
+ * User property for reverse dependency tree. If enabled, Maven will record ".tracking" directory into local
+ * repository with "reverse dependency tree", essentially explaining WHY given artifact is present in local
+ * repository.
+ * Default: false, will not record anything.
+ *
+ * @since 3.9.0
+ */
+ @Config(defaultValue = "false")
+ public static final String MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE = "maven.repo.local.recordReverseTree";
+
+ /**
+ * User property for selecting dependency manager behaviour regarding transitive dependencies and dependency
+ * management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored
+ * dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence
+ * unlike Maven2, obeys dependency management entries deep in dependency graph as well.
+ *
+ * Default: "true".
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "true")
+ public static final String MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY =
+ "maven.resolver.dependencyManagerTransitivity";
+
+ /**
+ * Resolver transport to use.
+ * Can be default, wagon, apache, jdk or auto.
+ *
+ * @since 4.0.0
+ */
+ @Config(defaultValue = "default")
+ public static final String MAVEN_RESOLVER_TRANSPORT = "maven.resolver.transport";
+
+ /**
+ * Plugin validation level.
+ *
+ * @since 3.9.2
+ */
+ @Config(defaultValue = "inline")
+ public static final String MAVEN_PLUGIN_VALIDATION = "maven.plugin.validation";
+
+ /**
+ * Plugin validation exclusions.
+ *
+ * @since 3.9.6
+ */
+ @Config
+ public static final String MAVEN_PLUGIN_VALIDATION_EXCLUDES = "maven.plugin.validation.excludes";
+
+ /**
+ * ProjectBuilder parallelism.
+ *
+ * @since 4.0.0
+ */
+ @Config(type = "java.lang.Integer", defaultValue = "cores/2 + 1")
+ public static final String MAVEN_PROJECT_BUILDER_PARALLELISM = "maven.projectBuilder.parallelism";
+
+ private Constants() {}
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilder.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilder.java
index 6561e2d0f287..c0e66d8ac53a 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilder.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilder.java
@@ -28,7 +28,7 @@
import org.apache.maven.api.settings.Settings;
/**
- * Builds the effective settings from a user settings file and/or a global settings file.
+ * Builds the effective settings from a user settings file and/or a installation settings file.
*
* @since 4.0.0
*/
@@ -53,8 +53,8 @@ public interface SettingsBuilder extends Service {
*/
@Nonnull
default SettingsBuilderResult build(
- @Nonnull Session session, @Nonnull Source globalSettingsSource, @Nonnull Source userSettingsSource) {
- return build(session, globalSettingsSource, null, userSettingsSource);
+ @Nonnull Session session, @Nonnull Source installationSettingsSource, @Nonnull Source userSettingsSource) {
+ return build(session, installationSettingsSource, null, userSettingsSource);
}
/**
@@ -65,8 +65,8 @@ default SettingsBuilderResult build(
*/
@Nonnull
default SettingsBuilderResult build(
- @Nonnull Session session, @Nonnull Path globalSettingsPath, @Nonnull Path userSettingsPath) {
- return build(session, globalSettingsPath, null, userSettingsPath);
+ @Nonnull Session session, @Nonnull Path installationSettingsPath, @Nonnull Path userSettingsPath) {
+ return build(session, installationSettingsPath, null, userSettingsPath);
}
/**
@@ -78,11 +78,11 @@ default SettingsBuilderResult build(
@Nonnull
default SettingsBuilderResult build(
@Nonnull Session session,
- @Nonnull Source globalSettingsSource,
+ @Nonnull Source installationSettingsSource,
@Nonnull Source projectSettingsSource,
@Nonnull Source userSettingsSource) {
- return build(
- SettingsBuilderRequest.build(session, globalSettingsSource, projectSettingsSource, userSettingsSource));
+ return build(SettingsBuilderRequest.build(
+ session, installationSettingsSource, projectSettingsSource, userSettingsSource));
}
/**
@@ -94,10 +94,11 @@ default SettingsBuilderResult build(
@Nonnull
default SettingsBuilderResult build(
@Nonnull Session session,
- @Nonnull Path globalSettingsPath,
+ @Nonnull Path installationSettingsPath,
@Nonnull Path projectSettingsPath,
@Nonnull Path userSettingsPath) {
- return build(SettingsBuilderRequest.build(session, globalSettingsPath, projectSettingsPath, userSettingsPath));
+ return build(
+ SettingsBuilderRequest.build(session, installationSettingsPath, projectSettingsPath, userSettingsPath));
}
/**
@@ -115,7 +116,7 @@ default List validate(@Nonnull Settings settings) {
* Validate the specified settings.
*
* @param settings The settings to validate, must not be {@code null}.
- * @param isProjectSettings Boolean indicating if the validation is for project settings or user / global settings.
+ * @param isProjectSettings Boolean indicating if the validation is for project settings or user / installation settings.
* @return The list of problems that were encountered, must not be {@code null}.
*/
@Nonnull
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilderRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilderRequest.java
index 249e2954fbdb..09f7bcb341cd 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilderRequest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/SettingsBuilderRequest.java
@@ -42,12 +42,12 @@ public interface SettingsBuilderRequest {
Session getSession();
/**
- * Gets the global settings source.
+ * Gets the installation settings source.
*
- * @return the global settings source or {@code null} if none
+ * @return the installation settings source or {@code null} if none
*/
@Nonnull
- Optional getGlobalSettingsSource();
+ Optional getInstallationSettingsSource();
/**
* Gets the project settings source.
@@ -67,25 +67,25 @@ public interface SettingsBuilderRequest {
@Nonnull
static SettingsBuilderRequest build(
- @Nonnull Session session, @Nonnull Source globalSettingsSource, @Nonnull Source userSettingsSource) {
- return build(session, globalSettingsSource, null, userSettingsSource);
+ @Nonnull Session session, @Nonnull Source installationSettingsSource, @Nonnull Source userSettingsSource) {
+ return build(session, installationSettingsSource, null, userSettingsSource);
}
@Nonnull
static SettingsBuilderRequest build(
- @Nonnull Session session, @Nonnull Path globalSettingsPath, @Nonnull Path userSettingsPath) {
- return build(session, Source.fromPath(globalSettingsPath), null, Source.fromPath(userSettingsPath));
+ @Nonnull Session session, @Nonnull Path installationSettingsPath, @Nonnull Path userSettingsPath) {
+ return build(session, Source.fromPath(installationSettingsPath), null, Source.fromPath(userSettingsPath));
}
@Nonnull
static SettingsBuilderRequest build(
@Nonnull Session session,
- @Nullable Source globalSettingsSource,
+ @Nullable Source installationSettingsSource,
@Nullable Source projectSettingsSource,
@Nullable Source userSettingsSource) {
return builder()
.session(nonNull(session, "session cannot be null"))
- .globalSettingsSource(globalSettingsSource)
+ .installationSettingsSource(installationSettingsSource)
.projectSettingsSource(projectSettingsSource)
.userSettingsSource(userSettingsSource)
.build();
@@ -94,14 +94,14 @@ static SettingsBuilderRequest build(
@Nonnull
static SettingsBuilderRequest build(
@Nonnull Session session,
- @Nullable Path globalSettingsPath,
+ @Nullable Path installationSettingsPath,
@Nullable Path projectSettingsPath,
@Nullable Path userSettingsPath) {
return builder()
.session(nonNull(session, "session cannot be null"))
- .globalSettingsSource(
- globalSettingsPath != null && Files.exists(globalSettingsPath)
- ? Source.fromPath(globalSettingsPath)
+ .installationSettingsSource(
+ installationSettingsPath != null && Files.exists(installationSettingsPath)
+ ? Source.fromPath(installationSettingsPath)
: null)
.projectSettingsSource(
projectSettingsPath != null && Files.exists(projectSettingsPath)
@@ -122,7 +122,7 @@ static SettingsBuilderRequestBuilder builder() {
@NotThreadSafe
class SettingsBuilderRequestBuilder {
Session session;
- Source globalSettingsSource;
+ Source installationSettingsSource;
Source projectSettingsSource;
Source userSettingsSource;
@@ -131,8 +131,8 @@ public SettingsBuilderRequestBuilder session(Session session) {
return this;
}
- public SettingsBuilderRequestBuilder globalSettingsSource(Source globalSettingsSource) {
- this.globalSettingsSource = globalSettingsSource;
+ public SettingsBuilderRequestBuilder installationSettingsSource(Source installationSettingsSource) {
+ this.installationSettingsSource = installationSettingsSource;
return this;
}
@@ -148,30 +148,30 @@ public SettingsBuilderRequestBuilder userSettingsSource(Source userSettingsSourc
public SettingsBuilderRequest build() {
return new DefaultSettingsBuilderRequest(
- session, globalSettingsSource, projectSettingsSource, userSettingsSource);
+ session, installationSettingsSource, projectSettingsSource, userSettingsSource);
}
private static class DefaultSettingsBuilderRequest extends BaseRequest implements SettingsBuilderRequest {
- private final Source globalSettingsSource;
+ private final Source installationSettingsSource;
private final Source projectSettingsSource;
private final Source userSettingsSource;
@SuppressWarnings("checkstyle:ParameterNumber")
DefaultSettingsBuilderRequest(
@Nonnull Session session,
- @Nullable Source globalSettingsSource,
+ @Nullable Source installationSettingsSource,
@Nullable Source projectSettingsSource,
@Nullable Source userSettingsSource) {
super(session);
- this.globalSettingsSource = globalSettingsSource;
+ this.installationSettingsSource = installationSettingsSource;
this.projectSettingsSource = projectSettingsSource;
this.userSettingsSource = userSettingsSource;
}
@Nonnull
@Override
- public Optional getGlobalSettingsSource() {
- return Optional.ofNullable(globalSettingsSource);
+ public Optional getInstallationSettingsSource() {
+ return Optional.ofNullable(installationSettingsSource);
}
@Nonnull
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilder.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilder.java
index ecd4a2b2d2f4..f9bc989ee877 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilder.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilder.java
@@ -24,7 +24,7 @@
import org.apache.maven.api.annotations.Nonnull;
/**
- * Builds the effective toolchains from a user toolchains file and/or a global toolchains file.
+ * Builds the effective toolchains from a user toolchains file and/or an installation toolchains file.
*
* @since 4.0.0
*/
@@ -44,7 +44,7 @@ public interface ToolchainsBuilder extends Service {
* Builds the effective toolchains for the specified toolchains sources.
*
* @param session the {@link Session}, must not be {@code null}
- * @param globalToolchainsSource The {@link Source} pointing to the global toolchains, must not be {@code null}
+ * @param installationToolchainsFile The {@link Source} pointing to the installation toolchains, must not be {@code null}
* @param userToolchainsSource The {@link Source} pointing to the user toolchains, must not be {@code null}
* @throws ToolchainsBuilderException if the project cannot be created
* @throws IllegalArgumentException if an argument is {@code null} or invalid
@@ -52,7 +52,9 @@ public interface ToolchainsBuilder extends Service {
*/
@Nonnull
default ToolchainsBuilderResult build(
- @Nonnull Session session, @Nonnull Source globalToolchainsSource, @Nonnull Source userToolchainsSource) {
- return build(ToolchainsBuilderRequest.build(session, globalToolchainsSource, userToolchainsSource));
+ @Nonnull Session session,
+ @Nonnull Source installationToolchainsFile,
+ @Nonnull Source userToolchainsSource) {
+ return build(ToolchainsBuilderRequest.build(session, installationToolchainsFile, userToolchainsSource));
}
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilderRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilderRequest.java
index 3a1a6d60d9e2..bfe3241fe40c 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilderRequest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainsBuilderRequest.java
@@ -40,12 +40,12 @@ public interface ToolchainsBuilderRequest {
Session getSession();
/**
- * Gets the global Toolchains source.
+ * Gets the installation Toolchains source.
*
- * @return the global Toolchains source or {@code null} if none
+ * @return the installation Toolchains source or {@code null} if none
*/
@Nonnull
- Optional getGlobalToolchainsSource();
+ Optional getInstallationToolchainsSource();
/**
* Gets the user Toolchains source.
@@ -57,22 +57,24 @@ public interface ToolchainsBuilderRequest {
@Nonnull
static ToolchainsBuilderRequest build(
- @Nonnull Session session, @Nullable Source globalToolchainsSource, @Nullable Source userToolchainsSource) {
+ @Nonnull Session session,
+ @Nullable Source installationToolchainsFile,
+ @Nullable Source userToolchainsSource) {
return builder()
.session(nonNull(session, "session cannot be null"))
- .globalToolchainsSource(globalToolchainsSource)
+ .installationToolchainsSource(installationToolchainsFile)
.userToolchainsSource(userToolchainsSource)
.build();
}
@Nonnull
static ToolchainsBuilderRequest build(
- @Nonnull Session session, @Nullable Path globalToolchainsPath, @Nullable Path userToolchainsPath) {
+ @Nonnull Session session, @Nullable Path installationToolchainsFile, @Nullable Path userToolchainsPath) {
return builder()
.session(nonNull(session, "session cannot be null"))
- .globalToolchainsSource(
- globalToolchainsPath != null && Files.exists(globalToolchainsPath)
- ? Source.fromPath(globalToolchainsPath)
+ .installationToolchainsSource(
+ installationToolchainsFile != null && Files.exists(installationToolchainsFile)
+ ? Source.fromPath(installationToolchainsFile)
: null)
.userToolchainsSource(
userToolchainsPath != null && Files.exists(userToolchainsPath)
@@ -89,7 +91,7 @@ static ToolchainsBuilderRequestBuilder builder() {
@NotThreadSafe
class ToolchainsBuilderRequestBuilder {
Session session;
- Source globalToolchainsSource;
+ Source installationToolchainsSource;
Source userToolchainsSource;
public ToolchainsBuilderRequestBuilder session(Session session) {
@@ -97,8 +99,8 @@ public ToolchainsBuilderRequestBuilder session(Session session) {
return this;
}
- public ToolchainsBuilderRequestBuilder globalToolchainsSource(Source globalToolchainsSource) {
- this.globalToolchainsSource = globalToolchainsSource;
+ public ToolchainsBuilderRequestBuilder installationToolchainsSource(Source installationToolchainsSource) {
+ this.installationToolchainsSource = installationToolchainsSource;
return this;
}
@@ -109,27 +111,27 @@ public ToolchainsBuilderRequestBuilder userToolchainsSource(Source userToolchain
public ToolchainsBuilderRequest build() {
return new ToolchainsBuilderRequestBuilder.DefaultToolchainsBuilderRequest(
- session, globalToolchainsSource, userToolchainsSource);
+ session, installationToolchainsSource, userToolchainsSource);
}
private static class DefaultToolchainsBuilderRequest extends BaseRequest implements ToolchainsBuilderRequest {
- private final Source globalToolchainsSource;
+ private final Source installationToolchainsSource;
private final Source userToolchainsSource;
@SuppressWarnings("checkstyle:ParameterNumber")
DefaultToolchainsBuilderRequest(
@Nonnull Session session,
- @Nullable Source globalToolchainsSource,
+ @Nullable Source installationToolchainsSource,
@Nullable Source userToolchainsSource) {
super(session);
- this.globalToolchainsSource = globalToolchainsSource;
+ this.installationToolchainsSource = installationToolchainsSource;
this.userToolchainsSource = userToolchainsSource;
}
@Nonnull
@Override
- public Optional getGlobalToolchainsSource() {
- return Optional.ofNullable(globalToolchainsSource);
+ public Optional getInstallationToolchainsSource() {
+ return Optional.ofNullable(installationToolchainsSource);
}
@Nonnull
diff --git a/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Config.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Config.java
new file mode 100644
index 000000000000..5b3703d643fb
--- /dev/null
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Config.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Experimental
+@Documented
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.FIELD)
+public @interface Config {
+
+ Source source() default Source.USER_PROPERTIES;
+
+ String type() default "java.lang.String";
+
+ String defaultValue() default "";
+
+ boolean readOnly() default false;
+
+ enum Source {
+ USER_PROPERTIES,
+ MODEL
+ }
+}
diff --git a/api/maven-api-settings/src/main/mdo/settings.mdo b/api/maven-api-settings/src/main/mdo/settings.mdo
index 2135ae3e9386..b07d35653498 100644
--- a/api/maven-api-settings/src/main/mdo/settings.mdo
+++ b/api/maven-api-settings/src/main/mdo/settings.mdo
@@ -44,8 +44,7 @@
TrackableBase1.0.0+
- common base class that contains code to track the source for
- this instance (USER|GLOBAL)
+ Common base class that contains code to track the source for this instance.
diff --git a/api/maven-api-toolchain/src/main/mdo/toolchains.mdo b/api/maven-api-toolchain/src/main/mdo/toolchains.mdo
index 49c1b2f6b49a..b8e2b1bbf81d 100644
--- a/api/maven-api-toolchain/src/main/mdo/toolchains.mdo
+++ b/api/maven-api-toolchain/src/main/mdo/toolchains.mdo
@@ -51,7 +51,7 @@
TrackableBase1.1.0+
- Common base class that contains code to track the source for this instance (USER|GLOBAL)
+ Common base class that contains code to track the source for this instance.
diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultSettingsBuilder.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultSettingsBuilder.java
index 24b64f6436fc..e31011439698 100644
--- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultSettingsBuilder.java
+++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultSettingsBuilder.java
@@ -66,8 +66,8 @@ public class DefaultSettingsBuilder implements SettingsBuilder {
public SettingsBuilderResult build(SettingsBuilderRequest request) throws SettingsBuilderException {
List problems = new ArrayList<>();
- Source globalSource = request.getGlobalSettingsSource().orElse(null);
- Settings global = readSettings(globalSource, false, request, problems);
+ Source installationSource = request.getInstallationSettingsSource().orElse(null);
+ Settings installation = readSettings(installationSource, false, request, problems);
Source projectSource = request.getProjectSettingsSource().orElse(null);
Settings project = readSettings(projectSource, true, request, problems);
@@ -76,7 +76,7 @@ public SettingsBuilderResult build(SettingsBuilderRequest request) throws Settin
Settings user = readSettings(userSource, false, request, problems);
Settings effective =
- settingsMerger.merge(user, settingsMerger.merge(project, global, false, null), false, null);
+ settingsMerger.merge(user, settingsMerger.merge(project, installation, false, null), false, null);
// If no repository is defined in the user/global settings,
// it means that we have "old" settings (as those are new in 4.0)
diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java
index 08b3f509e8f2..64a2ba378333 100644
--- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java
+++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java
@@ -57,13 +57,13 @@ public class DefaultToolchainsBuilder implements ToolchainsBuilder {
public ToolchainsBuilderResult build(ToolchainsBuilderRequest request) throws ToolchainsBuilderException {
List problems = new ArrayList<>();
- Source globalSource = request.getGlobalToolchainsSource().orElse(null);
- PersistedToolchains global = readToolchains(globalSource, request, problems);
+ Source installationSource = request.getInstallationToolchainsSource().orElse(null);
+ PersistedToolchains installation = readToolchains(installationSource, request, problems);
Source userSource = request.getUserToolchainsSource().orElse(null);
PersistedToolchains user = readToolchains(userSource, request, problems);
- PersistedToolchains effective = toolchainsMerger.merge(user, global, false, null);
+ PersistedToolchains effective = toolchainsMerger.merge(user, installation, false, null);
if (hasErrors(problems)) {
throw new ToolchainsBuilderException("Error building toolchains", problems);
diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/MavenBuildTimestamp.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/MavenBuildTimestamp.java
index 75544b5891f2..3ee89cedd844 100644
--- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/MavenBuildTimestamp.java
+++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/MavenBuildTimestamp.java
@@ -26,18 +26,18 @@
import java.util.Properties;
import java.util.TimeZone;
+import org.apache.maven.api.Constants;
+
/**
* MavenBuildTimestamp
*/
public class MavenBuildTimestamp {
// ISO 8601-compliant timestamp for machine readability
- public static final String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
-
- public static final String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format";
+ public static final String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX";
public static final TimeZone DEFAULT_BUILD_TIME_ZONE = TimeZone.getTimeZone("Etc/UTC");
- private String formattedTimestamp;
+ private final String formattedTimestamp;
public MavenBuildTimestamp() {
this(Instant.now());
@@ -48,7 +48,7 @@ public MavenBuildTimestamp(Instant time) {
}
public MavenBuildTimestamp(Instant time, Map properties) {
- this(time, properties != null ? properties.get(BUILD_TIMESTAMP_FORMAT_PROPERTY) : null);
+ this(time, properties != null ? properties.get(Constants.MAVEN_BUILD_TIMESTAMP_FORMAT) : null);
}
/**
@@ -58,7 +58,7 @@ public MavenBuildTimestamp(Instant time, Map properties) {
*/
@Deprecated
public MavenBuildTimestamp(Instant time, Properties properties) {
- this(time, properties != null ? properties.getProperty(BUILD_TIMESTAMP_FORMAT_PROPERTY) : null);
+ this(time, properties != null ? properties.getProperty(Constants.MAVEN_BUILD_TIMESTAMP_FORMAT) : null);
}
public MavenBuildTimestamp(Instant time, String timestampFormat) {
diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java
index 4493ecc5d6d6..99b810f83fe9 100644
--- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java
+++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/relocation/UserPropertiesArtifactRelocationSource.java
@@ -25,6 +25,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.apache.maven.api.Constants;
import org.apache.maven.api.di.Named;
import org.apache.maven.api.di.Priority;
import org.apache.maven.api.di.Singleton;
@@ -51,8 +52,6 @@ public final class UserPropertiesArtifactRelocationSource implements MavenArtifa
public static final String NAME = "userProperties";
private static final Logger LOGGER = LoggerFactory.getLogger(UserPropertiesArtifactRelocationSource.class);
- private static final String CONFIG_PROP_RELOCATIONS_ENTRIES = "maven.relocations.entries";
-
private static final Artifact SENTINEL = new DefaultArtifact("org.apache.maven.banned:user-relocation:1.0");
@Override
@@ -153,7 +152,7 @@ private Relocation getRelocation(Artifact artifact) {
}
private Relocations parseRelocations(RepositorySystemSession session) {
- String relocationsEntries = (String) session.getConfigProperties().get(CONFIG_PROP_RELOCATIONS_ENTRIES);
+ String relocationsEntries = (String) session.getConfigProperties().get(Constants.MAVEN_RELOCATIONS_ENTRIES);
if (relocationsEntries == null) {
return null;
}
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
index c8fe844c1c2a..aa9748ca51ff 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
@@ -97,11 +97,11 @@ public class DefaultMavenExecutionRequest implements MavenExecutionRequest {
private File projectSettingsFile;
- private File globalSettingsFile;
+ private File installationSettingsFile;
private File userToolchainsFile;
- private File globalToolchainsFile;
+ private File installationToolchainsFile;
// ----------------------------------------------------------------------------
// Request
@@ -190,9 +190,9 @@ public static MavenExecutionRequest copy(MavenExecutionRequest original) {
copy.setPluginGroups(original.getPluginGroups());
copy.setProjectPresent(original.isProjectPresent());
copy.setUserSettingsFile(original.getUserSettingsFile());
- copy.setGlobalSettingsFile(original.getGlobalSettingsFile());
+ copy.setInstallationSettingsFile(original.getInstallationSettingsFile());
copy.setUserToolchainsFile(original.getUserToolchainsFile());
- copy.setGlobalToolchainsFile(original.getGlobalToolchainsFile());
+ copy.setInstallationToolchainsFile(original.getInstallationToolchainsFile());
copy.setBaseDirectory((original.getBaseDirectory() != null) ? new File(original.getBaseDirectory()) : null);
copy.setGoals(original.getGoals());
copy.setRecursive(original.isRecursive());
@@ -866,13 +866,25 @@ public MavenExecutionRequest setProjectSettingsFile(File projectSettingsFile) {
}
@Override
+ @Deprecated
public File getGlobalSettingsFile() {
- return globalSettingsFile;
+ return getInstallationSettingsFile();
}
@Override
+ @Deprecated
public MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile) {
- this.globalSettingsFile = globalSettingsFile;
+ return setInstallationSettingsFile(globalSettingsFile);
+ }
+
+ @Override
+ public File getInstallationSettingsFile() {
+ return installationSettingsFile;
+ }
+
+ @Override
+ public MavenExecutionRequest setInstallationSettingsFile(File installationSettingsFile) {
+ this.installationSettingsFile = installationSettingsFile;
return this;
}
@@ -890,13 +902,26 @@ public MavenExecutionRequest setUserToolchainsFile(File userToolchainsFile) {
}
@Override
+ @Deprecated
public File getGlobalToolchainsFile() {
- return globalToolchainsFile;
+ return installationToolchainsFile;
+ }
+
+ @Override
+ @Deprecated
+ public MavenExecutionRequest setGlobalToolchainsFile(File installationToolchainsFile) {
+ this.installationToolchainsFile = installationToolchainsFile;
+ return this;
+ }
+
+ @Override
+ public File getInstallationToolchainsFile() {
+ return installationToolchainsFile;
}
@Override
- public MavenExecutionRequest setGlobalToolchainsFile(File globalToolchainsFile) {
- this.globalToolchainsFile = globalToolchainsFile;
+ public MavenExecutionRequest setInstallationToolchainsFile(File installationToolchainsFile) {
+ this.installationToolchainsFile = installationToolchainsFile;
return this;
}
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
index ab548a37ae6c..5f217daa50ff 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.maven.api.Constants;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.bridge.MavenRepositorySystem;
@@ -125,7 +126,11 @@ private ArtifactRepository createLocalRepository(MavenExecutionRequest request)
}
if (localRepositoryPath == null || localRepositoryPath.isEmpty()) {
- localRepositoryPath = new File(System.getProperty("user.home"), ".m2/repository").getAbsolutePath();
+ String path = request.getUserProperties().getProperty(Constants.MAVEN_USER_CONF);
+ if (path == null) {
+ path = request.getSystemProperties().getProperty("user.home") + File.separator + ".m2";
+ }
+ localRepositoryPath = new File(path, "repository").getAbsolutePath();
}
try {
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
index 1904dff7a64b..f95f48b26ca6 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
@@ -426,10 +426,16 @@ public interface MavenExecutionRequest {
MavenExecutionRequest setProjectSettingsFile(File projectSettingsFile);
+ @Deprecated
File getGlobalSettingsFile();
+ @Deprecated
MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile);
+ File getInstallationSettingsFile();
+
+ MavenExecutionRequest setInstallationSettingsFile(File installationSettingsFile);
+
MavenExecutionRequest addRemoteRepository(ArtifactRepository repository);
MavenExecutionRequest addPluginArtifactRepository(ArtifactRepository repository);
@@ -467,7 +473,9 @@ public interface MavenExecutionRequest {
*
* @return the global toolchains file
* @since 3.3.0
+ * @deprecated use {@link #getInstallationToolchainsFile()}
*/
+ @Deprecated
File getGlobalToolchainsFile();
/**
@@ -475,9 +483,27 @@ public interface MavenExecutionRequest {
* @param globalToolchainsFile the global toolchains file
* @return this request
* @since 3.3.0
+ * @deprecated use {@link #setInstallationToolchainsFile(File)}
*/
+ @Deprecated
MavenExecutionRequest setGlobalToolchainsFile(File globalToolchainsFile);
+ /**
+ *
+ *
+ * @return the installation toolchains file
+ * @since 4.0.0
+ */
+ File getInstallationToolchainsFile();
+
+ /**
+ *
+ * @param installationToolchainsFile the installation toolchains file
+ * @return this request
+ * @since 4.0.0
+ */
+ MavenExecutionRequest setInstallationToolchainsFile(File installationToolchainsFile);
+
ExecutionListener getExecutionListener();
MavenExecutionRequest setExecutionListener(ExecutionListener executionListener);
diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
index 05d1d02bfe36..f49ef3b727b2 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
@@ -30,6 +30,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import org.apache.maven.api.Constants;
import org.apache.maven.api.di.Inject;
import org.apache.maven.api.di.Named;
import org.apache.maven.api.di.Singleton;
@@ -68,7 +69,6 @@
import org.eclipse.aether.util.graph.version.PredicateVersionFilter;
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
-import org.eclipse.aether.util.repository.ChainedLocalRepositoryManager;
import org.eclipse.aether.util.repository.DefaultAuthenticationSelector;
import org.eclipse.aether.util.repository.DefaultMirrorSelector;
import org.eclipse.aether.util.repository.DefaultProxySelector;
@@ -89,66 +89,14 @@
@Named
@Singleton
public class DefaultRepositorySystemSessionFactory implements RepositorySystemSessionFactory {
- /**
- * User property for version filters expression, a semicolon separated list of filters to apply. By default, no version
- * filter is applied (like in Maven 3).
- *
- * Supported filters:
- *
- *
"h" or "h(num)" - highest version or top list of highest ones filter
- *
"l" or "l(num)" - lowest version or bottom list of lowest ones filter
- *
"s" - contextual snapshot filter
- *
"e(G:A:V)" - predicate filter (leaves out G:A:V from range, if hit, V can be range)
- *
- * Example filter expression: {@code "h(5);s;e(org.foo:bar:1)} will cause: ranges are filtered for "top 5" (instead
- * full range), snapshots are banned if root project is not a snapshot, and if range for {@code org.foo:bar} is
- * being processed, version 1 is omitted.
- *
- * @since 4.0.0
- */
- private static final String MAVEN_VERSION_FILTERS = "maven.versionFilters";
-
- /**
- * User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with
- * {@link ChainedLocalRepositoryManager}.
- * Default value: {@code null}, no chained LRM is used.
- *
- * @since 3.9.0
- */
- private static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail";
-
- /**
- * User property for reverse dependency tree. If enabled, Maven will record ".tracking" directory into local
- * repository with "reverse dependency tree", essentially explaining WHY given artifact is present in local
- * repository.
- * Default: {@code false}, will not record anything.
- *
- * @since 3.9.0
- */
- private static final String MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE = "maven.repo.local.recordReverseTree";
-
- /**
- * User property for selecting dependency manager behaviour regarding transitive dependencies and dependency
- * management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored
- * dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence
- * unlike Maven2, obeys dependency management entries deep in dependency graph as well.
- *
- * Default: {@code "true"}.
- *
- * @since 4.0.0
- */
- private static final String MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY_KEY =
- "maven.resolver.dependencyManagerTransitivity";
-
- private static final String MAVEN_RESOLVER_TRANSPORT_KEY = "maven.resolver.transport";
- private static final String MAVEN_RESOLVER_TRANSPORT_DEFAULT = "default";
+ public static final String MAVEN_RESOLVER_TRANSPORT_DEFAULT = "default";
- private static final String MAVEN_RESOLVER_TRANSPORT_WAGON = "wagon";
+ public static final String MAVEN_RESOLVER_TRANSPORT_WAGON = "wagon";
- private static final String MAVEN_RESOLVER_TRANSPORT_APACHE = "apache";
+ public static final String MAVEN_RESOLVER_TRANSPORT_APACHE = "apache";
- private static final String MAVEN_RESOLVER_TRANSPORT_JDK = "jdk";
+ public static final String MAVEN_RESOLVER_TRANSPORT_JDK = "jdk";
/**
* This name for Apache HttpClient transport is deprecated.
@@ -158,7 +106,7 @@ public class DefaultRepositorySystemSessionFactory implements RepositorySystemSe
@Deprecated
private static final String MAVEN_RESOLVER_TRANSPORT_NATIVE = "native";
- private static final String MAVEN_RESOLVER_TRANSPORT_AUTO = "auto";
+ public static final String MAVEN_RESOLVER_TRANSPORT_AUTO = "auto";
private static final String WAGON_TRANSPORTER_PRIORITY_KEY = "aether.priority.WagonTransporterFactory";
@@ -257,7 +205,7 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
sessionBuilder.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(
request.isIgnoreMissingArtifactDescriptor(), request.isIgnoreInvalidArtifactDescriptor()));
- VersionFilter versionFilter = buildVersionFilter(mergedProps.get(MAVEN_VERSION_FILTERS));
+ VersionFilter versionFilter = buildVersionFilter(mergedProps.get(Constants.MAVEN_VERSION_FILTERS));
if (versionFilter != null) {
sessionBuilder.setVersionFilter(versionFilter);
}
@@ -390,7 +338,8 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
}
sessionBuilder.setAuthenticationSelector(authSelector);
- Object transport = mergedProps.getOrDefault(MAVEN_RESOLVER_TRANSPORT_KEY, MAVEN_RESOLVER_TRANSPORT_DEFAULT);
+ Object transport =
+ mergedProps.getOrDefault(Constants.MAVEN_RESOLVER_TRANSPORT, MAVEN_RESOLVER_TRANSPORT_DEFAULT);
if (MAVEN_RESOLVER_TRANSPORT_DEFAULT.equals(transport)) {
// The "default" mode (user did not set anything) from now on defaults to AUTO
} else if (MAVEN_RESOLVER_TRANSPORT_JDK.equals(transport)) {
@@ -425,21 +374,21 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
RepositoryListener repositoryListener = eventSpyDispatcher.chainListener(new LoggingRepositoryListener(logger));
boolean recordReverseTree = Boolean.parseBoolean(
- mergedProps.getOrDefault(MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE, Boolean.FALSE.toString()));
+ mergedProps.getOrDefault(Constants.MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE, Boolean.FALSE.toString()));
if (recordReverseTree) {
repositoryListener = new ChainedRepositoryListener(repositoryListener, new ReverseTreeRepositoryListener());
}
sessionBuilder.setRepositoryListener(repositoryListener);
// may be overridden
- String resolverDependencyManagerTransitivity =
- mergedProps.getOrDefault(MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY_KEY, Boolean.TRUE.toString());
+ String resolverDependencyManagerTransitivity = mergedProps.getOrDefault(
+ Constants.MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY, Boolean.TRUE.toString());
sessionBuilder.setDependencyManager(
supplier.getDependencyManager(Boolean.parseBoolean(resolverDependencyManagerTransitivity)));
ArrayList paths = new ArrayList<>();
paths.add(Paths.get(request.getLocalRepository().getBasedir()));
- String localRepoTail = mergedProps.get(MAVEN_REPO_LOCAL_TAIL);
+ String localRepoTail = mergedProps.get(Constants.MAVEN_REPO_LOCAL_TAIL);
if (localRepoTail != null) {
Arrays.stream(localRepoTail.split(","))
.filter(p -> p != null && !p.trim().isEmpty())
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java
index cf15292df8df..35cae50a4c94 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java
@@ -38,6 +38,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
+import org.apache.maven.api.Constants;
import org.apache.maven.eventspy.AbstractEventSpy;
import org.apache.maven.execution.ExecutionEvent;
import org.apache.maven.execution.MavenSession;
@@ -66,11 +67,7 @@ public final class DefaultPluginValidationManager extends AbstractEventSpy imple
private static final String PLUGIN_EXCLUDES_KEY = DefaultPluginValidationManager.class.getName() + ".excludes";
- private static final String MAVEN_PLUGIN_VALIDATION_KEY = "maven.plugin.validation";
-
- private static final String MAVEN_PLUGIN_VALIDATION_EXCLUDES_KEY = "maven.plugin.validation.excludes";
-
- private static final ValidationReportLevel DEFAULT_VALIDATION_LEVEL = ValidationReportLevel.INLINE;
+ public static final ValidationReportLevel DEFAULT_VALIDATION_LEVEL = ValidationReportLevel.INLINE;
private static final Collection INLINE_VALIDATION_LEVEL = Collections.unmodifiableCollection(
Arrays.asList(ValidationReportLevel.INLINE, ValidationReportLevel.BRIEF));
@@ -106,7 +103,7 @@ private List> validationPluginExcludes(RepositorySystemSession session) {
}
private List parsePluginExcludes(RepositorySystemSession session) {
- String excludes = ConfigUtils.getString(session, null, MAVEN_PLUGIN_VALIDATION_EXCLUDES_KEY);
+ String excludes = ConfigUtils.getString(session, null, Constants.MAVEN_PLUGIN_VALIDATION_EXCLUDES);
if (excludes == null || excludes.isEmpty()) {
return Collections.emptyList();
}
@@ -122,7 +119,7 @@ private ValidationReportLevel validationReportLevel(RepositorySystemSession sess
}
private ValidationReportLevel parseValidationReportLevel(RepositorySystemSession session) {
- String level = ConfigUtils.getString(session, null, MAVEN_PLUGIN_VALIDATION_KEY);
+ String level = ConfigUtils.getString(session, null, Constants.MAVEN_PLUGIN_VALIDATION);
if (level == null || level.isEmpty()) {
return DEFAULT_VALIDATION_LEVEL;
}
@@ -131,7 +128,7 @@ private ValidationReportLevel parseValidationReportLevel(RepositorySystemSession
} catch (IllegalArgumentException e) {
logger.warn(
"Invalid value specified for property {}: '{}'. Supported values are (case insensitive): {}",
- MAVEN_PLUGIN_VALIDATION_KEY,
+ Constants.MAVEN_PLUGIN_VALIDATION,
level,
Arrays.toString(ValidationReportLevel.values()));
return DEFAULT_VALIDATION_LEVEL;
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
index 131c9a69d9e1..67bffa279942 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
@@ -57,6 +57,7 @@
import org.apache.maven.ProjectCycleException;
import org.apache.maven.RepositoryUtils;
+import org.apache.maven.api.Constants;
import org.apache.maven.api.Session;
import org.apache.maven.api.SessionData;
import org.apache.maven.api.feature.Features;
@@ -118,7 +119,7 @@
@Named
@Singleton
public class DefaultProjectBuilder implements ProjectBuilder {
- public static final String BUILDER_PARALLELISM = "maven.projectBuilder.parallelism";
+
public static final int DEFAULT_BUILDER_PARALLELISM = Runtime.getRuntime().availableProcessors() / 2 + 1;
private final Logger logger = LoggerFactory.getLogger(getClass());
@@ -382,10 +383,7 @@ public void close() {
private int getParallelism(ProjectBuildingRequest request) {
int parallelism = DEFAULT_BUILDER_PARALLELISM;
try {
- String str = request.getUserProperties().getProperty(BUILDER_PARALLELISM);
- if (str == null) {
- str = request.getSystemProperties().getProperty(BUILDER_PARALLELISM);
- }
+ String str = request.getUserProperties().getProperty(Constants.MAVEN_PROJECT_BUILDER_PARALLELISM);
if (str != null) {
parallelism = Integer.parseInt(str);
}
diff --git a/maven-docgen/pom.xml b/maven-docgen/pom.xml
new file mode 100644
index 000000000000..1e84e830f51c
--- /dev/null
+++ b/maven-docgen/pom.xml
@@ -0,0 +1,118 @@
+
+
+
+ 4.0.0
+
+ org.apache.maven
+ maven
+ 4.0.0-beta-4-SNAPSHOT
+
+
+ maven-docgen
+
+ Maven Documentation Generator
+
+
+ true
+
+
+
+
+
+ org.apache.maven
+ maven-api-impl
+
+
+ org.apache.maven
+ maven-core
+
+
+ org.apache.maven
+ maven-embedder
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+ org.ow2.asm
+ asm
+
+
+ org.jboss.forge.roaster
+ roaster-api
+ 2.29.0.Final
+
+
+ org.jboss.forge.roaster
+ roaster-jdt
+ 2.29.0.Final
+
+
+ org.apache.velocity
+ velocity-engine-core
+ 2.3
+
+
+ org.codehaus.plexus
+ plexus-utils
+
+
+
+
+ org.slf4j
+ slf4j-simple
+ runtime
+
+
+ org.apache.commons
+ commons-lang3
+ 3.14.0
+ runtime
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.3.0
+
+
+ render-configuration-page
+
+ java
+
+ verify
+
+ org.apache.maven.tools.CollectConfiguration
+
+ ${basedir}/..
+ ${basedir}/../src/site/markdown/configuration.md
+
+
+
+
+
+
+
+
diff --git a/maven-docgen/src/main/java/org/apache/maven/tools/CollectConfiguration.java b/maven-docgen/src/main/java/org/apache/maven/tools/CollectConfiguration.java
new file mode 100644
index 000000000000..01554d540bf7
--- /dev/null
+++ b/maven-docgen/src/main/java/org/apache/maven/tools/CollectConfiguration.java
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.tools;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.spi.ToolProvider;
+
+import org.apache.maven.api.annotations.Config;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.codehaus.plexus.util.io.CachingWriter;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AST;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Javadoc;
+import org.jboss.forge.roaster.model.JavaDocCapable;
+import org.jboss.forge.roaster.model.JavaDocTag;
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.impl.JavaDocImpl;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Opcodes;
+
+public class CollectConfiguration {
+
+ public static void main(String[] args) throws Exception {
+ try {
+ Path start = Paths.get(args.length > 0 ? args[0] : ".");
+ Path output = Paths.get(args.length > 1 ? args[1] : "output");
+
+ TreeMap discoveredKeys = new TreeMap<>();
+
+ Files.walk(start)
+ .map(Path::toAbsolutePath)
+ .filter(p -> p.getFileName().toString().endsWith(".class"))
+ .filter(p -> p.toString().contains("/target/classes/"))
+ .forEach(p -> {
+ processClass(p, discoveredKeys);
+ });
+
+ VelocityEngine velocityEngine = new VelocityEngine();
+ Properties properties = new Properties();
+ properties.setProperty("resource.loaders", "classpath");
+ properties.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName());
+ velocityEngine.init(properties);
+
+ VelocityContext context = new VelocityContext();
+ context.put("keys", discoveredKeys.values());
+
+ try (Writer fileWriter = new CachingWriter(output, StandardCharsets.UTF_8)) {
+ velocityEngine.getTemplate("page.vm").merge(context, fileWriter);
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ }
+ }
+
+ private static void processClass(Path path, Map discoveredKeys) {
+ try {
+ ClassReader classReader = new ClassReader(Files.newInputStream(path));
+ classReader.accept(
+ new ClassVisitor(Opcodes.ASM9) {
+ @Override
+ public FieldVisitor visitField(
+ int fieldAccess,
+ String fieldName,
+ String fieldDescriptor,
+ String fieldSignature,
+ Object fieldValue) {
+ return new FieldVisitor(Opcodes.ASM9) {
+ @Override
+ public AnnotationVisitor visitAnnotation(
+ String annotationDescriptor, boolean annotationVisible) {
+ if (annotationDescriptor.equals("Lorg/apache/maven/api/annotations/Config;")) {
+ return new AnnotationVisitor(Opcodes.ASM9) {
+ Map values = new HashMap<>();
+
+ @Override
+ public void visit(String name, Object value) {
+ values.put(name, value);
+ }
+
+ @Override
+ public void visitEnum(String name, String descriptor, String value) {
+ values.put(name, value);
+ }
+
+ @Override
+ public void visitEnd() {
+ JavaType> jtype = parse(Paths.get(path.toString()
+ .replace("/target/classes/", "/src/main/java/")
+ .replace(".class", ".java")));
+ FieldSource f =
+ ((JavaClassSource) jtype).getField(fieldName);
+
+ String fqName = null;
+ String desc = cloneJavadoc(f.getJavaDoc())
+ .removeAllTags()
+ .getFullText()
+ .replace("*", "\\*");
+ String since = getSince(f);
+ String source =
+ switch ((values.get("source") != null
+ ? (String) values.get("source")
+ : Config.Source.USER_PROPERTIES.toString())
+ .toLowerCase()) {
+ case "model" -> "Model properties";
+ case "user_properties" -> "User properties";
+ default -> throw new IllegalStateException();
+ };
+ String type =
+ switch ((values.get("type") != null
+ ? (String) values.get("type")
+ : "java.lang.String")) {
+ case "java.lang.String" -> "String";
+ case "java.lang.Integer" -> "Integer";
+ default -> throw new IllegalStateException();
+ };
+ discoveredKeys.put(
+ fieldValue.toString(),
+ new ConfigurationKey(
+ fieldValue.toString(),
+ values.get("defaultValue") != null
+ ? values.get("defaultValue")
+ .toString()
+ : null,
+ fqName,
+ desc,
+ since,
+ source,
+ type));
+ }
+ };
+ }
+ return null;
+ }
+ };
+ }
+ },
+ 0);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ static JavaDocSource