This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push: new cf421eee87 [MNG-8389] MavenExReq lacks u/p/i settings file paths (#1939) cf421eee87 is described below commit cf421eee87ae8bfa4feca1d994199a8cfc57143f Author: Tamas Cservenak <ta...@cservenak.net> AuthorDate: Fri Nov 29 21:54:36 2024 +0100 [MNG-8389] MavenExReq lacks u/p/i settings file paths (#1939) * [MNG-8389] MavenExReq lacks u/p/i settings file paths The "effective" paths for 3 settings file was not set on MavenExecutionRequest. --- https://issues.apache.org/jira/browse/MNG-8389 --- .../java/org/apache/maven/cling/invoker/LookupContext.java | 5 +++++ .../java/org/apache/maven/cling/invoker/LookupInvoker.java | 14 +++++++++++--- .../org/apache/maven/cling/invoker/mvn/MavenInvoker.java | 4 +--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java index cf0b09b4f4..2b29f846ed 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java @@ -86,6 +86,11 @@ public class LookupContext implements AutoCloseable { public ContainerCapsule containerCapsule; public Lookup lookup; + // paths user can override from CLI, and we need to set on MavenExReq + public Path installationSettingsPath; + public Path projectSettingsPath; + public Path userSettingsPath; + public boolean interactive; public Path localRepositoryPath; public Settings effectiveSettings; diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java index 23c93bd535..8c6aab340c 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java @@ -450,8 +450,8 @@ public abstract class LookupInvoker<C extends LookupContext> implements Invoker protected void settings(C context, SettingsBuilder settingsBuilder) throws Exception { Options mavenOptions = context.invokerRequest.options(); - Path userSettingsFile = null; + Path userSettingsFile = null; if (mavenOptions.altUserSettings().isPresent()) { userSettingsFile = context.cwdResolver.apply(mavenOptions.altUserSettings().get()); @@ -468,7 +468,6 @@ public abstract class LookupInvoker<C extends LookupContext> implements Invoker } Path projectSettingsFile = null; - if (mavenOptions.altProjectSettings().isPresent()) { projectSettingsFile = context.cwdResolver.apply(mavenOptions.altProjectSettings().get()); @@ -486,7 +485,6 @@ public abstract class LookupInvoker<C extends LookupContext> implements Invoker } Path installationSettingsFile = null; - if (mavenOptions.altInstallationSettings().isPresent()) { installationSettingsFile = context.cwdResolver.apply( mavenOptions.altInstallationSettings().get()); @@ -503,6 +501,10 @@ public abstract class LookupInvoker<C extends LookupContext> implements Invoker } } + context.installationSettingsPath = installationSettingsFile; + context.projectSettingsPath = projectSettingsFile; + context.userSettingsPath = userSettingsFile; + Function<String, String> interpolationSource = Interpolator.chain( context.protoSession.getUserProperties()::get, context.protoSession.getSystemProperties()::get); SettingsBuilderRequest settingsRequest = SettingsBuilderRequest.builder() @@ -608,6 +610,12 @@ public abstract class LookupInvoker<C extends LookupContext> implements Invoker request.setSystemProperties(toProperties(context.protoSession.getSystemProperties())); request.setUserProperties(toProperties(context.protoSession.getUserProperties())); + request.setInstallationSettingsFile( + context.installationSettingsPath != null ? context.installationSettingsPath.toFile() : null); + request.setProjectSettingsFile( + context.projectSettingsPath != null ? context.projectSettingsPath.toFile() : null); + request.setUserSettingsFile(context.userSettingsPath != null ? context.userSettingsPath.toFile() : null); + request.setTopDirectory(context.invokerRequest.topDirectory()); if (context.invokerRequest.rootDirectory().isPresent()) { request.setMultiModuleProjectDirectory( diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java index 579f1e5683..5e75e96b6f 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java @@ -171,7 +171,7 @@ public abstract class MavenInvoker<C extends MavenContext> extends LookupInvoker } @Override - protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest) { + protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest) throws Exception { if (context.eventSpyDispatcher != null) { context.eventSpyDispatcher.onEvent(settingsBuilderRequest); } @@ -186,7 +186,6 @@ public abstract class MavenInvoker<C extends MavenContext> extends LookupInvoker protected void toolchains(C context, MavenExecutionRequest request) throws Exception { Path userToolchainsFile = null; - if (context.invokerRequest.options().altUserToolchains().isPresent()) { userToolchainsFile = context.cwdResolver.apply( context.invokerRequest.options().altUserToolchains().get()); @@ -204,7 +203,6 @@ public abstract class MavenInvoker<C extends MavenContext> extends LookupInvoker } Path installationToolchainsFile = null; - if (context.invokerRequest.options().altInstallationToolchains().isPresent()) { installationToolchainsFile = context.cwdResolver.apply( context.invokerRequest.options().altInstallationToolchains().get());