If you declare a dependency in Maven, you can add a type, like war, jar, ejb.
I understand that compiling a project with type ejb is different from compiling a project with type jar because it triggers a different lifecycle.
But what is the difference in declaring a dependency?
Maven dependency type ejb vs jar seems to ask the same question, but the accepted answer seems strange to me. I doubt that a type in a dependency can trigger a lifecycle. Actually, I would expect that type ejb and type jar do exactly the same thing. Can somebody shed light on this?
I doubt that a type in a dependency can trigger a lifecycle
You are not alone to doubt.
When you declare a dependency with the ejb
type, you benefit from some facilities provided by Maven related to ejb
as :
the ability to add the declaration of the EJB in the application.xml
.
Since Java EE 5, it is not required any longer.
the check that the dependency is a EJB and not a simple JAR.
and probably some other minor things.
You would have not these facilities if you declare your dependency with the jar type
.
As you can notice, it doesn't change at a lot of thing but anyway, in both cases, it is the same JAR which is used for the dependency.
You don't refer to the ejb-client
type but it is often something of more interesting since contrary to the case of the dependency with the jar
or ejb
type which uses the same jar, when you declare ejb-client
type in a dependency, you depend on a different jar that the classic jar since this jar should contain only API classes to call the ejb
.
Of course, if we want the version ejb-client
of our ejb
, we have to specify it in the artifact which produces the ejb
.