What is the `eclipse-wtp` plugin for, and how does it differ from the plain `eclipse` plugin?
answer
- WTP = Web Tools Platform, server deploy
- writes wst.common.component + facet.core.xml
- eclipse.wtp { component { } facet { } }
- plus/minusConfigurations -> WEB-INF/lib
- layered on top of eclipse plugin
basics
~10 seclipse-wtp adds Web Tools Platform metadata for web/EE projects (WAR/EAR). It generates .settings/org.eclipse.wst.common.* files describing deployment assembly and facets, on top of the .project/.classpath the eclipse plugin produces.
solid answer
~40 sThe plain `eclipse` plugin only describes a Java project. `eclipse-wtp` layers on **Web Tools Platform** support so Eclipse can deploy the module to a server. Applied (usually alongside `war` or `ear`), it generates WTP metadata: `.settings/org.eclipse.wst.common.component` (the deployment assembly — which folders/dependencies map to which deploy paths) and `.settings/org.eclipse.wst.common.project.facet.core.xml` (facets like `jst.web`/`jst.java` and their versions). It exposes the `eclipse.wtp { component { … } facet { … } }` DSL, with `plusConfigurations`/`minusConfigurations` to control which dependencies are packaged into `WEB-INF/lib`, plus the same `whenMerged`/`withXml` hooks. You apply it when you need WTP server publishing from Eclipse; otherwise the plain `eclipse` plugin is enough.
code
kotlin · 16 linesplugins {
war
`eclipse-wtp`
}
eclipse {
wtp {
component {
contextPath = "/app"
minusConfigurations.add(configurations["providedRuntime"])
}
facet {
facet(mapOf("name" to "jst.web", "version" to "4.0"))
}
}
}go deeper
Know that WTP is the 'web/EE deploy' variant of the eclipse plugin.
Name the two extra files and that you apply it with war/ear.
Explain component vs. facet, and how plus/minusConfigurations shape the deployment assembly.
Decide whether Eclipse-server-deploy workflows are supported org-wide vs. container/Buildship-based runs, and codify it.
## The problem WTP solves Eclipse **Web Tools Platform (WTP)** lets Eclipse deploy a web/Java EE module to a server (Tomcat, etc.) and run/debug it in place. To do that, Eclipse needs more than `.project`/`.classpath`: it needs to know the **deployment assembly** (which source/output folders and which dependency jars map to which runtime paths like `WEB-INF/classes`, `WEB-INF/lib`) and the **facets** (the technology profile, e.g. Dynamic Web Module + Java). ## What `eclipse-wtp` generates Applying `eclipse-wtp` (typically with `war` or `ear`) registers tasks that write: - `.settings/org.eclipse.wst.common.component` — the **deployment assembly**: `wb-resource` mappings and dependent-module entries. - `.settings/org.eclipse.wst.common.project.facet.core.xml` — the **facets** and their versions (e.g. `jst.web 4.0`, `jst.java 17`). These sit on top of the `.project`/`.classpath` the `eclipse` plugin emits (which `eclipse-wtp` pulls in). ## The DSL ```kotlin plugins { war `eclipse-wtp` } eclipse { wtp { component { // which configs become deployed libs plusConfigurations.add(configurations["runtimeClasspath"]) minusConfigurations.add(configurations["providedRuntime"]) contextPath = "/app" deployName = "app" } facet { facet(mapOf("name" to "jst.web", "version" to "4.0")) facet(mapOf("name" to "jst.java", "version" to "17")) } } } ``` - **component** drives the deployment-assembly file; `plus/minusConfigurations` decide which dependencies are deployed (so `providedRuntime`/`compileOnly`-style deps can be excluded from `WEB-INF/lib`). - **facet** drives the facets file. - Both support `file.whenMerged`/`withXml` for fine edits. ## eclipse vs. eclipse-wtp | | `eclipse` | `eclipse-wtp` | |---|---|---| | Output | `.project`, `.classpath`, JDT prefs | + WTP component & facet files | | Use case | Any Java project | Web/EE deploy from Eclipse | | Depends on | `java`/`java-base` | usually `war`/`ear` + applies `eclipse` | If you don't deploy to a server from Eclipse, you don't need WTP — it just adds metadata you'd otherwise ignore.
- Which two settings files does eclipse-wtp generate beyond the plain eclipse output?`.settings/org.eclipse.wst.common.component` (deployment assembly) and `.settings/org.eclipse.wst.common.project.facet.core.xml` (facets).
- How do you keep a provided/compileOnly dependency out of WEB-INF/lib?Add its configuration to `wtp.component.minusConfigurations` so it isn't packaged into the deployment assembly.
- Does eclipse-wtp require the plain eclipse plugin?It applies the eclipse plugin functionality itself; the WTP metadata is layered on top of the `.project`/`.classpath` output.
saying these in an interview costs you the question
- Thinking eclipse-wtp replaces the eclipse plugin rather than extending it.
- Believing facets/component files matter for a non-deployed library project.
- Forgetting that minusConfigurations controls deployed libs, not the compile classpath.