use of org.eclipse.buildship.core.BuildConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporterTest method testGradleJvmArguments.
@Test
public void testGradleJvmArguments() {
List<String> jvmArguments = JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getGradleJvmArguments();
try {
Path rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().toPath();
BuildConfiguration build = GradleProjectImporter.getBuildConfiguration(rootPath);
assertTrue(build.getJvmArguments().isEmpty());
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleJvmArguments(ImmutableList.of("-Djavax.net.ssl.trustStore=truststore.jks"));
build = GradleProjectImporter.getBuildConfiguration(rootPath);
assertEquals(1, build.getJvmArguments().size());
assertTrue(build.getJvmArguments().contains("-Djavax.net.ssl.trustStore=truststore.jks"));
} finally {
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleJvmArguments(jvmArguments);
}
}
use of org.eclipse.buildship.core.BuildConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporterTest method testGradleOfflineMode.
@Test
public void testGradleOfflineMode() {
boolean offlineMode = JavaLanguageServerPlugin.getPreferencesManager().getPreferences().isImportGradleOfflineEnabled();
try {
Path rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().toPath();
BuildConfiguration build = GradleProjectImporter.getBuildConfiguration(rootPath);
assertFalse(build.isOfflineMode());
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setImportGradleOfflineEnabled(true);
build = GradleProjectImporter.getBuildConfiguration(rootPath);
assertTrue(build.isOfflineMode());
} finally {
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setImportGradleOfflineEnabled(offlineMode);
}
}
use of org.eclipse.buildship.core.BuildConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporterTest method testGradleArguments.
@Test
public void testGradleArguments() {
List<String> arguments = JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getGradleArguments();
try {
Path rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().toPath();
BuildConfiguration build = GradleProjectImporter.getBuildConfiguration(rootPath);
assertTrue(build.getArguments().isEmpty());
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleArguments(ImmutableList.of("-Pproperty=value", "--stacktrace"));
build = GradleProjectImporter.getBuildConfiguration(rootPath);
assertEquals(2, build.getArguments().size());
assertTrue(build.getArguments().contains("-Pproperty=value"));
assertTrue(build.getArguments().contains("--stacktrace"));
} finally {
JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setGradleArguments(arguments);
}
}
use of org.eclipse.buildship.core.BuildConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleProjectImporter method getBuildConfiguration.
public static BuildConfiguration getBuildConfiguration(Path rootFolder) {
GradleDistribution distribution = getGradleDistribution(rootFolder);
Preferences preferences = getPreferences();
File javaHome = getJavaHome(preferences);
File gradleUserHome = getGradleUserHomeFile();
List<String> gradleArguments = preferences.getGradleArguments();
List<String> gradleJvmArguments = preferences.getGradleJvmArguments();
boolean offlineMode = preferences.isImportGradleOfflineEnabled();
boolean overrideWorkspaceConfiguration = !(distribution instanceof WrapperGradleDistribution) || offlineMode || (gradleArguments != null && !gradleArguments.isEmpty()) || (gradleJvmArguments != null && !gradleJvmArguments.isEmpty()) || gradleUserHome != null || javaHome != null;
// @formatter:off
BuildConfiguration build = BuildConfiguration.forRootProjectDirectory(rootFolder.toFile()).overrideWorkspaceConfiguration(overrideWorkspaceConfiguration).gradleDistribution(distribution).javaHome(javaHome).arguments(gradleArguments).gradleUserHome(gradleUserHome).jvmArguments(gradleJvmArguments).offlineMode(offlineMode).build();
// @formatter:on
return build;
}
use of org.eclipse.buildship.core.BuildConfiguration in project eclipse.jdt.ls by eclipse.
the class GradleBuildSupport method update.
@Override
public void update(IProject project, boolean force, IProgressMonitor monitor) throws CoreException {
if (!applies(project)) {
return;
}
JavaLanguageServerPlugin.logInfo("Starting Gradle update for " + project.getName());
Optional<GradleBuild> build = GradleCore.getWorkspace().getBuild(project);
if (build.isPresent()) {
GradleBuild gradleBuild = build.get();
boolean isRoot = isRoot(project, gradleBuild, monitor);
if (force && isRoot) {
String projectPath = project.getLocation().toFile().getAbsolutePath();
BuildConfiguration buildConfiguration = GradleProjectImporter.getBuildConfiguration(Paths.get(projectPath));
gradleBuild = GradleCore.getWorkspace().createBuild(buildConfiguration);
}
File buildFile = project.getFile(GradleProjectImporter.BUILD_GRADLE_DESCRIPTOR).getLocation().toFile();
File settingsFile = project.getFile(GradleProjectImporter.SETTINGS_GRADLE_DESCRIPTOR).getLocation().toFile();
File buildKtsFile = project.getFile(GradleProjectImporter.BUILD_GRADLE_KTS_DESCRIPTOR).getLocation().toFile();
File settingsKtsFile = project.getFile(GradleProjectImporter.SETTINGS_GRADLE_KTS_DESCRIPTOR).getLocation().toFile();
boolean shouldUpdate = (buildFile.exists() && JavaLanguageServerPlugin.getDigestStore().updateDigest(buildFile.toPath())) || (settingsFile.exists() && JavaLanguageServerPlugin.getDigestStore().updateDigest(settingsFile.toPath())) || (buildKtsFile.exists() && JavaLanguageServerPlugin.getDigestStore().updateDigest(buildKtsFile.toPath())) || (settingsKtsFile.exists() && JavaLanguageServerPlugin.getDigestStore().updateDigest(settingsKtsFile.toPath()));
if (isRoot || shouldUpdate) {
gradleBuild.synchronize(monitor);
}
}
}
Aggregations