You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mang Jun Lau <Ma...@otpp.com> on 2006/02/17 22:55:49 UTC

[M2] Adding jars to classpath in war manifest

Hi,

I've seen people ask this or a similar question before but I don't think 
it has ever been answered.  If it has then can some kind soul point me in 
the right direction?

Here's the situation:

I have an EAR and a WAR inside the EAR.  The EAR also contains JARs.  So 
here's a directory structure:

projectEAR
|--- moduleA.jar
|--- moduleB.jar
|--- JSPs.war
      |--- WEB-INF
           |--- lib
                |--- moduleC.jar
                |--- moduleD.jar

Now, let's say that moduleB and moduleC depends on moduleA.  Thus, moduleA 
has to be in the EAR so that both moduleB and C can find it without 
duplicating moduleA in the WAR.  So now, in my pom file for the WAR, the 
dependencies contain moduleC and moduleD but since moduleC depends on 
moduleA, moduleA automatically gets included in the WAR.  This duplication 
is something I don't want.  I add an exclusion to exclude moduleA but now 
it doesn't show up in the manifest classpath.

Since we can't use custom manifest files with the maven-war-plugin, I need 
to update the manifest manually after building.  So I want to get away 
from manually updating, I want to know if there's a way to add classpath 
entries to the manifest without including the actual jar since the jar is 
already located in the EAR.  Is there a way to do this?  I've tried 
different scope settings for the dependencies but they don't seem to work.

Is there something wrong with my structure?  All of my problems could be 
solved if the war plugin supports custom manifest files like the jar 
plugin does.


_Mang Lau

Re: [M2] Adding jars to classpath in war manifest

Posted by Mang Jun Lau <Ma...@otpp.com>.
Thanks for the reply Wayne.  I added the <addClasspath> line to my ear pom 
but it made no difference.  Both the webapp and the EAR have classpath 
entries in their manifest file but projects in the webapp still cannot 
find the resources in the EAR.  Back to my original structure:

projectEAR
|--- moduleA.jar
|--- moduleB.jar
|--- JSPs.war
      |--- WEB-INF
           |--- lib
                |--- moduleC.jar
                |--- moduleD.jar

We know that moduleC is dependent on moduleA, but since A is not in the 
webapp manifest, C cannot find A even though A is in the EAR manifest.  Is 
this assumption correct?

So using Maven, I put a dependency with a compile scope, moduleA will be 
in the webapp manifest but its jar will also be included in the webapp. So 
really I just want the classpath entry without including the jar in the 
webapp.  Is there a way to do this?

Hopefully someone knows how to do this.  Thanks again.


_Mang Lau





"Wayne Fay" <wa...@gmail.com> 
02/17/2006 05:39 PM
Please respond to
"Maven Users List" <us...@maven.apache.org>


To
"Maven Users List" <us...@maven.apache.org>
cc

Subject
Re: [M2] Adding jars to classpath in war manifest






This is what I'm using rather successfully...

in the webapp/pom.xml
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

in the ear/pom.xml
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

Give this a try, Mang, and let us know...

Wayne


On 2/17/06, Mang Jun Lau <Ma...@otpp.com> wrote:
> Hi,
>
> I've seen people ask this or a similar question before but I don't think
> it has ever been answered.  If it has then can some kind soul point me 
in
> the right direction?
>
> Here's the situation:
>
> I have an EAR and a WAR inside the EAR.  The EAR also contains JARs.  So
> here's a directory structure:

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org



Re: [M2] Adding jars to classpath in war manifest

Posted by Wayne Fay <wa...@gmail.com>.
This is what I'm using rather successfully...

in the webapp/pom.xml
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

in the ear/pom.xml
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

Give this a try, Mang, and let us know...

Wayne


On 2/17/06, Mang Jun Lau <Ma...@otpp.com> wrote:
> Hi,
>
> I've seen people ask this or a similar question before but I don't think
> it has ever been answered.  If it has then can some kind soul point me in
> the right direction?
>
> Here's the situation:
>
> I have an EAR and a WAR inside the EAR.  The EAR also contains JARs.  So
> here's a directory structure:

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org