use of org.eclipse.buildship.core.SynchronizationResult in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporter method startSynchronization.
protected IStatus startSynchronization(Path projectFolder, IProgressMonitor monitor) {
File location = projectFolder.toFile();
boolean shouldSynchronize = shouldSynchronize(location);
if (shouldSynchronize) {
BuildConfiguration build = getBuildConfiguration(projectFolder);
GradleBuild gradleBuild = GradleCore.getWorkspace().createBuild(build);
SynchronizationResult result = gradleBuild.synchronize(monitor);
IStatus resultStatus = result.getStatus();
if (isFailedStatus(resultStatus)) {
try {
BuildEnvironment environment = gradleBuild.withConnection(connection -> connection.getModel(BuildEnvironment.class), monitor);
GradleEnvironment gradleEnvironment = environment.getGradle();
String gradleVersion = gradleEnvironment.getGradleVersion();
File javaHome = getJavaHome(getPreferences());
String javaVersion;
if (javaHome == null) {
javaVersion = System.getProperty("java.version");
} else {
StandardVMType type = new StandardVMType();
javaVersion = type.readReleaseVersion(javaHome);
}
if (GradleCompatibilityChecker.isIncompatible(GradleVersion.version(gradleVersion), javaVersion)) {
Path projectName = projectFolder.getName(projectFolder.getNameCount() - 1);
String message = String.format("Can't use Java %s and Gradle %s to import Gradle project %s.", javaVersion, gradleVersion, projectName.toString());
String highestJavaVersion = GradleCompatibilityChecker.getHighestSupportedJava(GradleVersion.version(gradleVersion));
return new GradleCompatibilityStatus(resultStatus, message, projectFolder.toUri().toString(), highestJavaVersion);
}
} catch (Exception e) {
// Do nothing
}
}
return resultStatus;
}
return Status.OK_STATUS;
}
Aggregations