diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java index 83a010b03620..ae3e75fcf678 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java @@ -186,7 +186,7 @@ public class ExternalSystemFacadeManager { @NotNull private RemoteExternalSystemFacade doCreateFacade(@NotNull IntegrationKey key, @NotNull Project project, @NotNull ExternalSystemCommunicationManager communicationManager) throws Exception { - final RemoteExternalSystemFacade facade = communicationManager.acquire(project.getName(), key.getExternalSystemId()); + final RemoteExternalSystemFacade facade = communicationManager.acquire(key.getExternalProjectConfigPath(), key.getExternalSystemId()); if (facade == null) { throw new IllegalStateException("Can't obtain facade to working with external api at the remote process. Project: " + project); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java index b8ad4f16b932..2cc4b2eb5cca 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemCommunicationManager.java @@ -60,6 +60,7 @@ import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.File; import java.nio.charset.Charset; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; @@ -99,7 +100,7 @@ public class RemoteExternalSystemCommunicationManager implements ExternalSystemC @Override protected RunProfileState getRunProfileState(Object o, String configuration, Executor executor) throws ExecutionException { - return createRunProfileState(); + return createRunProfileState(configuration); } }; @@ -114,14 +115,15 @@ public class RemoteExternalSystemCommunicationManager implements ExternalSystemC mySupport.stopAll(wait); } - private RunProfileState createRunProfileState() { + private RunProfileState createRunProfileState(final String configuration) { return new CommandLineState(null) { private SimpleJavaParameters createJavaParameters() throws ExecutionException { final SimpleJavaParameters params = new SimpleJavaParameters(); params.setJdk(new SimpleJavaSdkType().createJdk("tmp", SystemProperties.getJavaHome())); - params.setWorkingDirectory(PathManager.getBinPath()); + File myWorkingDirectory = new File(configuration); + params.setWorkingDirectory(myWorkingDirectory.isDirectory() ? myWorkingDirectory.getPath() : PathManager.getBinPath()); final List classPath = ContainerUtilRt.newArrayList(); // IDE jars. diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java index bf5179c220d6..3a761b550192 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java @@ -39,6 +39,7 @@ import org.jetbrains.plugins.gradle.settings.DistributionType; import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings; import org.jetbrains.plugins.gradle.tooling.internal.init.Init; import org.jetbrains.plugins.gradle.util.GradleConstants; +import org.jetbrains.plugins.gradle.util.GradleEnvironment; import org.jetbrains.plugins.gradle.util.GradleUtil; import java.io.File; @@ -188,16 +189,13 @@ public class GradleExecutionHelper { projectDir = projectPath; } - // This is a workaround to get right base dir in case of 'PROJECT' setting used in case custom wrapper property file location - // see org.gradle.wrapper.PathAssembler#getBaseDir for details String userDir = null; - if (settings != null && settings.getDistributionType() == DistributionType.WRAPPED) { + if (!GradleEnvironment.ADJUST_USER_DIR) { try { userDir = System.getProperty("user.dir"); - System.setProperty("user.dir", projectDir); + if (userDir != null) System.setProperty("user.dir", projectDir); } - catch (Exception e) { - // ignore + catch (Exception ignore) { } } ProjectConnection connection = getConnection(projectDir, settings); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java index cdd8afb782e8..2c61ac6c10eb 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java @@ -11,6 +11,7 @@ public class GradleEnvironment { @NonNls public static final boolean DEBUG_GRADLE_HOME_PROCESSING = Boolean.getBoolean("gradle.debug.home.processing"); @NonNls public static final boolean DISABLE_ENHANCED_TOOLING_API = Boolean.getBoolean("gradle.disable.enhanced.tooling.api"); + @NonNls public static final boolean ADJUST_USER_DIR = Boolean.getBoolean("gradle.adjust.userdir"); private GradleEnvironment() { }