void ( @NotNull LongRunningOperation operation, @NotNull GradleExecutionSettings settings, @NotNull ExternalSystemTaskId taskId, @NotNull ExternalSystemTaskNotificationListener listener, @Nullable BuildEnvironment buildEnvironment ) { String gradleVersion = buildEnvironment != null ? buildEnvironment.getGradle().getGradleVersion() : null; boolean isEnvironmentCustomizationSupported = gradleVersion != null && GradleVersion.version(gradleVersion).getBaseVersion().compareTo(GradleVersion.version("3.5")) >= 0; if (!isEnvironmentCustomizationSupported) { if (!settings.isPassParentEnvs() || !settings.getEnv().isEmpty()) { listener.onTaskOutput(taskId, String.format( "The version of Gradle you are using%s does not support the environment variables customization feature. " + "Support for this is available in Gradle 3.5 and all later versions.\n", gradleVersion == null ? "" : (" (" + gradleVersion + ")")), false); } return; } TargetEnvironmentConfigurationProvider environmentConfigurationProvider = ExternalSystemExecutionAware.Companion.getEnvironmentConfigurationProvider(settings); TargetEnvironmentConfiguration environmentConfiguration = environmentConfigurationProvider != null ? environmentConfigurationProvider.getEnvironmentConfiguration() : null; if (environmentConfiguration != null && !LocalGradleExecutionAware.LOCAL_TARGET_TYPE_ID.equals(environmentConfiguration.getTypeId())) { if (settings.isPassParentEnvs()) { LOG.warn("Host system environment variables will not be passed for the target run."); } operation.setEnvironmentVariables(settings.getEnv()); return; } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.withEnvironment(settings.getEnv()); commandLine.withParentEnvironmentType( settings.isPassParentEnvs() ? GeneralCommandLine.ParentEnvironmentType.CONSOLE : GeneralCommandLine.ParentEnvironmentType.NONE); Map<String, String> effectiveEnvironment = commandLine.getEffectiveEnvironment(); operation.setEnvironmentVariables(effectiveEnvironment); }