philihpAboutPGPLightning

Using Eclipse WTP with Maven's eclipse:eclipse Goal

Philihp Busby,0 min read

If you use Maven's "eclipse:eclipse" goal to generate a project descriptor for eclipse, by default you're just going to get a plain Java project. You'll have to add in the Dynamic Web facet in order to tell Eclipse that you can deploy this project in a web container. The easy way around this is to configure the maven-eclipse-plugin in the pom.xml file like this:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8</version> <configuration> <wtpContextName>some/url/context</wtpContextName> <wtpversion>1.5</wtpversion> </configuration> </plugin>

Also, I like to download sources and Javadoc, which makes navigating in Eclipse a lot easier. This can be done like this.

<plugin> ... <configuration> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> </configuration> </plugin>

Supposing you also want your project to have JPA facets, or other additional project facets you could also add them in like this

<plugin> ... <configuration> <additionalProjectFacets> <jpt.jpa>2.0</jpt.jpa> </additionalProjectFacets> </configuration> </plugin>

And all of these can be combined to do this

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8</version> <configuration> <wtpContextName>list</wtpContextName> <wtpversion>1.5</wtpversion> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> <additionalProjectFacets> <jpt.jpa>2.0</jpt.jpa> </additionalProjectFacets> </configuration> </plugin>

GitHub · Bluesky · LinkedIn · Instagram · KeybaseRSS

Built from 8f0906ac CC BY 4.0 — with love from San Francisco.