maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <its_toas...@yahoo.com.INVALID>
Subject Re: I want to separate the 3rd party jar in war file.
Date Fri, 18 Mar 2016 08:48:41 GMT
As Anders has said, you can use <scope>provided</scope> for those third
party JARs that you wish to exclude from the WAR file, but still need
when the application runs on your server.

There are few advantages to this and several disadvantages.

The advantages include a smaller WAR file, which means faster
deployment, faster transfers, and a smaller file within your local
repository (you do use a corporate repository, yes?).

As Anders has stated as well, the problem then becomes a configuration
management issue. Your development, testing, user acceptance test, and
production environments must all provide the same versions of the 165
JARs that you currently include in your WAR file. Mismatched versions
can lead to some very subtle issues.

Another problem with using <scope>provided</scope> is when you run
multiple web applications in one container. They must all use the same
version of common JARs, otherwise issues can arise with incompatible
versions of various libraries. Class loading may minimize this, but
there are 'interesting' edge cases.

Upgrading the shared libraries means that all applications must function
with the upgrade. Also, when you do the upgrade, the server must be shut
down.

In short, using a <scope>provided</scope> for the 165 JARs (or subset of
those JARs) is workable if you are careful with server configuration
management as well as cross-application compatibility (or you only run
one application per server). Otherwise, you can end up with errors with
the root cause being dependency version incompatibility.

Some people do this, and manage the dependencies at the server level.
Other people manage the dependencies at the application level.

. . . just my (sleepy) 2 cents
/mde/


On 3/18/2016 12:10 AM, Anders Hammar wrote:
> If some dependencies are already provided by the runtime (e.g. the app
> server) you use scope 'provided'. That will make those dependencies used
> during compilation but htey are not included in the war. More details on
> the different dependency scopes can be find by googling.
> However, using a different setup for local development and production is
> strongly discouraged, it will only lead to errors. So if you have some jars
> outside of your war during dev (i.e. 'provided') you should do that in
> production as well.
> 
> /Anders
> 
> On Fri, Mar 18, 2016 at 7:43 AM, pradeepkumar <pradeepkumar.scm@gmail.com>
> wrote:
> 
>> I want to separate the 3rd party jar in war file.
>> Currently we have 165 jars are  using in our project. Out of this only 27
>> jars are belongs to Application jars then rest of jars are 3rd party jars.
>> In our projects our dev team is maintaining the jars in a separate folder
>> in
>> one drive as shown below.
>> C:\Tomcatconfiguration\lib\Jar1 .. jar100
>> they will make use of those jars through eclipse.
>>
>> In the same way we have a job which will generate the war lets say Desktop.
>> in the same Desktop code there are maintaining some jars at
>> WebContent\WEB-INF\lib level.
>>
>> But i am adding all the dependencies in all the pom.xmls then war are
>> generated and working as expected. But the war file size is growing.
>> When ever i generate the war file all the 165 jars are included in war file
>> .then the war file  size is growing.
>> So i want to separate the 3rd party jars from war file.
>> I don't want to include all the 3rd party jars in WAR and want to use only
>> application jars.
>> Whenever i want to deploy i want make use of 3rd party jars.
>> Can anyone suggest the best way and how can i do this.
>> right now i am separating the the 3rd party jars by using the scope compile
>> <scope>compile</scope> tag in all the pom.xml as shown below .
>>                         <dependency>
>>                                 <groupId>org.apache.poi</groupId>
>>                                 <artifactId>poi</artifactId>
>>                                 <version>3.9</version>
>>                                 <scope>compile</scope>
>>                                 <optional>true</optional>
>>                         </dependency>
>>
>> Is this the right approch ? then how to make use of 3rd party jars.
>>
>> Please suggest .
>>
>>
>>



Mime
View raw message