Eclipse WTP + Gradle Buildship setup for 2025

For 2025, what is the correct way to setup a gradle sub-project in Eclipse, that works with the Tomcat 11 server?

Using: Eclipse 2024-12 (v4.34.0), Java 21, Tomcat 11, Dynamic Web Module v6.1, A gradle sub-project, Buildship Gradle Integration v3.0, Gradle v8.12.1, Gradle WAR plugin, Gradle eclipse-wtp plugin, and GIT.

The latest help requests I can find are from around 2019 and older. I would like to know the correct procedures to get a gradle sub-project working with a tomcat 11 server, instead of trying yet another wrong suggestion from 10+ years ago that wipes out or corrupts all of the config settings in all sub-projects. I’m finding it difficult to believe that whatever was causing issues with setting up a gradle/tomcat environment in a sub-project 10+ years ago, would still be an issue today, especially since I’m not finding any current topics. So I’m assuming its my fault and that I’ve done something horribly wrong, or just having the worst luck with searches.

I’ve read the documentation on gradle war and eclipse-wtp plugins, and just about anything else I can think may be the issue or may be related.

The war file is being properly generated and looks very much like all of the other war files that I’ve generated before; nothing is out of place or missing. I also have the sub-project setup with a WebContent directory, which contains all of the deployable content that Tomcat would require, including the WEB-INF directories with the lib resources and web.xml configs.

Some of the past symptoms that I was encountering, but have resolved: Setting made within Eclipse being reverted when ./gradlew build would run. Also ran in a lot of issues with buildship failing to initialize (Project configurator ‘org.eclipse.buildship.configurators.base’ failed to configure project ‘ares-web’ with no additional info about this error) until I removed all src directories from the sub-project (they were moved to another sub-project). Odd thing about the src directory, was that it was being wrapped in a “Java Resources” folder, of which, was not being done on any of the other sub-projects, as if it may have been messing with the classpath in unexpected ways.

But currently, although everything now appears to be fine with the builds, Tomcat will not recognize the sub-project as a valid resource to add to the tomcat server (Add and Remove option for web app resources).

Would anyone have any ideas that will work with the current software releases? Would there happen to be any formal documentation on how to properly setup this kind of an environment?

Some of the past suggestions would either wind up deleting needed config settings from all sub-projects, or would modify them to inject facets that they do not need. Many of the old suggestions have proven to be destructive without solving the problems.

Here is a copy of the ares-web sub-project’s build.gradle file. Its using dependency resolution management, which is why the implementation statements are simplified.

plugins {
    id 'java'
    id 'war'
    id 'eclipse-wtp'
}
repositories {
    mavenCentral()
}
dependencies {
	implementation project(':ares-core');
	implementation project(':ares-solr');
	implementation project(':ares-http');
	
	implementation( libs.gson )
	implementation( libs.commons.math3 )
	implementation( libs.guava )

	compileOnly( libs.jakarta.servlet.jsp )
	implementation( libs.jakarta.servlet.api )
	implementation( libs.jakarta.fileupload )
	
	implementation 'org.apache.tomcat.embed:tomcat-embed-core:11.0.0'
	implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:11.0.0'

	implementation( libs.bundles.log4j )
	  
	implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
}
eclipse {
    wtp {
        facet {
            facet name: 'jst.web', version: '6.1'
        }
    }
}

task cleanLibs(type: Delete) {
    delete "$projectDir/WebContent/WEB-INF/lib/"
    doLast {
        file("$projectDir/WebContent/WEB-INF/lib").mkdirs()
    }
}
task copyRuntimeLibs(type: Copy) {
	dependsOn cleanLibs
	dependsOn ':ares-core:jar' 
	dependsOn ':ares-solr:jar'
	dependsOn ':ares-http:jar'
	
	from configurations.runtimeClasspath.collect { it }
	into "$projectDir/WebContent/WEB-INF/lib"
	duplicatesStrategy = 'exclude'
}

war {
	dependsOn copyRuntimeLibs	
	enabled=true
	from 'WebContent'
	duplicatesStrategy = 'exclude'
}

Please let me know if there is any other additional information that could be helpful in figuring this out. Thank you for your time and help!

I found the cause of my problems and the simple solution.

Basically I was trying to use the Eclipse’s Dynamic Web Module facet v6.1. This is controlled though gradle with the setting:

eclipse {
    wtp {
        facet {
            facet name: 'jst.web', version: '6.1'
        }
    }
}

Unfortunately, it took me a while to figure out that Tomcat 11 only supports up to version 5.0.

That explains why I could not add it to the eclipse based tomcat servers too, since it was out of compliance.

So, from what I understand, the Dynamic Web Module v5.0, or jst.web v5.0, supports jakarta EE 9.0, which is what is supported in Tomcat 11.

So the correct, and proper fix for my gradle config is as follows:

eclipse {
    wtp {
        facet {
            facet name: 'jst.web', version: '5.0'
        }
    }
}

With this change, everything is now working as expected.