Skip to content

Commit

Permalink
Enable m2e toolchains.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza committed Aug 14, 2024
1 parent 949a9a2 commit 55f31a8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,10 @@ public static BuildConfiguration getBuildConfiguration(Path rootFolder, boolean
File javaHome = getJavaHome(preferences);
File gradleUserHome = getGradleUserHomeFile();
List<String> gradleArguments = new ArrayList<>();
if (noDaemon) {
gradleArguments.add("--no-daemon");
}
// https://github.com/microsoft/vscode-gradle/issues/1519
//if (noDaemon) {
// gradleArguments.add("--no-daemon");
//}
gradleArguments.addAll(getGradleInitScriptArgs());
gradleArguments.addAll(preferences.getGradleArguments());
List<String> gradleJvmArguments = preferences.getGradleJvmArguments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public static File getJdkToLaunchDaemon(String highestJavaVersion) {
return null;
}

Map<String, File> jdks = getAllVmInstalls();;
Map<String, File> jdks = getAllVmInstalls();
Entry<String, File> selected = null;
for (Entry<String, File> jdk : jdks.entrySet()) {
String javaVersion = jdk.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal;

import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logException;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.m2e.jdt.MavenJdtPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

/**
* @author snjeza
Expand All @@ -38,8 +43,20 @@ public class JavaLanguageServerTestPlugin implements BundleActivator {
*/
@Override
public void start(BundleContext context) throws Exception {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(MavenJdtPlugin.PLUGIN_ID);
prefs.put(PREFERENCE_LOOKUP_JVM_IN_TOOLCHAINS, Boolean.FALSE.toString());
// https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3238
if ("false".equals(System.getProperty(PREFERENCE_LOOKUP_JVM_IN_TOOLCHAINS, "true"))) {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(MavenJdtPlugin.PLUGIN_ID);
prefs.put(PREFERENCE_LOOKUP_JVM_IN_TOOLCHAINS, Boolean.FALSE.toString());
}
try {
long start = System.currentTimeMillis();
String symbolicName = MavenJdtPlugin.PLUGIN_ID;
JavaLanguageServerPlugin.debugTrace("Starting " + symbolicName);
Platform.getBundle(symbolicName).start(Bundle.START_TRANSIENT);
JavaLanguageServerPlugin.logInfo("Started " + symbolicName + " " + (System.currentTimeMillis() - start) + "ms");
} catch (BundleException e) {
logException(e.getMessage(), e);
}
TestVMType.setTestJREAsDefault("17");
JavaCore.initializeAfterLoad(new NullProgressMonitor());
IWorkspace workspace = ResourcesPlugin.getWorkspace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
import org.eclipse.jdt.ls.core.internal.preferences.Preferences;
import org.eclipse.jdt.ls.core.internal.preferences.StandardPreferenceManager;
import org.eclipse.m2e.jdt.LookupJDKToolchainsJob;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.mockito.Mock;
import org.mockito.Mockito;

Expand Down Expand Up @@ -132,6 +134,22 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
}
});

@BeforeClass
public static void initJVMs() {
Job[] jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
if (job instanceof LookupJDKToolchainsJob) {
try {
// 10 minutes
job.join(600000, new NullProgressMonitor());
} catch (OperationCanceledException | InterruptedException e) {
JavaLanguageServerPlugin.logException(e);
}
}
}
CorePlugin.publishedGradleVersions().getVersions();
}

@Before
public void initProjectManager() throws Exception {
clientRequests.clear();
Expand Down

0 comments on commit 55f31a8

Please sign in to comment.