Richard,
I feel your pain. I struggled with similar issues at great length
several weeks back. On one hand, Maven's encouragement toward
modularity is a good thing, but something that comes with that is
that in handling upstream dependencies, there is no consideration
given to the downstream archive being built. So on one hand, there's
the argument that a WAR should be a self-contained archive, which is
a good argument; but pragmatically, doing so may result in huge EAR
files. Additionally, manipulating jar classpaths and the like doesn't
really help much, because you need upstream manipulation of these,
not just the EAR you are building. Add JBoss SARs and WSRs into the
mix, and the whole deal gets really fun.
I am sure there are some maven experts here that can give you better
advice than I on pursuing a solution. While it doesn't optimize file
size, the way it works now, keeping everything self-contained and
modular isn't a wrong approach -- you just probably won't like the
size of your EAR file. One possible approach might be to alter the
WAR plugin to allow inclusion or exclusion of dependencies, and treat
things the way the JAR plugin works. Another approach might be to
fork the EAR plugin and create a new plugin that will both create
your WAR and EAR in the same project. Just thoughts, maybe not good
ones, but ideas.
In the end, I concluded that the time investment to get it to
optimize dependency packaging wasn't worth it, and that the nuisance
of file size could be incurred. If you hit on a solution, let me know.
Brad
On Mar 22, 2006, at 11:23 AM, Wayne Fay wrote:
I've been wondering this myself and just "didn't care" enough to
really solve the "problem". ;-)
Fortunately the duplicated libs are not very large so it doesn't
affect me much (yet).
Anyone got a solution?
Wayne
On 3/22/06, Richard Sladek <[EMAIL PROTECTED]> wrote:
Hello,
I've been searching through the archive half of the day but I
haven't found
a satisfactory solution to my problem:
I have an EAR including 2 modules: EJB JAR and WAR.
These 2 modules have some common dependencies, lets say
mycommonlib.jar.
When I run the packaging on EAR, I get duplicates of mycommonlib.jar:
one is in EAR's root, the other is in WAR's WEB-INF/lib.
I found a way how to exclude this from WEB-INF/lib by providing:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
in my WAR's pom.xml
However, now none of my WAR's dependencies gets resolved to the
EAR (see
http://jira.codehaus.org/browse/MEAR-14), even those that are not
common.
Is there a way how could I force EAR plugin to enable transitive
dependencies on a WAR?
Also see
http://jira.codehaus.org/browse/MWAR-9
--
View this message in context: http://www.nabble.com/M2---Best-
practice-for-common-jars-between-EJB%2CWAR-modules-in-EAR-
t1325601.html#a3537700
Sent from the Maven - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]