1

does anybody know how to exclude specific lib from packiging to .war

I have a following dependency:

<dependency>
    <groupId>com.intel.mtwilson</groupId>
    <artifactId>mtwilson-client</artifactId>
    <version>2.0.3</version>
</dependency>

mtwilson-client-2.0.3.jar in WEB-INF then contains a library (javax servlet), which causes some troubles with application server. Is there a way how to exclude this specific lib from packaging? I can not exclude whole jar by setting provided tag.

Thank you in advance

Peeve
  • 49
  • 4

1 Answers1

0

The only thing that you need to do to exclude maven including the above jar in WAR is to mark it as provided.

so now your above dependency will now look like below:

<dependency>
    <groupId>com.intel.mtwilson</groupId>
    <artifactId>mtwilson-client</artifactId>
    <version>2.0.3</version>
    <scope>provided</scope>
</dependency>

Note: provided will not add particular JAR it to the war but will add a class path to the final war after build, which can cause some run time faults if you actually happen to miss the JAR somehow at deployment.

2nd thing you can do is to use <packagingExcludes> configuration parameter.

The syntax in POM.xml is like:

        <configuration>
          <packagingExcludes>WEB-INF/lib/mtwilson-client-2.0.3.jar</packagingExcludes>
        </configuration>

You can visit Apache Maven Doc on exclusion of a particular jar.

Vishwa Ratna
  • 5,567
  • 5
  • 33
  • 55
  • Thank you for your effort, but the goal is to get rif of specific library, which is opened in that JAR, not to exclude whole JAR itself. – Peeve Jan 31 '19 at 07:36