0

I am using maven build tool.

The following two are my intentions.

1) To move some of the third party library jars out of my war from WEB-INF/lib folder [note: These jars are common between more than 2 war files (or artifacts)]

2) To make the war file small in size.

Is it possible to move those jars out of war and put it into a folder and these jars should be referred in the classpath only by the wars which require it.

I have tried adding the path to the jars in the Class-Path: of MANIFEST.MF of war files but it did not work out. Please help me out.

Ravichandra
  • 1,260
  • 7
  • 23
  • 37

1 Answers1

0

I assume the jars in question are necessary for compiling the code that make up the web application. If the third-party jars are necessary for compilation but you don't want them in your war file, you have two options:

  1. In the <dependency></dependency> section for the third-party jar, add "<scope>provided</scope>".

  2. Configure the maven war plugin to exclude the jars you don't want in the war. See http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html for the details.

How you get the jar files that you exclude from the war into the web container's classpath depends on your environment. If you are using ear files, the Maven docs above talk about how to get the jars included in the ear file. If you are not using ear files, you will have to come up with your own way to get the jars into the container's lib directory.

Scott Frederick
  • 4,184
  • 19
  • 22