use of org.eclipse.buildship.core.internal.configuration.ProjectConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporterTest method testSubprojects.
@Test
public void testSubprojects() throws Exception {
List<String> arguments = JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getGradleArguments();
try {
// force overrideWorkspace
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleArguments(ImmutableList.of("--stacktrace"));
List<IProject> projects = importProjects("gradle/subprojects");
// default + 3 gradle projects
assertEquals(4, projects.size());
IProject root = WorkspaceHelper.getProject("subprojects");
assertIsGradleProject(root);
IProject project1 = WorkspaceHelper.getProject("project1");
assertIsGradleProject(project1);
IProject project2 = WorkspaceHelper.getProject("project2");
assertIsGradleProject(project2);
projectsManager.updateProject(root, true);
projectsManager.updateProject(project1, true);
projectsManager.updateProject(project2, true);
waitForBackgroundJobs();
ProjectConfiguration configuration = getProjectConfiguration(root);
// check the children .settings/org.eclipse.buildship.core.prefs
assertTrue(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
configuration = getProjectConfiguration(project1);
assertFalse(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
configuration = getProjectConfiguration(project2);
assertFalse(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleArguments(ImmutableList.of("--stacktrace"));
configuration = CorePlugin.configurationManager().loadProjectConfiguration(project1);
assertTrue(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
configuration = CorePlugin.configurationManager().loadProjectConfiguration(project2);
assertTrue(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleArguments(arguments);
projectsManager.updateProject(root, true);
JobHelpers.waitForJobsToComplete();
Job.getJobManager().join(CorePlugin.GRADLE_JOB_FAMILY, new NullProgressMonitor());
configuration = CorePlugin.configurationManager().loadProjectConfiguration(root);
assertFalse(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
// check that the children are updated
configuration = CorePlugin.configurationManager().loadProjectConfiguration(project1);
assertFalse(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
configuration = CorePlugin.configurationManager().loadProjectConfiguration(project2);
assertFalse(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
} finally {
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleArguments(arguments);
}
}
use of org.eclipse.buildship.core.internal.configuration.ProjectConfiguration in project eclipse.jdt.ls by eclipse.
the class GradlePreferenceChangeListener method updateProject.
private void updateProject(ProjectsManager projectsManager, IProject project, boolean gradleJavaHomeChanged) {
String projectDir = project.getLocation().toFile().getAbsolutePath();
Path projectPath = Paths.get(projectDir);
if (gradleJavaHomeChanged || Files.exists(projectPath.resolve("gradlew"))) {
ProjectConfiguration configuration = CorePlugin.configurationManager().loadProjectConfiguration(project);
GradleDistribution distribution = configuration.getBuildConfiguration().getGradleDistribution();
if (gradleJavaHomeChanged || !(distribution instanceof WrapperGradleDistribution)) {
projectsManager.updateProject(project, true);
} else {
try {
ValidationResult result = new WrapperValidator().checkWrapper(projectDir);
if (!result.isValid()) {
projectsManager.updateProject(project, true);
}
} catch (CoreException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
}
}
}
use of org.eclipse.buildship.core.internal.configuration.ProjectConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporterTest method testGradleUserHome.
@Test
public void testGradleUserHome() throws Exception {
String gradleUserHomePreference = JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getGradleUserHome();
File gradleUserHome = null;
try {
gradleUserHome = Files.createTempDir();
gradleUserHome.deleteOnExit();
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleUserHome(gradleUserHome.getAbsolutePath());
List<IProject> projects = importProjects("gradle/simple-gradle");
// default + 1 eclipse projects
assertEquals(2, projects.size());
IProject project = WorkspaceHelper.getProject("simple-gradle");
assertNotNull(project);
assertTrue(project.getName() + " does not have the Gradle nature", ProjectUtils.isGradleProject(project));
assertTrue(gradleUserHome.exists());
ProjectConfiguration projectConfiguration = CorePlugin.configurationManager().loadProjectConfiguration(project);
assertEquals(gradleUserHome, projectConfiguration.getBuildConfiguration().getGradleUserHome());
} finally {
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleUserHome(gradleUserHomePreference);
}
}
Aggregations