Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven makes war with two versions of the same jar

Tags:

maven-2

war

Maven puts both axis-1.3.jar and axis-1.4.jar to WEB-INF/lib of my war. Can someone explain how to tell it to use only axis-1.4.jar?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <groupId>dummy</groupId>
        <artifactId>test-war</artifactId>
        <version>0.1</version>
    </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>dummy</groupId>
  <artifactId>war-part2</artifactId>
  <name>war-part1</name>
  <version>0.1</version>
  <packaging>war</packaging>

  <dependencies>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>com.jaspersoft.jasperserver</groupId>
      <artifactId>jasperserver-ireport-plugin</artifactId>
      <version>2.0.1</version>
    </dependency>
  </dependencies>
</project>

[dependency:tree {execution: default-cli}]

+- org.apache.axis:axis:jar:1.4:compile
\- com.jaspersoft.jasperserver:jasperserver-ireport-plugin:jar:2.0.1:compile
   +- javax.activation:activation:jar:1.1:compile
   +- javax.mail:mail:jar:1.4:compile
   +- log4j:log4j:jar:1.2.12:compile
   \- com.jaspersoft.jasperserver:jasperserver-common-ws:jar:2.0.1:compile
      +- xerces:xercesImpl:jar:2.8.1:compile
      |  \- xml-apis:xml-apis:jar:1.3.03:compile
      \- axis:axis:jar:1.3:compile
         +- axis:axis-jaxrpc:jar:1.3:compile
         +- axis:axis-saaj:jar:1.3:compile
         +- wsdl4j:wsdl4j:jar:1.5.1:compile
         +- commons-logging:commons-logging:jar:1.0.4:compile
         \- commons-discovery:commons-discovery:jar:0.2:compile

Maven is 2.2.1

like image 727
basin Avatar asked Sep 14 '10 15:09

basin


1 Answers

In theory, Maven should handle the convergence of the version of an artifact present in dependencies or transitive dependencies. The problem here is that axis-1.4.jar and axis-1.3.jar don't have the same groupId (org.apache.axis vs axis) so Maven see them as distinct artifacts and include them both.

If you don't want to get axis-1.3.jar but only axis-1.4.jar, you'll have to exclude the unwanted from the jasperserver-ireport-plugin dependency explicitly using an exclusion:

<dependency>
  <groupId>com.jaspersoft.jasperserver</groupId>
  <artifactId>jasperserver-ireport-plugin</artifactId>
  <version>2.0.1</version>
  <exclusions>
    <exclusion>
      <groupId>axis</groupId>
      <artifactId>axis</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Can't say if jasperserver-ireport-plugin will work with axis-1.4.jar though.

like image 87
Pascal Thivent Avatar answered Oct 17 '22 03:10

Pascal Thivent