added a comment - - edited
Here's a more complete head's up of what's been done so far, and what's left to be done :
The WTPProjectConfigurator has been reworked to use a delegate pattern : Depending on a project type, it uses the corresponding IProjectConfiguratorDelegate.
So far only war, ejb and ear are supported so we have 3 implementations:
When the project is configured, WTPProjectConfigurator calls :
- IProjectConfiguratorDelegate.configure() : installs the corresponding WTP Facets (Dynamic Web Project, EJB, EAR)
- IProjectConfiguratorDelegate.setModuleDependencies() : loops on every dependent artifact and configure them as component dependencies the WTP way.
When a maven project has changed in the workspace, IProjectConfiguratorDelegate.setModuleDependencies() is called to update the component dependencies.
Each IProjectConfiguratorDelegate relies on a XXXPluginConfiguration to extract informations from the corresponding maven plugin in pom.xml :
- WarPluginConfiguration for maven-war-plugin
- EjbPluginConfiguration for maven-ejb-plugin
- EarPluginConfiguration for maven-ear-plugin
EJB support :
EjbProjectConfiguratorDelegate pretty much adds the EJB Facet version and configures the content directory and that's it.
The ejbVersion tag is read from ejb mojo. If it's not configured ,the default EJB Facet version is 2.1 (same as maven).
The content directory is the first resources directory configured in pom.xml (src\main\resources by default)
setModuleDependencies is not implemented (yet), as it pretty much works as a regular java project. I didn't delve too much into that part, so there might be some additional work there.
Ejb Clients are not supported. WTP creates an application client project whereas it's just a matter of saying generateClient=true for maven-ejb-plugin. I haven't started to think how to handle this.
For EJB projects prior to 3.0, an empty ejb-jar.xml is automatically created in the content directory.
EAR Support :
As I already said, to add EAR support, we need to do follow the steps of org.eclipse.jst.j2ee.ui.AddModulestoEARPropertiesPage.
Parts of WTP's code was reused in EarProjectConfiguratorDelegate
In EarProjectConfiguratorDelegate.configure(), we :
- Add EAR facet version, read from the version tag in ear mojo
- set the content directory (same as EJB)
- should update the bundle lib directory (API exists in WTP 3.0.0, currently not implemented here)
What should be done in EarProjectConfiguratorDelegate.setModules()
- get the earmodules configured in maven-ear-plugin : calls EarPluginConfiguration.getEarModules() (an earmodule is an artifact dependency of the ear project)
- configure each earmodule that is a workspace dependency (by calling the configure() method of its IProjectConfiguratorDelegate if it has not already been configured)
- each non project earmodule is referenced using the M2_REPO variable
- remove the deleted referenced components : For each deployement directory, delete the existing WTP referenced components that are missing from the current pom dependencies (still not implemented)
- configure earmodules per deployment directory : For each deployement directory declared in pom.xml, create a referenced component per earmodule, get its URI and call AddComponentToEnterpriseApplicationDataModelProvider
Something that might be a problem : WTP 3.0.0 lets you define one lib directory, whereas maven-ear-plugin lets you set a different lib directory for each module if it pleases you.
My implementation tries to comply with maven config (loops on each deployement dir), but I haven't tried it with WTP 3.0.0. It might produce strange behaviour in the J2EE Module Dependencies page of the ear project.
- generate the deployment descriptor : automatically done for ear projects <= 2.4. For some reason doesn't work for 5.0 ears. We need to find the WTP API responsible for DD generation.
As for now, I don't know how to set alt-dds and security roles using the wtp api.
In order to read the earmodules from maven-ear-plugin, I didn't want to reinvent the wheel, so I reused a large part of maven-ear-plugin base code, which is under ASF Licence.
If Eclipse IP folks are not ok with that, well I can just format my brains, forget what I saw and you guys find a better idea.
So basically, EarPluginConfiguration.getEarModules() is a port of or.apache.maven.plugins.ear.AbstractEarMojo
Configuration of the custom earmodules (defined in maven-ear-plugin > configuration > modules) is not implemented yet.
As Eugene cleverly noted, the problem with that approach is we might get out of synch w/ maven-ear-plugin evolutions.
But I think we'll have the same problem with every ProjectConfigurator implementation that reverse engineers maven plugins.
Jboss stuff is still not supported. That means no custom file types, nor jboss configurations.
My opinion is that it should be implemented by Jboss IDE folks, if we provide the right extension points. The discussion is open
My current implementation might not be as open as needed but I have zero eclipse plugin developement experience.
So far :
In WTP 2.0.2 and 3.0.0, you can't change the JEE facet version, so if you create an ejb project from scratch with the maven wizard, it'll be a 2.1 JEE version.
To have an ejb 3.0, you would have to :
- logically delete the project in eclipse (do not delete content)
- manually remove the wtp config files
- import the project again
I successfully deployed an ear w/ 2 skinny wars and 1 ejb 2.1 on jboss \o/.
For the wars config, optional dependencies are not handled correctly so I declared them as provided,
then I had to manually configure the war projects manifests (via the j2ee modules dependencies page). We should take a look at automatic Manifest configuration.
I got a strange behavior with xdoclet when generating the ejb, it's not happy with the standard maven directory config,
so it didn't generate the jboss deployment descriptor, but that's another issue. I had to create and copy it from another non maven project.
I can't get ears 5.0 to work as they 're missing the application.xml. I bet that's everybody most wanted feature
I'm currently having issues synch'ing with SVN tonight, but you can take a look at http://svn.sonatype.org/m2eclipse/branches/ear-support/
Development's been stalling a bit on my side, I'm sorry for that but spare time is really an issue. I don't think there's more than a few days work left.
Hopefully Eugene involvment'll speed things up.
I'm sure I forgot some things. As always, I'm open to questions/comments/insults.