Skip to content

Commit

Permalink
Fix Gradle tests started with Java 23
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza authored and rgrunber committed Aug 13, 2024
1 parent ebd30cd commit 0fc400f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.Map.Entry;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -218,7 +218,7 @@ private static File getGradleInitScriptTempFile(String scriptPath) {
* <ul>
* @param initScript the init script file.
* @param checksum the expected checksum of the file.
*
*
* @throws IOException
* @throws NoSuchAlgorithmException
*/
Expand Down Expand Up @@ -260,7 +260,7 @@ public static Map<String, String> parseProcessorOptions(List<Object> compilerArg
return Collections.emptyMap();
}
Map<String, String> options = new HashMap<>();

for(Object arg : compilerArgs) {
String argString = String.valueOf(arg);
if (argString.startsWith("-A")) {
Expand Down Expand Up @@ -338,11 +338,12 @@ public static File getJdkToLaunchDaemon(String highestJavaVersion) {
* The results are returned as map, where key is the major version and value is the file instance of
* the installation.
*/
private static Map<String, File> getAllVmInstalls() {
public static Map<String, File> getAllVmInstalls() {
List<IVMInstall> vmList = Stream.of(JavaRuntime.getVMInstallTypes())
.map(IVMInstallType::getVMInstalls)
.flatMap(Arrays::stream)
.toList();
// https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/issues/609
.filter(t -> (t.getName() != null && !t.getName().startsWith("TestVMInstall-")))
.map(IVMInstallType::getVMInstalls)
.flatMap(Arrays::stream).toList();
Map<String, File> vmInstalls = new HashMap<>();
for (IVMInstall vmInstall : vmList) {
if (vmInstall instanceof AbstractVMInstall vm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ plugins {
}

repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.Map;

import org.junit.Test;

Expand All @@ -28,7 +29,10 @@ public void testGetJdkToLaunchDaemon() {

@Test
public void testGetMajorJavaVersion() {
File javaHome = GradleUtils.getJdkToLaunchDaemon("10");
assertTrue("javaHome=" + javaHome.getAbsolutePath(), javaHome.getAbsolutePath().contains("fakejdk" + File.separator + "10"));
Map<String, File> vmInstalls = GradleUtils.getAllVmInstalls();
vmInstalls.forEach((k, v) -> {
File javaHome = GradleUtils.getJdkToLaunchDaemon(k);
assertTrue("javaHome=" + javaHome.getAbsolutePath(), javaHome.equals(v));
});
}
}

0 comments on commit 0fc400f

Please sign in to comment.