You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/04/21 18:17:40 UTC
[maven-shared-utils] branch addsystem-public created (now 3669e0b)
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a change to branch addsystem-public
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
at 3669e0b [MSHARED-1014] Make Commandline.addSystemEnvironment public and deprecated
This branch includes the following new commits:
new 3669e0b [MSHARED-1014] Make Commandline.addSystemEnvironment public and deprecated
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-shared-utils] 01/01: [MSHARED-1014] Make Commandline.addSystemEnvironment public and deprecated
Posted by sj...@apache.org.
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 <s....@gmail.com>
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;