mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Gradle: gradle build file can be used to resolve project info instead of gradle project dir
This commit is contained in:
+12
-2
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.settings.DistributionType;
|
||||
import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -134,19 +135,28 @@ public class GradleExecutionHelper {
|
||||
|
||||
public <T> T execute(@NotNull String projectPath, @Nullable GradleExecutionSettings settings, @NotNull Function<ProjectConnection, T> f) {
|
||||
|
||||
final String projectDir;
|
||||
final File projectPathFile = new File(projectPath);
|
||||
if (projectPathFile.isFile() && projectPath.endsWith(GradleConstants.EXTENSION)
|
||||
&& projectPathFile.getParent() != null) {
|
||||
projectDir = projectPathFile.getParent();
|
||||
} else {
|
||||
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) {
|
||||
try {
|
||||
userDir = System.getProperty("user.dir");
|
||||
System.setProperty("user.dir", projectPath);
|
||||
System.setProperty("user.dir", projectDir);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
ProjectConnection connection = getConnection(projectPath, settings);
|
||||
ProjectConnection connection = getConnection(projectDir, settings);
|
||||
try {
|
||||
return f.fun(connection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user