Could not execute build using connection

Hello everyone,

JDK: 21.0.7+6 (Adoptium)
Gradle: 8.9 (included with Eclipse 2025-03 with latest updates) and 8.14
OS: Windows 11 (AV exclusion enabled for entire D: drive where eclipse, JDK, and gradle resides)

When I enable the war plugin for one of my subprojects, I get this error below:

Could not execute build using connection to Gradle installation 'D:\Dev\gradle\gradle-8.14'.
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:erm_war:eclipseWtpComponent` of type `org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.14/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

See the complete report at file:///D:/Dev/_projects_/java/erm/build/reports/configuration-cache/20y5eo1eqi4qrdmt6xj5i2c8u/8lsk9nbs6vmw2j4qpsw7o1g4z/configuration-cache-report.html

I tried deleting both eclipse, gradle, and project caches without success. Please help.

Project files (unable to upload as new user):
(7z 48kb) https://drive.google.com/file/d/1kl0lFvEa0X9p97sXMc2ObQASi9ysz5wo/view?usp=drive_link
(zip 68kb) https://drive.google.com/file/d/1L-XFoavtbpKRYp2xmYgbx5QDanZZtQRt/view?usp=drive_link

As you can see on Configuration Cache even with 8.14 the eclipse and idea plugins are not CC compatible yet.

But that doesn’t make sense because this works:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java library project to get you started.
 * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.9/userguide/building_java_projects.html in the Gradle documentation.
 */

plugins {
    // Apply the java-library plugin for API and implementation separation.
    `java-library`
    `war`
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation(libs.junit.jupiter)

    testRuntimeOnly("org.junit.platform:junit-platform-launcher")

    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api(libs.commons.math3)

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation(libs.guava)
}

// Apply a specific Java toolchain to ease working on different environments.
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}

Gradle refresh results:

> Task :nothing UP-TO-DATE

BUILD SUCCESSFUL in 9s
Working Directory: D:\Dev\_projects_\java\test_gradle_war
Gradle user home: C:\Users\tommy\.gradle
Gradle Distribution: Local installation at D:\Dev\gradle\gradle-8.14
Gradle Version: 8.14
Java Home: D:\jdk\OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
> Task :lib:cleanEclipseWtpComponent
> Task :lib:cleanEclipseWtpFacet
> Task :lib:cleanEclipseWtp UP-TO-DATE
> Task :lib:eclipseWtpComponent
> Task :lib:eclipseWtpFacet
> Task :lib:eclipseWtp

BUILD SUCCESSFUL in 207ms
5 actionable tasks: 4 executed, 1 up-to-date

Project files of test_gradle_war
(zip 52k) https://drive.google.com/file/d/14uafa9V4QsmdSs1yUjj3NlUP0sPHb9Fv/view?usp=drive_link

Why not?
You don’t have configuration cache enabled on that one, do you?

In the midst of troubleshooting, I recreated several test projects to find root cause. Sometimes the gradle.properties file is created in the root project directory with configuration-cache enabled. How do I ensure that file is created or not when creating a new project?

I also stumble on something else I don’t know if it’s related to the cache but when I change the project’s facet configuration (either through GUI or manually editing the XML file), the facets changed from:

<faceted-project>
	<fixed facet="jst.java"/>
	<fixed facet="jst.web"/>
	<installed facet="jst.web" version="6.1"/>
	<installed facet="jst.java" version="21"/>
</faceted-project>

to this every time gradle refreshes the root project:

<faceted-project>
	<fixed facet="jst.java"/>
	<fixed facet="jst.web"/>
	<installed facet="jst.web" version="2.4"/>
	<installed facet="jst.java" version="21"/>
</faceted-project>

It seems I’m not the only one having problems with facet changing on gradle refreshes.

How do I ensure that file is created or not when creating a new project?

Depends on how you create those projects I guess.
If you for example use the init task, it might maybe depend on the concrete options / answers you use, what content is generated.

It seems I’m not the only one having problems with facet changing on gradle refreshes

From a cursory look I’d say that is a different issue.
As far as I got, that issue is about additional things that get thrown out.
But that tag is generated by the eclipse-wtp plugin and the version is hard-coded and not directly configurable: gradle/platforms/ide/ide-plugins/src/main/java/org/gradle/plugins/ide/eclipse/EclipseWtpPlugin.java at v8.14.1 · gradle/gradle · GitHub

That things that are coming from the Gradle import are overwritten on Gradle import is normal and expected.
But you can use your buildscript to change the value to your liking, then you also don’t need to change it in the UI after import every time.

For example with this buildscript snippet in Kotlin DSL and the eclipse-wtp plugin applied, you can make 6.0 to be used:

eclipse {
    wtp {
        facet {
            facet(
                "type" to installed,
                "name" to "jst.web",
                "version" to "6.0"
            )
            file {
                whenMerged {
                    this as WtpFacet
                    facets.removeIf { (it.type == installed) && (it.name == "jst.web") && (it.version != "6.0") }
                }
            }
        }
    }
}