This is an automated email from the ASF dual-hosted git repository. sjaranowski pushed a commit to branch addsystem-public in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
commit 3669e0ba5c21e844a5f8915a1e40b4b70cecc29b Author: Slawomir Jaranowski <[email protected]> AuthorDate: Fri Apr 21 20:17:08 2023 +0200 [MSHARED-1014] Make Commandline.addSystemEnvironment public and deprecated MavenInvoker still use it. --- .../apache/maven/shared/utils/cli/Commandline.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java b/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java index 4f93957..46dc839 100644 --- a/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java +++ b/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java @@ -183,8 +183,13 @@ public class Commandline implements Cloneable { /** * Add system environment variables. + * + * @deprecated please use {@link #setShellEnvironmentInherited(boolean)} */ - private void addSystemEnvironment() { + @Deprecated + public void addSystemEnvironment() {} + + private void copySystemEnvironment() { Properties systemEnvVars = CommandLineUtils.getSystemEnvVars(); for (Object o : systemEnvVars.keySet()) { @@ -202,7 +207,7 @@ public class Commandline implements Cloneable { */ public String[] getEnvironmentVariables() { if (isShellEnvironmentInherited()) { - addSystemEnvironment(); + copySystemEnvironment(); } List<String> environmentVars = new ArrayList<>(); @@ -243,7 +248,7 @@ public class Commandline implements Cloneable { /** * @param mask flag to mask any arguments (having his {@code mask} field to {@code true}) * @return the shell, executable and all defined arguments with masking some arguments if - * {@code mask} parameter is on + * {@code mask} parameter is on */ private String[] getShellCommandline(boolean mask) { List<String> shellCommandLine = getShell().getShellCommandLine(getArguments(mask)); @@ -253,6 +258,7 @@ public class Commandline implements Cloneable { /** * Returns all arguments defined by <code>addLine</code>, * <code>addValue</code> or the argument object. + * * @return an array of arguments. */ public String[] getArguments() { @@ -289,13 +295,15 @@ public class Commandline implements Cloneable { return result.toArray(new String[result.size()]); } - /** {@inheritDoc} + /** + * {@inheritDoc} */ public String toString() { return StringUtils.join(getShellCommandline(true), " "); } - /** {@inheritDoc} + /** + * {@inheritDoc} */ public Object clone() { throw new RuntimeException("Do we ever clone a commandline?"); @@ -351,7 +359,7 @@ public class Commandline implements Cloneable { * Specifies whether the environment variables of the current process should be propagated to the executing Command. * * @param shellEnvironmentInherited <code>true</code> if the environment variables should be propagated, - * <code>false</code> otherwise. + * <code>false</code> otherwise. */ public void setShellEnvironmentInherited(boolean shellEnvironmentInherited) { this.shellEnvironmentInherited = shellEnvironmentInherited;
