-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Select suitable JDK to launch Gradle. (#2812)
- When the Gradle Java home preference is not set, and the default JDK is not compatible with the project Gradle, try to find compatible JDK if there is one available. --------- Signed-off-by: Sheng Chen <sheche@microsoft.com>
- Loading branch information
Showing
4 changed files
with
172 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/GradleUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.Test; | ||
|
||
public class GradleUtilsTest { | ||
@Test | ||
public void testGetJdkToLaunchDaemon() { | ||
assertEquals("17", GradleUtils.getMajorJavaVersion("17.0.8")); | ||
assertEquals("1.8", GradleUtils.getMajorJavaVersion("1.8.0_202")); | ||
} | ||
|
||
@Test | ||
public void testGetMajorJavaVersion() { | ||
File javaHome = GradleUtils.getJdkToLaunchDaemon("10"); | ||
assertTrue(javaHome.getAbsolutePath().contains("fakejdk" + File.separator + "10")); | ||
} | ||
} |