diff --git a/CHANGELOG.md b/CHANGELOG.md index f12b3b8..fab9d49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning]. +## Unreleased + +### Fixed + +- Substitute parent process env vars in IDEA - wasn't working before ([#81]) + ## 3.1.0 - 2018-11-28 ### Added @@ -92,7 +98,8 @@ This project adheres to [Semantic Versioning]. [#68]: https://github.com/Ashald/EnvFile/issues/68 [#70]: https://github.com/Ashald/EnvFile/issues/70 [#72]: https://github.com/Ashald/EnvFile/issues/72 +[#81]: https://github.com/Ashald/EnvFile/issues/81 [Keep a CHANGELOG]: http://keepachangelog.com [Semantic Versioning]: http://semver.org/ -[StringSubstitutor]: https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/StringSubstitutor.html \ No newline at end of file +[StringSubstitutor]: https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/StringSubstitutor.html diff --git a/modules/core/src/main/java/net/ashald/envfile/AbstractEnvVarsProvider.java b/modules/core/src/main/java/net/ashald/envfile/AbstractEnvVarsProvider.java index 026eee5..5fa5b01 100644 --- a/modules/core/src/main/java/net/ashald/envfile/AbstractEnvVarsProvider.java +++ b/modules/core/src/main/java/net/ashald/envfile/AbstractEnvVarsProvider.java @@ -3,6 +3,7 @@ import org.apache.commons.text.StringSubstitutor; import org.jetbrains.annotations.NotNull; +import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -47,4 +48,9 @@ private String renderValue(String template, @NotNull Map context return stage2; } + + @Override + public boolean isFileLocationValid(File file) { + return file != null && file.exists(); + } } diff --git a/modules/core/src/main/java/net/ashald/envfile/EnvVarsProvider.java b/modules/core/src/main/java/net/ashald/envfile/EnvVarsProvider.java index 4db710d..fb73035 100644 --- a/modules/core/src/main/java/net/ashald/envfile/EnvVarsProvider.java +++ b/modules/core/src/main/java/net/ashald/envfile/EnvVarsProvider.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; +import java.io.File; import java.io.IOException; import java.util.Map; @@ -11,4 +12,6 @@ public interface EnvVarsProvider { @NotNull Map process(@NotNull Map runConfigEnv, String path, @NotNull Map aggregatedEnv) throws EnvFileErrorException, IOException; boolean isEditable(); + + boolean isFileLocationValid(File file); } diff --git a/modules/core/src/main/java/net/ashald/envfile/providers/runconfig/RunConfigEnvVarsProvider.java b/modules/core/src/main/java/net/ashald/envfile/providers/runconfig/RunConfigEnvVarsProvider.java index 2c8503a..f9e2245 100644 --- a/modules/core/src/main/java/net/ashald/envfile/providers/runconfig/RunConfigEnvVarsProvider.java +++ b/modules/core/src/main/java/net/ashald/envfile/providers/runconfig/RunConfigEnvVarsProvider.java @@ -3,6 +3,7 @@ import net.ashald.envfile.AbstractEnvVarsProvider; import org.jetbrains.annotations.NotNull; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,4 +24,8 @@ public boolean isEditable() { return false; } + @Override + public boolean isFileLocationValid(File file) { + return true; // no file needed + } } diff --git a/modules/platform/src/main/java/net/ashald/envfile/platform/EnvFileEntry.java b/modules/platform/src/main/java/net/ashald/envfile/platform/EnvFileEntry.java index c7f6bbb..7d99e84 100644 --- a/modules/platform/src/main/java/net/ashald/envfile/platform/EnvFileEntry.java +++ b/modules/platform/src/main/java/net/ashald/envfile/platform/EnvFileEntry.java @@ -72,7 +72,7 @@ public Map process(Map runConfigEnv, Map void updateJavaParameters(T configuration, JavaParameters params, RunnerSettings runnerSettings) throws ExecutionException { - Map newEnv = EnvFileConfigurationEditor.collectEnv(configuration, new HashMap<>(params.getEnv())); + // Borrowed from com.intellij.openapi.projectRoots.JdkUtil + Map sourceEnv = new GeneralCommandLine() + .withEnvironment(params.getEnv()) + .withParentEnvironmentType( + params.isPassParentEnvs() ? GeneralCommandLine.ParentEnvironmentType.CONSOLE : GeneralCommandLine.ParentEnvironmentType.NONE + ) + .getEffectiveEnvironment(); + + Map newEnv = EnvFileConfigurationEditor.collectEnv(configuration, new HashMap<>(sourceEnv)); // there is a chance that env is an immutable map, // that is why it is safer to replace it instead of updating it params.setEnv(newEnv);