I have created Maven projects inside Eclipse with these archetypes:
- ejb-javaee6
- webapp-javaee6
The projects were created without facets.
Does it make sense to convert such Maven projects into faceted form?
Which facets would be helpful and which ones could cause trouble for a Maven project?
Specifically: Would any of the following project facets be in conflict with something that is in the responsibility of Maven?
- Java
- JavaScript
- EJB Module
- Dynamic Web Module
- GlassFish Deployment Descriptors Files
- JavaServer Faces
I have the impression that converting a Maven project to faceted form would mean mixing two worlds. Therefore I tend to NOT enable ANY project facets.
But where I work we have examples of Maven projects that are in faceted form and I was wondering whether there might be (risk-free) benefits to it.
Eclipse facets and maven archetypes are orthogonal - i.e. they have no influence on each other, or rather no knowledge of each other. You can safely add the facets if it will facilitate your work with eclipse.
After some experimenting I think I have something that works (except that I cannot get m2e to accept Java 1.7 for EJBs).
Versions:
- Eclipse Juno 4.2
- m2e 1.3.1
- GlassFish 3.1.2
- JDK 1.7.0_17 (Oracle)
IMPORTANT USAGE NOTE: With the setup below, you should disable automatic publishing to GlassFish ("Never publish automatically") if you want to run Maven clean & install. For the usual editing and saving work in Eclipse, automatic publishing can be enabled and seems to work fine. Only when starting Maven explicitly (inside Eclipse) did I encounter problems.
Setting up an EJB project with Maven in Eclipse
Create Maven projects in Eclipse with these archetypes:
ejb-javaee6
ear-javaee6
webapp-javaee6
webapp-javaee6
--------------
- Convert to faceted form, select GlassFish in Runtimes and enable:
- Dynamic Web Module
- GlassFish Deployment Descriptors Files
- Java
- JavaScript
- JavaServer Faces
Further configuration available...
- Content directory: src/main/webapp
- NOT checked: Generate web.xml deployment descriptor
- JSF Capabilities (all defaults): JSF 2.1 + PrimeFaces selected
CHECKED: "Include libraries with this application"
ejb-javaee6
-----------
- Convert to faceted form, select GlassFish in Runtimes and enable:
- EJB Module
- GlassFish Deployment Descriptors Files
- Java
Further configuration available...
- NOT checked: Generate ejb-jar.xml deployment descriptor
ear-javaee6
-----------
- Convert to faceted form, select GlassFish in Runtimes and enable:
- EAR
- GlassFish Deployment Descriptors Files
Further configuration available...
- Add EJB and WEB projects as dependencies
- Content directory: src/main/application (META-INF location used by Maven)
- NOT checked: Generate application.xml deployment descriptor
来源:https://stackoverflow.com/questions/16216838/maven-vs-eclipse-project-facets-for-java-ee-6