IDEA-118062 Gradle Run Configuration: 'working directory' is set incorrectly

This commit is contained in:
Vladislav.Soroka
2014-04-23 17:51:19 +04:00
parent 09333b1ac3
commit 6924cc4eac
4 changed files with 11 additions and 10 deletions
@@ -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);
}
@@ -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<String> classPath = ContainerUtilRt.newArrayList();
// IDE jars.
@@ -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);
@@ -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() {
}