forked from devonfw/IDEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…nfw#810: setup in current shell devonfw#782: fix IDE_ROOT on linux/mac devonfw#774: fixed HTTP proxy support (devonfw#811)
- Loading branch information
Showing
24 changed files
with
754 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
cli/src/main/java/com/devonfw/tools/ide/environment/IdeSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.devonfw.tools.ide.environment; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Interface to abstract from {@link System}. | ||
*/ | ||
public interface IdeSystem { | ||
|
||
/** | ||
* @param key the name of the requested system property. | ||
* @return the {@link System#getProperty(String) value} of the requested system property. | ||
* @see System#getProperty(String) | ||
*/ | ||
String getProperty(String key); | ||
|
||
/** | ||
* @param key the name of the requested system property. | ||
* @param fallback the value to return as default in case the requested system property is undefined. | ||
* @return the {@link System#getProperty(String, String) value} of the requested system property. | ||
* @see System#getProperty(String, String) | ||
*/ | ||
String getProperty(String key, String fallback); | ||
|
||
/** | ||
* @param key the name of the system property to set. | ||
* @param value the new value to {@link System#setProperty(String, String) set}. | ||
* @see System#setProperty(String, String) | ||
*/ | ||
void setProperty(String key, String value); | ||
|
||
/** | ||
* @param key the name of the requested environment variable. | ||
* @return the {@link System#getenv(String) value} of the requested environment variable. | ||
* @see System#getenv(String) | ||
*/ | ||
String getEnv(String key); | ||
|
||
/** | ||
* @return the {@link System#getenv() environment variables}. | ||
*/ | ||
Map<String, String> getEnv(); | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
cli/src/main/java/com/devonfw/tools/ide/environment/IdeSystemImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.devonfw.tools.ide.environment; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
|
||
import com.devonfw.tools.ide.log.IdeLogger; | ||
|
||
/** | ||
* Implementation of {@link IdeSystem}. | ||
*/ | ||
public class IdeSystemImpl implements IdeSystem { | ||
|
||
private final IdeLogger logger; | ||
|
||
final Properties systemProperties; | ||
|
||
final Map<String, String> environmentVariables; | ||
|
||
/** | ||
* @param logger the {@link IdeLogger}. | ||
*/ | ||
public IdeSystemImpl(IdeLogger logger) { | ||
|
||
this(logger, System.getProperties(), System.getenv()); | ||
} | ||
|
||
/** | ||
* @param logger the {@link IdeLogger}. | ||
* @param systemProperties the {@link System#getProperties() system properties}. | ||
* @param environmentVariables the {@link System#getenv() environment variables}. | ||
*/ | ||
protected IdeSystemImpl(IdeLogger logger, Properties systemProperties, Map<String, String> environmentVariables) { | ||
|
||
super(); | ||
this.logger = logger; | ||
this.systemProperties = systemProperties; | ||
this.environmentVariables = environmentVariables; | ||
} | ||
|
||
@Override | ||
public String getProperty(String key) { | ||
|
||
return this.systemProperties.getProperty(key); | ||
} | ||
|
||
@Override | ||
public String getProperty(String key, String fallback) { | ||
|
||
return this.systemProperties.getProperty(key, fallback); | ||
} | ||
|
||
@Override | ||
public void setProperty(String key, String value) { | ||
|
||
String old = getProperty(key); | ||
if (Objects.equals(old, value)) { | ||
this.logger.trace("System property was already set to {}={}", key, value); | ||
} else { | ||
this.systemProperties.put(key, value); | ||
if (old == null) { | ||
this.logger.trace("System property was set to {}={}", key, value); | ||
} else { | ||
this.logger.trace("System property was changed to {}={} from {}", key, value, old); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public String getEnv(String key) { | ||
|
||
return this.environmentVariables.get(key); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getEnv() { | ||
|
||
return this.environmentVariables; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.