Error while building a Gradle project with Java 21 using the Buildship 3.1.9 plugin

We are using latest org.eclipse.buildship.core plugin (3.1.9) in our custom Eclipse plugin code. Using this Eclipse plugin, we are creating gradle-based projects using JDK 21. Additionally, while creating projects, we are internally building gradle projects using this GradleCore.getWorkspace().createBuild( code. But we observed that when we are creating projects using our eclipse plugin, Buildship internally downloads the 8.1.1 Gradle version and tries to build using it. So because of this, the following error is occurring.

FAILURE: Build failed with an exception.
* What went wrong:
Could not open cp_init generic class cache for initialization script 'C:\workstation\workspace\PR-307\tw-eclipse-ide\com.thingworx.eclipse.extension.test\target\work\data\.metadata\.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle' (C:\Users\rshah\.gradle\caches\8.1.1\scripts\2to4is5l87jn9v7vrcgka57e).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65

I checked the gradle compatibility page where they mentioned that the 8.1.1 version of gradle is not compatible with JDK 21. So is there any recent plan to release 3.1.10 Buidlship version, which has the latest Gradle version and supports the JDK 21 version? What is the expected release date for the 3.1.10 version? Until then, do you have any alternative solutions to resolve this issue?

I think you need to configure builder to use a compatible distribution.
Something like builder.gradleDistribution(GradleDistribution.forVersion("8.7")).build().

1 Like

@Vampire I used that but still giving same error.
Do you know what is expected date for release 3.1.10 buildship plugin?

I have no idea, I would for the life of me never use Eclipse and thus also have no real idea about anything Buildship related, sorry.

@Vampire Ohkk. Thanks for your help!! :slight_smile:

@oleosterhagen Can you please guide me on this issue.

The configuration of the Gradle distribution with the builder is the right way as suggested by @Vampire.

For this to work, overrideWorkspaceConfiguration(true) has to be invoked on the builder. Otherwise the build configuration will be taken from the Eclipse Preferences and the configured properties on the builder will be ignored (see DefaultBuildConfiguration.getGradleDistribution()).

BuildConfigurationBuilder builder = BuildConfiguration.forRootProjectDirectory(new File("/home/ole/data/workspace/demo"));
// Download and cache a specific Gradle version...

// ... or download and cache a specified remote distribution...
// builder.gradleDistribution(GradleDistribution.forRemoteDistribution(URI.create("")));
// ...or use an already installed Gradle distribution
// builder.gradleDistribution(GradleDistribution.forLocalInstallation(new File("/home/ole/gradle-8.7")));
// Without this, "Gradle distribution" and other properties will be read from Window > Preferences > Gradle

GradleBuild build = GradleCore.getWorkspace().createBuild(;
1 Like