IDEA-CR-1672: fix support to use build script file(instead of directory) as to run a build

GitOrigin-RevId: e25718efd4608ccac85428657af2a396f2ed1e60
This commit is contained in:
Vladislav.Soroka
2020-06-09 10:35:51 +03:00
committed by intellij-monorepo-bot
parent 571af6bb9c
commit a37c7a545a
@@ -96,21 +96,21 @@ public class GradleExecutionHelper {
@Nullable ExternalSystemTaskNotificationListener listener,
@Nullable CancellationTokenSource cancellationTokenSource,
@NotNull Function<? super ProjectConnection, ? extends T> f) {
String projectDir;
File projectPathFile = new File(projectPath);
if (projectPathFile.isFile() && projectPath.endsWith(GradleConstants.EXTENSION) && projectPathFile.getParent() != null) {
projectDir = projectPathFile.getParent();
}
else {
projectDir = projectPath;
}
CancellationToken cancellationToken = cancellationTokenSource != null ? cancellationTokenSource.token() : null;
return withGradleConnection(
projectPath, taskId, settings, listener, cancellationToken,
projectDir, taskId, settings, listener, cancellationToken,
connection -> {
String userDir = null;
if (!GradleEnvironment.ADJUST_USER_DIR) {
try {
String projectDir;
File projectPathFile = new File(projectPath);
if (projectPathFile.isFile() && projectPath.endsWith(GradleConstants.EXTENSION) && projectPathFile.getParent() != null) {
projectDir = projectPathFile.getParent();
}
else {
projectDir = projectPath;
}
userDir = System.getProperty("user.dir");
if (userDir != null) System.setProperty("user.dir", projectDir);
}