Hi David,

David Sharp wrote at Freitag, 28. August 2009 15:40:

>>I am not sure, I get your problem. By default your EJB will not contain
>>any jars and if you declare your EJB as dependency for your EAR the latter
>>will contain the EJB as well as all transitive dependencies of this EJB.
> 
> You are right.  I made an erroneous assumption that EJBs would be similar
> to
> wars (again I'm new to maven and EJBs).  However the question still holds
> for war projects.

By default all jars are embedded into the war's WEB-INF/lib folder. However,
it is possible to keepthem out there and put them into the EAR, but it must
be supported by the app server. There's an example in the maven-war-plugin
docs.

> How do I get dependencies to be placed in the ear?  The 
> best I can come up with is to declare the dependencies in the ear project
> pom with a scope of "compile", and then again in the war project pom, with
> a scope of "provided".

Because wars are normally self-contained they do not inherit their
dependencies transitively. What you can do, however, is to declare in your
ear not the war itself, but the war's pom file i.e. use type "pom" instead
of "war". This trick can be used to get all transitive dependencies of the
war also.

> Or is there a configuration setting for the war plugin that will tell it
> to package dependencies in the ear?

The war-plugin does not know anything about any other project that will use
the resulting war artifact. As explained you have to declare the
appropriate dependency in the ear's pom. However, you have to define a
value for the property "packagingExcludes" in the war plugin's
configuration to prevent the jars to be embedded into the war:

  <configuration>
    <packagingExcludes>WEB-INF/lib/**</packagingExcludes>
  </configuration>

You can define more patterns by separating them with comma. Patterns are
relative to the target/<webapp> directory as root where the plugin collects
all files before they are packed as war.

BTW: You have to ensure to use the latest version of the war-plugin for
this.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to