In my previous blog (http://magnus-k-karlsson.blogspot.se/2012/04/handling-java-enterprise-dependency.html) I was talking about the hardship of using Maven when developing Java Enterprise Applications. And this following up blog I will show the best practice I think of handling JBoss Enterprise dependency with Maven.
First when using JBoss dependency you will have to add the JBoss Repository. You can add this in your personal Maven configuration file, settings.xml as described at the JBoss Community page https://community.jboss.org/wiki/MavenGettingStarted-Users. Or you can add the repository in your parent pom. I think the best way is to do it in your parent pom, since it is more clear to less experience programmers.
I have left out the rest of the configuration, since it is anyway default values, you can read more about the above configuration below:
Or if you already have upgraded to the latest Maven 3 version:
If you are using a different version of maven simple change the above URL with you maven version.
Now to the real work adding JBoss Enterprise Dependency. The hardest part is the first part. What is the groupId and artifactIf for the JBoss dependency? And this is not at all clear at the beginning. But Red Hat have submitted a version fil with JBoss:
JBoss AS (Community Edition) and JBoss EAP (Enterpise Application Platform)
When looking for Maven Dependency groupId and artifactId you should look for implVendorID which is groupId and implVersion which is the version in Maven. But the problem is in most cases implVendorID is replaced with an URL, that will not help us much.
But JBoss have actually deployed there dependency matrix in there repository:
As you can see they have preserved the groupId and artifactId for most of there JBoss releases and that is a good, because that makes component more easy to discover. But instead of now searching the component matrix for the specific dependency and it version you can actually import this pom to maven with
And now to import the JBoss Enterprise Dependency:
NOTE: that here I'm not specifying the version number that is retrieved from the above pom import. You can verify that either with m2eclipse or with Maven:
Sadly the JBoss Enterprise Dependency jboss-javaee is not always complete, so if you are for example using standard JAX-WS you will have to add that additionally:
And if you are programming MBeans they are not at all defined in the jboss-as-component-matrix, so you will have to completely add them with version:
Well nothing is perfect but with this way the dependency should be a little more clearer and easier to maintain.