diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/ExtensionConfigurationModule.java b/maven-embedder/src/main/java/org/apache/maven/cli/ExtensionConfigurationModule.java index 3b751d0617..21d9cb2260 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/ExtensionConfigurationModule.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/ExtensionConfigurationModule.java @@ -18,6 +18,8 @@ */ package org.apache.maven.cli; +import java.util.Arrays; + import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.name.Names; @@ -28,17 +30,17 @@ import org.apache.maven.internal.xml.XmlPlexusConfiguration; import org.apache.maven.model.v4.MavenTransformer; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.interpolation.InterpolationException; -import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; import org.codehaus.plexus.interpolation.StringSearchInterpolator; +import org.codehaus.plexus.interpolation.ValueSource; -class ExtensionConfigurationModule implements Module { +public class ExtensionConfigurationModule implements Module { private final CoreExtensionEntry extension; - private final CliRequest cliRequest; + private final Iterable valueSources; - ExtensionConfigurationModule(CoreExtensionEntry extension, CliRequest cliRequest) { + public ExtensionConfigurationModule(CoreExtensionEntry extension, ValueSource... valueSources) { this.extension = extension; - this.cliRequest = cliRequest; + this.valueSources = Arrays.asList(valueSources); } @Override @@ -66,8 +68,7 @@ class ExtensionConfigurationModule implements Module { super(null); interpolator = new StringSearchInterpolator(); interpolator.setCacheAnswers(true); - interpolator.addValueSource(new PropertiesBasedValueSource(cliRequest.userProperties)); - interpolator.addValueSource(new PropertiesBasedValueSource(cliRequest.systemProperties)); + valueSources.forEach(interpolator::addValueSource); } public XmlNode transform(XmlNode node) { 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 a5bd58ab3b..7c620ce5e9 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 @@ -690,12 +690,22 @@ public class MavenCli { container.setLoggerManager(plexusLoggerManager); + AbstractValueSource extensionSource = new AbstractValueSource(false) { + @Override + public Object getValue(String expression) { + Object value = cliRequest.userProperties.getProperty(expression); + if (value == null) { + value = cliRequest.systemProperties.getProperty(expression); + } + return value; + } + }; for (CoreExtensionEntry extension : extensions) { container.discoverComponents( extension.getClassRealm(), new SessionScopeModule(container), new MojoExecutionScopeModule(container), - new ExtensionConfigurationModule(extension, cliRequest)); + new ExtensionConfigurationModule(extension, extensionSource)); } customizeContainer(container);