How to remove a .jar file from a maven-dependent war

I have a maven3 webapp (war) project that has 2 dependencies. One of them is a bank (ehcache), and the other is military dependence (a third-party library that I do not control).

Third-party military dependency has a dependency on a much earlier version of ehcache, which encounters a later version that I need to use.

The following steps occur during the package of my application.

  • My copy of ehcache is copied to / WEB -INF / lib /
  • . The .war dependency, which also includes ehcache, is built and overlaid on top of my target.
  • The final.war file is created from the target

No matter what I do, war always includes an earlier version of ehcache. I even tried writing an ant script, which I execute through maven-antrun-plugin, which removes the .jar file from the target directory. However, this is always done before the .war dependency is imposed.

Does anyone know how I can exclude / remove an earlier version of ehcache?

+5
source share
2 answers

You will probably need to exclude the ehcache jar by the file name from your overlay. If you have not yet declared an explicit overlay for your dependent war, you will have to do this in the configuration of the war plugin:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.2</version>
      <configuration>
        <overlays>
          <overlay>
            <groupId>your.thirdparty.war.groupId</groupId>
            <artifactId>your.thirdparty.war.artifactId</artifactId>
            <excludes>
              <exclude>WEB-INF/lib/ehcache*.jar</exclude>
            </excludes>
          </overlay>
        </overlays>
      </configuration>
    </plugin>
  </plugins>
</build>
+8
source

All Articles